aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2008-04-01 17:28:26 +0000
committerChong Yidong2008-04-01 17:28:26 +0000
commit8203444546dd77da11a67c8aa1590801d20dc8f5 (patch)
tree5b73fe1c972f43b568df40b03df667eb74f37087
parent43ef4163b38c89cbd9129de84db0c28fc72baeae (diff)
downloademacs-8203444546dd77da11a67c8aa1590801d20dc8f5.tar.gz
emacs-8203444546dd77da11a67c8aa1590801d20dc8f5.zip
(find-dired-filter): Fix last patch to handle multi-line process
input. Pad link numbers too.
-rw-r--r--lisp/find-dired.el85
1 files changed, 47 insertions, 38 deletions
diff --git a/lisp/find-dired.el b/lisp/find-dired.el
index 7d35451b6e3..87676fe71bc 100644
--- a/lisp/find-dired.el
+++ b/lisp/find-dired.el
@@ -239,47 +239,56 @@ Thus ARG can also contain additional grep options."
239(defun find-dired-filter (proc string) 239(defun find-dired-filter (proc string)
240 ;; Filter for \\[find-dired] processes. 240 ;; Filter for \\[find-dired] processes.
241 (let ((buf (process-buffer proc)) 241 (let ((buf (process-buffer proc))
242 (inhibit-read-only t) 242 (inhibit-read-only t))
243 (l-opt (and (consp find-ls-option) 243 (if (buffer-name buf)
244 (string-match "l" (cdr find-ls-option)))) 244 (with-current-buffer buf
245 (size-regexp
246 "^ +[^ \t\r\n]+ +[^ \t\r\n]+ +[^ \t\r\n]+ +[^ \t\r\n]+ +\\([0-9]+\\)"))
247 (if (buffer-name buf) ; not killed?
248 (save-excursion
249 (set-buffer buf)
250 (save-restriction 245 (save-restriction
251 (widen) 246 (widen)
252 (save-excursion 247 (let ((buffer-read-only nil)
253 (let ((buffer-read-only nil) 248 (beg (point-max))
254 (end (point-max))) 249 (l-opt (and (consp find-ls-option)
255 (goto-char end) 250 (string-match "l" (cdr find-ls-option))))
256 (insert string) 251 (links-regexp "^ +[^ \t\r\n]+\\( +[^ \t\r\n]+\\)")
257 (goto-char end) 252 (size-regexp
258 (or (looking-at "^") 253 "^ +[^ \t\r\n]+ +[^ \t\r\n]+ +[^ \t\r\n]+ +[^ \t\r\n]+\\( +[0-9]+\\)"))
259 (forward-line 1)) 254 (goto-char beg)
260 (while (looking-at "^") 255 (insert string)
261 (insert " ") 256 (goto-char beg)
257 (or (looking-at "^")
258 (forward-line 1))
259 (while (looking-at "^")
260 (insert " ")
261 (forward-line 1))
262 ;; Convert ` ./FILE' to ` FILE'
263 ;; This would lose if the current chunk of output
264 ;; starts or ends within the ` ./', so back up a bit:
265 (goto-char (- beg 3)) ; no error if < 0
266 (while (search-forward " ./" nil t)
267 (delete-region (point) (- (point) 2)))
268 ;; Pad the number of links and file size. This is a
269 ;; quick and dirty way of getting the columns to line up
270 ;; most of the time, but it's not foolproof.
271 (when l-opt
272 (goto-char beg)
273 (goto-char (line-beginning-position))
274 (while (re-search-forward links-regexp nil t)
275 (replace-match (format "%4s" (match-string 1))
276 nil nil nil 1)
262 (forward-line 1)) 277 (forward-line 1))
263 ;; Convert ` ./FILE' to ` FILE' 278 (goto-char beg)
264 ;; This would lose if the current chunk of output 279 (goto-char (line-beginning-position))
265 ;; starts or ends within the ` ./', so back up a bit: 280 (while (re-search-forward size-regexp nil t)
266 (goto-char (- end 3)) ; no error if < 0 281 (replace-match (format "%9s" (match-string 1))
267 (while (search-forward " ./" nil t) 282 nil nil nil 1)
268 (delete-region (point) (- (point) 2))) 283 (forward-line 1)))
269 ;; Make output line up by padding the file size 284 ;; Find all the complete lines in the unprocessed
270 (when l-opt 285 ;; output and process it to add text properties.
271 (goto-char (- end 3)) 286 (goto-char (point-max))
272 (when (re-search-forward size-regexp nil t) 287 (if (search-backward "\n" (process-mark proc) t)
273 (replace-match (format "%10s" (match-string 1)) 288 (progn
274 nil nil nil 1))) 289 (dired-insert-set-properties (process-mark proc)
275 ;; Find all the complete lines in the unprocessed 290 (1+ (point)))
276 ;; output and process it to add text properties. 291 (move-marker (process-mark proc) (1+ (point))))))))
277 (goto-char (point-max))
278 (if (search-backward "\n" (process-mark proc) t)
279 (progn
280 (dired-insert-set-properties (process-mark proc)
281 (1+ (point)))
282 (move-marker (process-mark proc) (1+ (point)))))))))
283 ;; The buffer has been killed. 292 ;; The buffer has been killed.
284 (delete-process proc)))) 293 (delete-process proc))))
285 294