diff options
author | Juri Linkov <juri@jurta.org> | 2008-07-29 14:42:35 +0000 |
---|---|---|
committer | Juri Linkov <juri@jurta.org> | 2008-07-29 14:42:35 +0000 |
commit | b4b6bda21c250f60a3ec93a2d94d94c4783aacce (patch) | |
tree | b1eeb6c3e056e9d13352759935b4c53f5520a33c /lisp | |
parent | eae2c85eec693a0ffed2fa5f3edf43f3d4ac2845 (diff) | |
download | emacs-b4b6bda21c250f60a3ec93a2d94d94c4783aacce.tar.gz emacs-b4b6bda21c250f60a3ec93a2d94d94c4783aacce.tar.bz2 emacs-b4b6bda21c250f60a3ec93a2d94d94c4783aacce.zip |
(dired-isearch-filenames): New user option.
(dired-isearch-orig-success-function): New internal variable.
(dired-isearch-filenames-setup, dired-isearch-filenames-end)
(dired-isearch-success-function): New functions.
(dired-isearch-filenames, dired-isearch-filenames-regexp): New commands.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/dired-aux.el | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 523f29e1b63..76f90cd4f82 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -2279,6 +2279,54 @@ Use \\[dired-hide-subdir] to (un)hide a particular subdirectory." ;;;###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 |