comparison lisp/dired-aux.el @ 99811:e9cd9fee6fd7

(dired-isearch-filenames): Add new context-dependent option `dwim'. Change non-dwim option from `dired-filename' to `t'. Doc fix. (dired-isearch-filenames-setup): Run filename Isearch only when dired-isearch-filenames is t or dired-isearch-filenames is `dwim' and the text property `dired-filename' at point is non-nil. In this case also set isearch-message-prefix-add to "filename ". (dired-isearch-filenames-end): Set isearch-message-prefix-add to nil. (dired-isearch-filenames, dired-isearch-filenames-regexp): Don't let-bind isearch-message-prefix-add since this is done now in dired-isearch-filenames-setup.
author Juri Linkov <juri@jurta.org>
date Sat, 22 Nov 2008 20:40:28 +0000
parents 833f28e62d37
children d42aff5ca541
comparison
equal deleted inserted replaced
99810:e47f7a922e57 99811:e9cd9fee6fd7
2302 2302
2303 2303
2304 ;; Search only in file names in the Dired buffer. 2304 ;; Search only in file names in the Dired buffer.
2305 2305
2306 (defcustom dired-isearch-filenames nil 2306 (defcustom dired-isearch-filenames nil
2307 "*If non-nil, Isearch in Dired matches only file names." 2307 "*Non-nil to Isearch in file names only.
2308 If t, Isearch in Dired always matches only file names.
2309 If `dwim', Isearch matches file names when initial point position is on
2310 a file name. Otherwise, it searches the whole buffer without restrictions."
2308 :type '(choice (const :tag "No restrictions" nil) 2311 :type '(choice (const :tag "No restrictions" nil)
2309 (const :tag "Isearch only in file names" dired-filename)) 2312 (const :tag "When point is on a file name initially, search file names" dwim)
2313 (const :tag "Always search in file names" t))
2310 :group 'dired 2314 :group 'dired
2311 :version "23.1") 2315 :version "23.1")
2312 2316
2313 (defvar dired-isearch-filter-predicate-orig nil) 2317 (defvar dired-isearch-filter-predicate-orig nil)
2314 2318
2327 2331
2328 ;;;###autoload 2332 ;;;###autoload
2329 (defun dired-isearch-filenames-setup () 2333 (defun dired-isearch-filenames-setup ()
2330 "Set up isearch to search in Dired file names. 2334 "Set up isearch to search in Dired file names.
2331 Intended to be added to `isearch-mode-hook'." 2335 Intended to be added to `isearch-mode-hook'."
2332 (when dired-isearch-filenames 2336 (when (or (eq dired-isearch-filenames t)
2337 (and (eq dired-isearch-filenames 'dwim)
2338 (get-text-property (point) 'dired-filename)))
2339 (setq isearch-message-prefix-add "filename ")
2333 (define-key isearch-mode-map "\M-sf" 'dired-isearch-filenames-toggle) 2340 (define-key isearch-mode-map "\M-sf" 'dired-isearch-filenames-toggle)
2334 (setq dired-isearch-filter-predicate-orig 2341 (setq dired-isearch-filter-predicate-orig
2335 (default-value 'isearch-filter-predicate)) 2342 (default-value 'isearch-filter-predicate))
2336 (setq-default isearch-filter-predicate 'dired-isearch-filter-filenames) 2343 (setq-default isearch-filter-predicate 'dired-isearch-filter-filenames)
2337 (add-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end nil t))) 2344 (add-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end nil t)))
2338 2345
2339 (defun dired-isearch-filenames-end () 2346 (defun dired-isearch-filenames-end ()
2340 "Clean up the Dired file name search after terminating isearch." 2347 "Clean up the Dired file name search after terminating isearch."
2348 (setq isearch-message-prefix-add nil)
2341 (define-key isearch-mode-map "\M-sf" nil) 2349 (define-key isearch-mode-map "\M-sf" nil)
2342 (setq-default isearch-filter-predicate dired-isearch-filter-predicate-orig) 2350 (setq-default isearch-filter-predicate dired-isearch-filter-predicate-orig)
2343 (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t)) 2351 (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t))
2344 2352
2345 (defun dired-isearch-filter-filenames (beg end) 2353 (defun dired-isearch-filter-filenames (beg end)
2352 2360
2353 ;;;###autoload 2361 ;;;###autoload
2354 (defun dired-isearch-filenames () 2362 (defun dired-isearch-filenames ()
2355 "Search for a string using Isearch only in file names in the Dired buffer." 2363 "Search for a string using Isearch only in file names in the Dired buffer."
2356 (interactive) 2364 (interactive)
2357 (let ((dired-isearch-filenames t) 2365 (let ((dired-isearch-filenames t))
2358 (isearch-message-prefix-add "filename "))
2359 (isearch-forward))) 2366 (isearch-forward)))
2360 2367
2361 ;;;###autoload 2368 ;;;###autoload
2362 (defun dired-isearch-filenames-regexp () 2369 (defun dired-isearch-filenames-regexp ()
2363 "Search for a regexp using Isearch only in file names in the Dired buffer." 2370 "Search for a regexp using Isearch only in file names in the Dired buffer."
2364 (interactive) 2371 (interactive)
2365 (let ((dired-isearch-filenames t) 2372 (let ((dired-isearch-filenames t))
2366 (isearch-message-prefix-add "filename "))
2367 (isearch-forward-regexp))) 2373 (isearch-forward-regexp)))
2368 2374
2369 2375
2370 ;; Functions for searching in tags style among marked files. 2376 ;; Functions for searching in tags style among marked files.
2371 2377