From 1ed7b67b0c5b4303419e37e85ae562efb53e3b27 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Tue, 1 Apr 2008 16:48:24 +0000 Subject: [PATCH] (find-dired-filter): Align columns by padding file sizes. --- lisp/find-dired.el | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lisp/find-dired.el b/lisp/find-dired.el index e49e1f304be..7d35451b6e3 100644 --- a/lisp/find-dired.el +++ b/lisp/find-dired.el @@ -239,7 +239,11 @@ Thus ARG can also contain additional grep options." (defun find-dired-filter (proc string) ;; Filter for \\[find-dired] processes. (let ((buf (process-buffer proc)) - (inhibit-read-only t)) + (inhibit-read-only t) + (l-opt (and (consp find-ls-option) + (string-match "l" (cdr find-ls-option)))) + (size-regexp + "^ +[^ \t\r\n]+ +[^ \t\r\n]+ +[^ \t\r\n]+ +[^ \t\r\n]+ +\\([0-9]+\\)")) (if (buffer-name buf) ; not killed? (save-excursion (set-buffer buf) @@ -262,6 +266,12 @@ Thus ARG can also contain additional grep options." (goto-char (- end 3)) ; no error if < 0 (while (search-forward " ./" nil t) (delete-region (point) (- (point) 2))) + ;; Make output line up by padding the file size + (when l-opt + (goto-char (- end 3)) + (when (re-search-forward size-regexp nil t) + (replace-match (format "%10s" (match-string 1)) + nil nil nil 1))) ;; Find all the complete lines in the unprocessed ;; output and process it to add text properties. (goto-char (point-max)) @@ -269,8 +279,7 @@ Thus ARG can also contain additional grep options." (progn (dired-insert-set-properties (process-mark proc) (1+ (point))) - (move-marker (process-mark proc) (1+ (point))))) - )))) + (move-marker (process-mark proc) (1+ (point))))))))) ;; The buffer has been killed. (delete-process proc)))) -- 2.39.2