On Thu, 21 Aug 2008 06:55:08 -0700 (PDT) "[EMAIL PROTECTED]" <[EMAIL 
PROTECTED]> wrote: 

sc> On Aug 21, 3:50 pm, Ted Zlatanov <[EMAIL PROTECTED]> wrote:
>> On Wed, 20 Aug 2008 13:27:46 -0700 (PDT) "[EMAIL PROTECTED]" <[EMAIL 
>> PROTECTED]> wrote:
>> 
>> You need to check if a file is going to be opened by Tramp; if so, it
>> usually requires a network trip and often is inconvenient for the user.

sc> Good point. I didn't occur to me slow network drives could be a
sc> problem.

>> For me at least, it's a very cool idea that is unusable without the
>> change above because my recent file history is spread over 20 servers
>> and 5 encrypted files.  I can send you a patch for the options above.

sc> Please do.

This was not heavily tested, so check it out for yourself.  I added
defcustoms to all your user-visible variables (except for the keymap), I
hope that's OK.  Users can now say 

(setq contentswitch-ignore '(hidden-buffer encrypted remote))

and it will skip remote or encrypted files and hidden buffers.  The
hidden-buffer option will not drop files with names starting with " "
because the function knows if you pass a buffer or not.

I made the default '(remote) but the set above may be more appropriate
for users in general.  Hidden buffers in particular can be a problem
since they can contain lots of junk data.

Ted

Index: contentswitch.el
===================================================================
RCS file: /home/tzz/cvsroot/emacs/contentswitch.el,v
retrieving revision 1.1
retrieving revision 1.3
diff -r1.1 -r1.3
59c59,63
< (defvar contentswitch-context-bias (if (featurep 'saveplace) 100)
---
> (defgroup contentswitch nil
>   "The contentswitch package."
>   :version "22.1")
> 
> (defcustom contentswitch-context-bias (if (featurep 'saveplace) 100)
78,86c82,96
< information this feature useless.")
< 
< (defvar contentswitch-enable-name-matches t
<   "If t then the query string is also tested on buffer and file
<   names for possible matches.")
< 
< (defvar contentswitch-jump-to-match-location nil
<   "If t then the after switching to the file point is put to the
<   location where the match was found.")
---
> information this feature useless."
>   :group 'contentswitch
>   :type '(radio (const :format "LRU order " nil)
> 		(const :format "Distance from point" t)
> 		(integer :format "Maximum non-unique matches: %v")))
> 
> (defcustom contentswitch-enable-name-matches t
>   "Match the query string against the buffer and file name as well."
>   :group 'contentswitch
>   :type 'boolean)
> 
> (defcustom contentswitch-jump-to-match-location nil
>   "After switching, put point at match."
>   :group 'contentswitch
>   :type 'boolean)
88c98
< (defvar contentswitch-file-history-variable
---
> (defcustom contentswitch-file-history-variable
100,124c110,160
< restored when Emacs is restarted.")
< 
< (defvar contentswitch-ignore nil
<   "List of regexps for excluding buffer and files from the results.")
< 
< (defvar contentswitch-max-files-from-history 30
<   "Do not show more matches from file history than this limit.")
< 
< (defvar contentswitch-file-completion-delay 0.3
<   "Delay before showing completions from file history.")
< 
< (defvar contentswitch-max-name-length 25
<   "Width of the name column in the result list.")
< 
< (defvar contentswitch-before-context-length 10
<   "Number of characters from context shown before the actual match.")
< 
< (defvar contentswitch-selection-face 'highlight
<   "Face for selection.")
< 
< (defvar contentswitch-context-face 'header-line
<   "Face for match context.")
< 
< (defvar contentswitch-match-face 'lazy-highlight
<   "Face for match.")
---
> restored when Emacs is restarted."
>   :group 'contentswitch
>   :type  '(choice :tag "File history"
> 		  (const :tag "recentf" recentf-list)
> 		  (const :tag "file name history" file-name-history)
> 		  (const :tag "Empty"  nil)))
> 
> (defcustom contentswitch-ignore '(remote)
>   "Options for excluding buffer and files from the results."
>   :group 'contentswitch
>   :type
>   '(repeat (choice :tag "Ignore these"
> 		   (regexp :tag "Regular expression")
> 		   (const :tag "Remote filenames" remote)
> 		   (const :tag "Encrypted files" encrypted)
> 		   (const :tag "Hidden buffers" hidden-buffer))))
> 
> (defcustom contentswitch-max-files-from-history 30
>   "Do not show more matches from file history than this limit."
>   :group 'contentswitch
>   :type 'integer)
> 
> (defcustom contentswitch-file-completion-delay 0.3
>   "Delay before showing completions from file history."
>   :group 'contentswitch
>   :type 'float)
> 
> (defcustom contentswitch-max-name-length 25
>   "Width of the name column in the result list."
>   :group 'contentswitch
>   :type 'integer)
> 
> (defcustom contentswitch-before-context-length 10
>   "Number of characters from context shown before the actual match."
>   :group 'contentswitch
>   :type 'integer)
> 
> (defcustom contentswitch-selection-face 'highlight
>   "Face for selection."
>   :group 'contentswitch
>   :type 'face)
> 
> (defcustom contentswitch-context-face 'header-line
>   "Face for match context."
>   :group 'contentswitch
>   :type 'face)
> 
> (defcustom contentswitch-match-face 'lazy-highlight
>   "Face for match."
>   :group 'contentswitch
>   :type 'face)
254a291,308
> (defun contentswitch-ignore-p (item)
>   (let ((name (if (bufferp item) 
> 		 (buffer-name item) 
> 	       item)))
>     (or
>      (and (member 'remote contentswitch-ignore)
> 	  (file-remote-p name))
>      (and (member 'encrypted contentswitch-ignore)
> 	  (featurep 'epa-file)
> 	  (string-match epa-file-name-regexp name))
>      (and (member 'hidden-buffer contentswitch-ignore)
> 	  (bufferp item)
> 	  (string-match "^ " name))
>      (some (lambda (regex)
> 	     (and (stringp regex)
> 		  (string-match regex name)))
> 	   contentswitch-ignore))))
> 
283,286c337
<                                (some (lambda (regex)
<                                        (string-match
<                                         regex (buffer-name buffer)))
<                                      contentswitch-ignore)
---
> 			       (contentswitch-ignore-p buffer)
306,308c357
<                                 (some (lambda (regex)
<                                         (string-match regex file))
<                                      contentswitch-ignore))
---
> 				(contentswitch-ignore-p file))
_______________________________________________
gnu-emacs-sources mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources

Reply via email to