emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/dired-aux.el,v


From: Juri Linkov
Subject: [Emacs-diffs] Changes to emacs/lisp/dired-aux.el,v
Date: Tue, 29 Jul 2008 14:42:35 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Juri Linkov <jurta>     08/07/29 14:42:35

Index: dired-aux.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/dired-aux.el,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -b -r1.173 -r1.174
--- dired-aux.el        28 Jul 2008 14:28:59 -0000      1.173
+++ dired-aux.el        29 Jul 2008 14:42:35 -0000      1.174
@@ -2279,6 +2279,54 @@
 ;;;###end dired-ins.el
 
 
+;; Search only in file names in the Dired buffer.
+
+(defcustom dired-isearch-filenames nil
+  "*If non-nil, Isearch in Dired matches only file names."
+  :type '(choice (const :tag "No restrictions" nil)
+                (const :tag "Isearch only in file names" dired-filename))
+  :group 'dired
+  :version "23.1")
+
+(defvar dired-isearch-orig-success-function nil)
+
+(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
+    (setq dired-isearch-orig-success-function
+         (default-value 'isearch-success-function))
+    (setq-default isearch-success-function 'dired-isearch-success-function)
+    (add-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end nil t)))
+
+(defun dired-isearch-filenames-end ()
+  "Clean up the Dired file name search after terminating isearch."
+  (setq-default isearch-success-function dired-isearch-orig-success-function)
+  (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t))
+
+(defun dired-isearch-success-function (beg end)
+  "Match only at visible regions with the text property `dired-filename'."
+  (and (isearch-success-function-default beg end)
+       (if dired-isearch-filenames
+          (text-property-not-all (min beg end) (max beg end)
+                                 'dired-filename nil)
+        t)))
+
+;;;###autoload
+(defun dired-isearch-filenames ()
+  "Search for a string using Isearch only in file names in the Dired buffer."
+  (interactive)
+  (let ((dired-isearch-filenames t))
+    (isearch-forward)))
+
+;;;###autoload
+(defun dired-isearch-filenames-regexp ()
+  "Search for a regexp using Isearch only in file names in the Dired buffer."
+  (interactive)
+  (let ((dired-isearch-filenames t))
+    (isearch-forward-regexp)))
+
+
 ;; Functions for searching in tags style among marked files.
 
 ;;;###autoload




reply via email to

[Prev in Thread] Current Thread [Next in Thread]