all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jari Aalto <jari.aalto@cante.net>
To: bug-gnu-emacs@gnu.org
Subject: [PATCH] Emacs CVS: find-file.el - Line up all columns in output
Date: Mon, 08 Oct 2007 01:16:08 +0300	[thread overview]
Message-ID: <ve9iefkn.fsf@blue.sea.net> (raw)


Patch against CVS 2007-10-07 22:15 UTC

Current output of M-x find-file:

  -rw-r--r-- 1 root None 123166 Sep 30 00:23 dir/test.tst
  -rw-r--r-- 1 root None 18 Oct  7 17:49 tmp/1

After the "line up" fix, where the size columns are placed evenly
to make the rest of the line, namely the file names, line up.

  -rw-r--r-- 1 root None 123166 Sep 30 00:23 dir/test.tst
  -rw-r--r-- 1 root None  18 Oct  7 17:49 tmp/1

2007-10-08  Jari Aalto  <jari.aalto AT cante.net>

        * find-dired.el (find-dired-filter): Make output line up by
        adjusting the position of file sizes at column 5.

diff --git a/find-dired.el b/find-dired.el
index 0a3de85..79b0c13 100644
--- a/find-dired.el
+++ b/find-dired.el
@@ -232,7 +232,12 @@ 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 (concat
+                      "^ *[^ \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)
@@ -246,6 +251,7 @@ Thus ARG can also contain additional grep options."
 		(goto-char end)
 		(or (looking-at "^")
 		    (forward-line 1))
+                (goto-char (line-beginning-position))
 		(while (looking-at "^")
 		  (insert "  ")
 		  (forward-line 1))
@@ -255,6 +261,19 @@ 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 adjusting the file size at column 5
+                ;; -rw-r----x 1 foo foo 2425 Dec  5  2005 file.txt
+                ;; -rw-r----x 1 foo foo   25 Dec  5  2005 test.tmp
+                (if l-opt
+                    (progn
+                      (goto-char (- end 3))
+                      (if (re-search-forward size-regexp nil t)
+                          (replace-match
+                           (format "%6s" (match-string 1))
+                           (not 'fixcase)
+                           (not 'literal)
+                           (not 'string)
+                           1))))
 		;; Find all the complete lines in the unprocessed
 		;; output and process it to add text properties.
 		(goto-char (point-max))




             reply	other threads:[~2007-10-07 22:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-07 22:16 Jari Aalto [this message]
2007-10-09  1:14 ` [PATCH] Emacs CVS: find-file.el - Line up all columns in output Richard Stallman
2007-10-09  8:51   ` Jari Aalto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ve9iefkn.fsf@blue.sea.net \
    --to=jari.aalto@cante.net \
    --cc=bug-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.