diff options
| author | Richard M. Stallman | 1998-06-27 21:59:11 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-06-27 21:59:11 +0000 |
| commit | 0322a154b764f8358ba8913dc6fc724ba9f4294d (patch) | |
| tree | c6e7d0e5782435da9af939ab1b748d24f3ef5dc4 | |
| parent | 3bf0b7276812c60315ba5ddf99dcb12d72078266 (diff) | |
| download | emacs-0322a154b764f8358ba8913dc6fc724ba9f4294d.tar.gz emacs-0322a154b764f8358ba8913dc6fc724ba9f4294d.zip | |
(find-dired): Bind dired-buffers so it can't change. Use abbreviate-file-name.
| -rw-r--r-- | lisp/find-dired.el | 98 |
1 files changed, 50 insertions, 48 deletions
diff --git a/lisp/find-dired.el b/lisp/find-dired.el index 43246c096aa..2bd9451f5d5 100644 --- a/lisp/find-dired.el +++ b/lisp/find-dired.el | |||
| @@ -67,7 +67,7 @@ On other systems, the closest you can come is to use `-l'." | |||
| 67 | 67 | ||
| 68 | ;;;###autoload | 68 | ;;;###autoload |
| 69 | (defun find-dired (dir args) | 69 | (defun find-dired (dir args) |
| 70 | "Run `find' and go into dired-mode on a buffer of the output. | 70 | "Run `find' and go into Dired mode on a buffer of the output. |
| 71 | The command run (after changing into DIR) is | 71 | The command run (after changing into DIR) is |
| 72 | 72 | ||
| 73 | find . \\( ARGS \\) -ls | 73 | find . \\( ARGS \\) -ls |
| @@ -77,53 +77,55 @@ as the final argument." | |||
| 77 | (interactive (list (read-file-name "Run find in directory: " nil "" t) | 77 | (interactive (list (read-file-name "Run find in directory: " nil "" t) |
| 78 | (read-string "Run find (with args): " find-args | 78 | (read-string "Run find (with args): " find-args |
| 79 | '(find-args-history . 1)))) | 79 | '(find-args-history . 1)))) |
| 80 | ;; Expand DIR ("" means default-directory), and make sure it has a | 80 | (let ((dired-buffers dired-buffers)) |
| 81 | ;; trailing slash. | 81 | ;; Expand DIR ("" means default-directory), and make sure it has a |
| 82 | (setq dir (file-name-as-directory (expand-file-name dir))) | 82 | ;; trailing slash. |
| 83 | ;; Check that it's really a directory. | 83 | (setq dir (abbreviate-file-name |
| 84 | (or (file-directory-p dir) | 84 | (file-name-as-directory (expand-file-name dir)))) |
| 85 | (error "find-dired needs a directory: %s" dir)) | 85 | ;; Check that it's really a directory. |
| 86 | (switch-to-buffer (get-buffer-create "*Find*")) | 86 | (or (file-directory-p dir) |
| 87 | (widen) | 87 | (error "find-dired needs a directory: %s" dir)) |
| 88 | (kill-all-local-variables) | 88 | (switch-to-buffer (get-buffer-create "*Find*")) |
| 89 | (setq buffer-read-only nil) | 89 | (widen) |
| 90 | (erase-buffer) | 90 | (kill-all-local-variables) |
| 91 | (setq default-directory dir | 91 | (setq buffer-read-only nil) |
| 92 | find-args args ; save for next interactive call | 92 | (erase-buffer) |
| 93 | args (concat "find . " | 93 | (setq default-directory dir |
| 94 | (if (string= args "") | 94 | find-args args ; save for next interactive call |
| 95 | "" | 95 | args (concat "find . " |
| 96 | (concat "\\( " args " \\) ")) | 96 | (if (string= args "") |
| 97 | (car find-ls-option))) | 97 | "" |
| 98 | ;; The next statement will bomb in classic dired (no optional arg allowed) | 98 | (concat "\\( " args " \\) ")) |
| 99 | (dired-mode dir (cdr find-ls-option)) | 99 | (car find-ls-option))) |
| 100 | ;; This really should rerun the find command, but I don't | 100 | ;; The next statement will bomb in classic dired (no optional arg allowed) |
| 101 | ;; have time for that. | 101 | (dired-mode dir (cdr find-ls-option)) |
| 102 | (use-local-map (append (make-sparse-keymap) (current-local-map))) | 102 | ;; This really should rerun the find command, but I don't |
| 103 | (define-key (current-local-map) "g" 'undefined) | 103 | ;; have time for that. |
| 104 | ;; Set subdir-alist so that Tree Dired will work: | 104 | (use-local-map (append (make-sparse-keymap) (current-local-map))) |
| 105 | (if (fboundp 'dired-simple-subdir-alist) | 105 | (define-key (current-local-map) "g" 'undefined) |
| 106 | ;; will work even with nested dired format (dired-nstd.el,v 1.15 | 106 | ;; Set subdir-alist so that Tree Dired will work: |
| 107 | ;; and later) | 107 | (if (fboundp 'dired-simple-subdir-alist) |
| 108 | (dired-simple-subdir-alist) | 108 | ;; will work even with nested dired format (dired-nstd.el,v 1.15 |
| 109 | ;; else we have an ancient tree dired (or classic dired, where | 109 | ;; and later) |
| 110 | ;; this does no harm) | 110 | (dired-simple-subdir-alist) |
| 111 | (set (make-local-variable 'dired-subdir-alist) | 111 | ;; else we have an ancient tree dired (or classic dired, where |
| 112 | (list (cons default-directory (point-min-marker))))) | 112 | ;; this does no harm) |
| 113 | (setq buffer-read-only nil) | 113 | (set (make-local-variable 'dired-subdir-alist) |
| 114 | ;; Subdir headlerline must come first because the first marker in | 114 | (list (cons default-directory (point-min-marker))))) |
| 115 | ;; subdir-alist points there. | 115 | (setq buffer-read-only nil) |
| 116 | (insert " " dir ":\n") | 116 | ;; Subdir headlerline must come first because the first marker in |
| 117 | ;; Make second line a ``find'' line in analogy to the ``total'' or | 117 | ;; subdir-alist points there. |
| 118 | ;; ``wildcard'' line. | 118 | (insert " " dir ":\n") |
| 119 | (insert " " args "\n") | 119 | ;; Make second line a ``find'' line in analogy to the ``total'' or |
| 120 | ;; Start the find process. | 120 | ;; ``wildcard'' line. |
| 121 | (let ((proc (start-process-shell-command "find" (current-buffer) args))) | 121 | (insert " " args "\n") |
| 122 | (set-process-filter proc (function find-dired-filter)) | 122 | ;; Start the find process. |
| 123 | (set-process-sentinel proc (function find-dired-sentinel)) | 123 | (let ((proc (start-process-shell-command "find" (current-buffer) args))) |
| 124 | ;; Initialize the process marker; it is used by the filter. | 124 | (set-process-filter proc (function find-dired-filter)) |
| 125 | (move-marker (process-mark proc) 1 (current-buffer))) | 125 | (set-process-sentinel proc (function find-dired-sentinel)) |
| 126 | (setq mode-line-process '(":%s"))) | 126 | ;; Initialize the process marker; it is used by the filter. |
| 127 | (move-marker (process-mark proc) 1 (current-buffer))) | ||
| 128 | (setq mode-line-process '(":%s")))) | ||
| 127 | 129 | ||
| 128 | ;;;###autoload | 130 | ;;;###autoload |
| 129 | (defun find-name-dired (dir pattern) | 131 | (defun find-name-dired (dir pattern) |