From: Jari Aalto <jari.aalto@cante.net>
To: rms@gnu.org
Cc: bug-gnu-emacs@gnu.org
Subject: Re: [PATCH] Emacs CVS: find-file.el - Line up all columns in output
Date: Tue, 09 Oct 2007 11:51:39 +0300 [thread overview]
Message-ID: <d4voekmc.fsf@blue.sea.net> (raw)
In-Reply-To: <E1If3gJ-0003mv-ML@fencepost.gnu.org> (Richard Stallman's message of "Mon, 08 Oct 2007 21:14:43 -0400")
* Mon 2007-10-08 Richard Stallman <rms AT gnu.org> INBOX
> I don't think this change fully does the job, because file sizes
> can be more than 6 digits.
I increased the size to 10 digits, which accomodates up to 9G. The
format is now also user configurable.
Jari
etc/ChangeLog
2007-10-09 Jari Aalto <jari.aalto AT cante.net>
* NEWS: Document new variable `find-dired-file-size-format'
diff --git a/NEWS b/NEWS
index b2e185b..3951639 100644
--- a/NEWS
+++ b/NEWS
@@ -238,6 +238,9 @@ saving changes.
*** The new command `eshell/info' runs info in an eshell buffer.
+*** The new variable `find-dired-file-size-format' controls the placement
+of file sizes in command `find-dired'.
+
\f
* Changes in Emacs 23.1 on non-free operating systems
lisp/Changelog
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.
(find-dired-file-size-format): New customizable variable.
diff --git a/find-dired.el b/find-dired.el
index 0a3de85..0c0c031 100644
--- a/find-dired.el
+++ b/find-dired.el
@@ -77,6 +77,9 @@ On other systems, the closest you can come is to use `-l'."
:type 'string
:group 'find-dired)
+(defcustom find-dired-file-size-format "%10s" ;; Up to 1-9G file size
+ "*Format spec of `find-dired' listing for file sizes.")
+
(defvar find-args nil
"Last arguments given to `find' by \\[find-dired].")
@@ -232,7 +235,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)
@@ -255,6 +263,20 @@ 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 find-dired-file-size-format
+ (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))
prev parent reply other threads:[~2007-10-09 8:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-07 22:16 [PATCH] Emacs CVS: find-file.el - Line up all columns in output Jari Aalto
2007-10-09 1:14 ` Richard Stallman
2007-10-09 8:51 ` Jari Aalto [this message]
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d4voekmc.fsf@blue.sea.net \
--to=jari.aalto@cante.net \
--cc=bug-gnu-emacs@gnu.org \
--cc=rms@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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).