]> git.eshelyaron.com Git - emacs.git/commitdiff
(dired-isearch-filenames-toggle): New command.
authorJuri Linkov <juri@jurta.org>
Thu, 31 Jul 2008 16:50:54 +0000 (16:50 +0000)
committerJuri Linkov <juri@jurta.org>
Thu, 31 Jul 2008 16:50:54 +0000 (16:50 +0000)
(dired-isearch-filenames-setup): Bind "\M-sf" to
dired-isearch-filenames-toggle in isearch-mode-map.
(dired-isearch-filenames-end): Bind "\M-sf" to nil
in isearch-mode-map.

lisp/dired-aux.el

index 5feed9b2191aa37934ec5935f3b542e952994c75..a55b0a70fbc8cf4533c067ebd4229cc037da22c5 100644 (file)
@@ -2308,11 +2308,26 @@ Use \\[dired-hide-subdir] to (un)hide a particular subdirectory."
 
 (defvar dired-isearch-orig-success-function nil)
 
+(defun dired-isearch-filenames-toggle ()
+  "Toggle file names searching on or off.
+When on, Isearch checks the success of the current matching point
+using the function `dired-isearch-success-function' that matches only
+at file names.  When off, it uses the default function
+`isearch-success-function-default'."
+  (interactive)
+  (setq isearch-success-function
+       (if (eq isearch-success-function 'dired-isearch-success-function)
+           'isearch-success-function-default
+         'dired-isearch-success-function))
+  (setq isearch-success t isearch-adjusted t)
+  (isearch-update))
+
 ;;;###autoload
 (defun dired-isearch-filenames-setup ()
   "Set up isearch to search in Dired file names.
 Intended to be added to `isearch-mode-hook'."
   (when dired-isearch-filenames
+    (define-key isearch-mode-map "\M-sf" 'dired-isearch-filenames-toggle)
     (setq dired-isearch-orig-success-function
          (default-value 'isearch-success-function))
     (setq-default isearch-success-function 'dired-isearch-success-function)
@@ -2320,6 +2335,7 @@ Intended to be added to `isearch-mode-hook'."
 
 (defun dired-isearch-filenames-end ()
   "Clean up the Dired file name search after terminating isearch."
+  (define-key isearch-mode-map "\M-sf" nil)
   (setq-default isearch-success-function dired-isearch-orig-success-function)
   (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t))