diff options
| author | Juri Linkov | 2008-07-29 14:42:35 +0000 |
|---|---|---|
| committer | Juri Linkov | 2008-07-29 14:42:35 +0000 |
| commit | b4b6bda21c250f60a3ec93a2d94d94c4783aacce (patch) | |
| tree | b1eeb6c3e056e9d13352759935b4c53f5520a33c | |
| parent | eae2c85eec693a0ffed2fa5f3edf43f3d4ac2845 (diff) | |
| download | emacs-b4b6bda21c250f60a3ec93a2d94d94c4783aacce.tar.gz 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.
| -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." | |||
| 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 |