comparison lisp/dired-aux.el @ 97080:7c116c0a454b

(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.
author Juri Linkov <juri@jurta.org>
date Tue, 29 Jul 2008 14:42:35 +0000
parents 2104d5663cdd
children 535cfa18fb6d
comparison
equal deleted inserted replaced
97079:22b04404b5d5 97080:7c116c0a454b
2277 (restore-buffer-modified-p modflag))) 2277 (restore-buffer-modified-p modflag)))
2278 2278
2279 ;;;###end dired-ins.el 2279 ;;;###end dired-ins.el
2280 2280
2281 2281
2282 ;; Search only in file names in the Dired buffer.
2283
2284 (defcustom dired-isearch-filenames nil
2285 "*If non-nil, Isearch in Dired matches only file names."
2286 :type '(choice (const :tag "No restrictions" nil)
2287 (const :tag "Isearch only in file names" dired-filename))
2288 :group 'dired
2289 :version "23.1")
2290
2291 (defvar dired-isearch-orig-success-function nil)
2292
2293 (defun dired-isearch-filenames-setup ()
2294 "Set up isearch to search in Dired file names.
2295 Intended to be added to `isearch-mode-hook'."
2296 (when dired-isearch-filenames
2297 (setq dired-isearch-orig-success-function
2298 (default-value 'isearch-success-function))
2299 (setq-default isearch-success-function 'dired-isearch-success-function)
2300 (add-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end nil t)))
2301
2302 (defun dired-isearch-filenames-end ()
2303 "Clean up the Dired file name search after terminating isearch."
2304 (setq-default isearch-success-function dired-isearch-orig-success-function)
2305 (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t))
2306
2307 (defun dired-isearch-success-function (beg end)
2308 "Match only at visible regions with the text property `dired-filename'."
2309 (and (isearch-success-function-default beg end)
2310 (if dired-isearch-filenames
2311 (text-property-not-all (min beg end) (max beg end)
2312 'dired-filename nil)
2313 t)))
2314
2315 ;;;###autoload
2316 (defun dired-isearch-filenames ()
2317 "Search for a string using Isearch only in file names in the Dired buffer."
2318 (interactive)
2319 (let ((dired-isearch-filenames t))
2320 (isearch-forward)))
2321
2322 ;;;###autoload
2323 (defun dired-isearch-filenames-regexp ()
2324 "Search for a regexp using Isearch only in file names in the Dired buffer."
2325 (interactive)
2326 (let ((dired-isearch-filenames t))
2327 (isearch-forward-regexp)))
2328
2329
2282 ;; Functions for searching in tags style among marked files. 2330 ;; Functions for searching in tags style among marked files.
2283 2331
2284 ;;;###autoload 2332 ;;;###autoload
2285 (defun dired-do-isearch () 2333 (defun dired-do-isearch ()
2286 "Search for a string through all marked files using Isearch." 2334 "Search for a string through all marked files using Isearch."