Mercurial > emacs
comparison lisp/find-dired.el @ 89909:68c22ea6027c
Sync to HEAD
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 16 Apr 2004 12:51:06 +0000 |
parents | 375f2633d815 |
children | 4c90ffeb71c5 |
comparison
equal
deleted
inserted
replaced
89908:ee1402f7b568 | 89909:68c22ea6027c |
---|---|
119 args (concat find-dired-find-program " . " | 119 args (concat find-dired-find-program " . " |
120 (if (string= args "") | 120 (if (string= args "") |
121 "" | 121 "" |
122 (concat "\\( " args " \\) ")) | 122 (concat "\\( " args " \\) ")) |
123 (car find-ls-option))) | 123 (car find-ls-option))) |
124 ;; Start the find process. | |
125 (shell-command (concat args "&") (current-buffer)) | |
124 ;; The next statement will bomb in classic dired (no optional arg allowed) | 126 ;; The next statement will bomb in classic dired (no optional arg allowed) |
125 (dired-mode dir (cdr find-ls-option)) | 127 (dired-mode dir (cdr find-ls-option)) |
128 (let ((map (make-sparse-keymap))) | |
129 (set-keymap-parent map (current-local-map)) | |
130 (define-key map "\C-c\C-k" 'kill-find) | |
131 (use-local-map map)) | |
126 (make-local-variable 'dired-sort-inhibit) | 132 (make-local-variable 'dired-sort-inhibit) |
127 (setq dired-sort-inhibit t) | 133 (setq dired-sort-inhibit t) |
128 (set (make-local-variable 'revert-buffer-function) | 134 (set (make-local-variable 'revert-buffer-function) |
129 `(lambda (ignore-auto noconfirm) | 135 `(lambda (ignore-auto noconfirm) |
130 (find-dired ,dir ,find-args))) | 136 (find-dired ,dir ,find-args))) |
142 ;; subdir-alist points there. | 148 ;; subdir-alist points there. |
143 (insert " " dir ":\n") | 149 (insert " " dir ":\n") |
144 ;; Make second line a ``find'' line in analogy to the ``total'' or | 150 ;; Make second line a ``find'' line in analogy to the ``total'' or |
145 ;; ``wildcard'' line. | 151 ;; ``wildcard'' line. |
146 (insert " " args "\n") | 152 (insert " " args "\n") |
147 ;; Start the find process. | 153 (setq buffer-read-only t) |
148 (let ((proc (start-process-shell-command find-dired-find-program (current-buffer) args))) | 154 (let ((proc (get-buffer-process (current-buffer)))) |
149 (set-process-filter proc (function find-dired-filter)) | 155 (set-process-filter proc (function find-dired-filter)) |
150 (set-process-sentinel proc (function find-dired-sentinel)) | 156 (set-process-sentinel proc (function find-dired-sentinel)) |
151 ;; Initialize the process marker; it is used by the filter. | 157 ;; Initialize the process marker; it is used by the filter. |
152 (move-marker (process-mark proc) 1 (current-buffer))) | 158 (move-marker (process-mark proc) 1 (current-buffer))) |
153 (setq mode-line-process '(":%s")))) | 159 (setq mode-line-process '(":%s")))) |
160 | |
161 (defun kill-find () | |
162 "Kill the `find' process running in the current buffer." | |
163 (interactive) | |
164 (let ((find (get-buffer-process (current-buffer)))) | |
165 (and find (eq (process-status find) 'run) | |
166 (eq (process-filter find) (function find-dired-filter)) | |
167 (condition-case nil | |
168 (delete-process find) | |
169 (error nil))))) | |
154 | 170 |
155 ;;;###autoload | 171 ;;;###autoload |
156 (defun find-name-dired (dir pattern) | 172 (defun find-name-dired (dir pattern) |
157 "Search DIR recursively for files matching the globbing pattern PATTERN, | 173 "Search DIR recursively for files matching the globbing pattern PATTERN, |
158 and run dired on those files. | 174 and run dired on those files. |
190 (shell-quote-argument regexp) | 206 (shell-quote-argument regexp) |
191 " {} \\\; "))) | 207 " {} \\\; "))) |
192 | 208 |
193 (defun find-dired-filter (proc string) | 209 (defun find-dired-filter (proc string) |
194 ;; Filter for \\[find-dired] processes. | 210 ;; Filter for \\[find-dired] processes. |
195 (let ((buf (process-buffer proc))) | 211 (let ((buf (process-buffer proc)) |
212 (inhibit-read-only t)) | |
196 (if (buffer-name buf) ; not killed? | 213 (if (buffer-name buf) ; not killed? |
197 (save-excursion | 214 (save-excursion |
198 (set-buffer buf) | 215 (set-buffer buf) |
199 (save-restriction | 216 (save-restriction |
200 (widen) | 217 (widen) |
227 ;; The buffer has been killed. | 244 ;; The buffer has been killed. |
228 (delete-process proc)))) | 245 (delete-process proc)))) |
229 | 246 |
230 (defun find-dired-sentinel (proc state) | 247 (defun find-dired-sentinel (proc state) |
231 ;; Sentinel for \\[find-dired] processes. | 248 ;; Sentinel for \\[find-dired] processes. |
232 (let ((buf (process-buffer proc))) | 249 (let ((buf (process-buffer proc)) |
250 (inhibit-read-only t)) | |
233 (if (buffer-name buf) | 251 (if (buffer-name buf) |
234 (save-excursion | 252 (save-excursion |
235 (set-buffer buf) | 253 (set-buffer buf) |
236 (let ((buffer-read-only nil)) | 254 (let ((buffer-read-only nil)) |
237 (save-excursion | 255 (save-excursion |
250 (force-mode-line-update))) | 268 (force-mode-line-update))) |
251 (message "find-dired %s finished." (current-buffer)))))) | 269 (message "find-dired %s finished." (current-buffer)))))) |
252 | 270 |
253 (provide 'find-dired) | 271 (provide 'find-dired) |
254 | 272 |
273 ;;; arch-tag: 8edece95-af00-4221-bc74-a4bd2f75f9b0 | |
255 ;;; find-dired.el ends here | 274 ;;; find-dired.el ends here |