From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: patch for Dired second header line info Date: Sun, 2 Mar 2008 10:56:36 -0800 Message-ID: <003001c87c97$24a81400$0600a8c0@us.oracle.com> References: <000101c87b38$1dcd2db0$0600a8c0@us.oracle.com><87fxv9zxqv.fsf@jurta.org><000f01c87c3c$22f7db50$0600a8c0@us.oracle.com><87y791mess.fsf@jurta.org><002801c87c82$539474d0$0600a8c0@us.oracle.com><002901c87c8d$c299c730$0600a8c0@us.oracle.com> <87zlth7zwh.fsf@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0031_01C87C54.1684D400" X-Trace: ger.gmane.org 1204484278 3056 80.91.229.12 (2 Mar 2008 18:57:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Mar 2008 18:57:58 +0000 (UTC) Cc: emacs-devel@gnu.org To: "'Juri Linkov'" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 02 19:58:25 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JVtOB-0005iq-Ar for ged-emacs-devel@m.gmane.org; Sun, 02 Mar 2008 19:58:23 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JVtNe-0005A9-Fg for ged-emacs-devel@m.gmane.org; Sun, 02 Mar 2008 13:57:50 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JVtNa-00059r-A0 for emacs-devel@gnu.org; Sun, 02 Mar 2008 13:57:46 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JVtNY-00059e-3F for emacs-devel@gnu.org; Sun, 02 Mar 2008 13:57:45 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JVtNX-00059b-Tg for emacs-devel@gnu.org; Sun, 02 Mar 2008 13:57:43 -0500 Original-Received: from rgminet01.oracle.com ([148.87.113.118]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JVtNX-0001Le-Fl for emacs-devel@gnu.org; Sun, 02 Mar 2008 13:57:43 -0500 Original-Received: from rgmgw2.us.oracle.com (rgmgw2.us.oracle.com [138.1.186.111]) by rgminet01.oracle.com (Switch-3.2.4/Switch-3.1.6) with ESMTP id m22IveHV004347; Sun, 2 Mar 2008 11:57:41 -0700 Original-Received: from acsmt351.oracle.com (acsmt351.oracle.com [141.146.40.151]) by rgmgw2.us.oracle.com (Switch-3.2.4/Switch-3.2.4) with ESMTP id m22IfRGS021744; Sun, 2 Mar 2008 11:57:40 -0700 Original-Received: from inet-141-146-46-1.oracle.com by acsmt350.oracle.com with ESMTP id 3596861221204484192; Sun, 02 Mar 2008 10:56:32 -0800 Original-Received: from dradamslap1 (/141.144.64.82) by bhmail.oracle.com (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 02 Mar 2008 10:56:31 -0800 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <87zlth7zwh.fsf@jurta.org> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 Thread-Index: Ach8kyoxSjVIy1hwQAes+KBMWOXW9QAAeEEA X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:91088 Archived-At: This is a multi-part message in MIME format. ------=_NextPart_000_0031_01C87C54.1684D400 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit > > Attached: patch for this. The text is now: > > > > files 420/694 space used 19646 available 56456000 > > The string `total' is the standard string printed by `ls' so maybe we > should keep it. Also what do you think about further compacting > this line as: > > total files 420/694 space 19646/56456000 I already said that I find "total" unclear and I prefer the form I proposed. > or using the same function in `size-indication-mode' that displays the > size in the mode line in human-readable format: > > total files 420/694 space 19KB/56MB That might be OK, but what's wrong with giving a more precise number? That's typically what is given for this kind of thing. > Also we could add a tooltip explaining what these numbers mean if they > are not obvious. > > > Meaning: 420 files shown now, out of 694 total in the > directory. Subdirs are > > treated the same way. Great minds think alike. I was already doing that - new patch attached. (Also fixed a bug introduced in last patch.) (The text should say nothing about subdirs, BTW - each subdir has its own tooltip.) > In your patch maybe better to move dired functionality to dired.el or > dired-aux.el and rename `count-dired-files' to `dired-count-files'. I'll leave that to others to decide. My proposal just leaves things where they are now. ------=_NextPart_000_0031_01C87C54.1684D400 Content-Type: application/octet-stream; name="files-2008-03-02b.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="files-2008-03-02b.patch" diff -c -w files-CVS-2008-02-29.el files-patched-2008-03-02b.el=0A= *** files-CVS-2008-02-29.el Fri Feb 29 14:59:08 2008=0A= --- files-patched-2008-03-02b.el Sun Mar 2 10:49:54 2008=0A= ***************=0A= *** 5284,5302 ****=0A= (if val=0A= (put-text-property pos (point)=0A= 'dired-filename t)))))))=0A= ! =0A= ! (if full-directory-p=0A= ! ;; Try to insert the amount of free space.=0A= (save-excursion=0A= (goto-char beg)=0A= ! ;; First find the line to put it on.=0A= ! (when (re-search-forward "^ *\\(total\\)" nil t)=0A= ! (let ((available (get-free-disk-space ".")))=0A= (when available=0A= - ;; Replace "total" with "used", to avoid confusion.=0A= - (replace-match "total used in directory" nil nil nil 1)=0A= (end-of-line)=0A= ! (insert " available " available)))))))))))=0A= =0A= (defun insert-directory-adj-pos (pos error-lines)=0A= "Convert `ls --dired' file name position value POS to a buffer = position.=0A= --- 5284,5342 ----=0A= (if val=0A= (put-text-property pos (point)=0A= 'dired-filename t)))))))=0A= ! (when full-directory-p=0A= (save-excursion=0A= (goto-char beg)=0A= ! (while (re-search-forward "^ *\\(total\\)" nil t)=0A= ! (beginning-of-line)=0A= ! (insert "files " (number-to-string (save-match-data=0A= ! = (count-dired-files)))=0A= ! "/" (number-to-string=0A= ! (- (length (directory-files = default-directory=0A= ! nil nil t)) = 2))=0A= ! " ")=0A= ! (goto-char beg)=0A= ! (re-search-forward "^files [0-9]+/[0-9]+ \\(total\\)" = nil t)=0A= ! (replace-match "space used" nil nil nil 1)=0A= ! (let ((available (and (fboundp 'get-free-disk-space)=0A= ! (get-free-disk-space "."))))=0A= (when available=0A= (end-of-line)=0A= ! (insert " available " available)))=0A= ! (put-text-property (progn (beginning-of-line) (point))=0A= ! (progn (end-of-line) (point))=0A= ! 'help-echo "Files shown, total = files in \=0A= ! dir, Kbytes used in dir, Kbytes available on disk")))))))))=0A= ! =0A= ! (defun count-dired-files ()=0A= ! "Returns the number of files in the current Dired directory listing.=0A= ! This includes directory entries, as well as files, but it excludes `.'=0A= ! and `..'."=0A= ! ;; Should we skip `#' files also, as in `dired-trivial-filenames'? = Dunno.=0A= ! (save-excursion=0A= ! (re-search-backward "^$" nil 'to-bob)=0A= ! (re-search-forward dired-move-to-filename-regexp nil t)=0A= ! (let* ((beg (line-beginning-position))=0A= ! (end (save-excursion (re-search-forward "^$" nil t)))=0A= ! (dots-p (save-excursion ; Is `..' present?=0A= ! (goto-char beg)=0A= ! (re-search-forward=0A= ! (concat directory-listing-before-filename-regexp=0A= ! "\\.\\./?$")=0A= ! end t))))=0A= ! (if dots-p (- (count-lines beg end) 2) (count-lines beg end)))))=0A= ! =0A= ! (add-hook 'dired-after-readin-hook 'update-dired-files-count)=0A= ! (defun update-dired-files-count ()=0A= ! "Update file count in Dired header for each directory listed."=0A= ! (let ((num-files (number-to-string (count-dired-files))))=0A= ! (save-excursion=0A= ! (goto-char (point-min))=0A= ! (while (re-search-forward "^ files \\([0-9]+\\)" nil t)=0A= ! (let ((buffer-read-only nil))=0A= ! (replace-match (number-to-string (save-match-data = (count-dired-files)))=0A= ! nil nil nil 1))=0A= ! (set-buffer-modified-p nil)))))=0A= =0A= (defun insert-directory-adj-pos (pos error-lines)=0A= "Convert `ls --dired' file name position value POS to a buffer = position.=0A= =0A= Diff finished. Sun Mar 02 10:53:36 2008=0A= ------=_NextPart_000_0031_01C87C54.1684D400 Content-Type: application/octet-stream; name="ls-lisp-2008-03-02b.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ls-lisp-2008-03-02b.patch" diff -c -w ls-lisp-CVS-2008-02-29.el ls-lisp-patched-2008-03-02b.el=0A= *** ls-lisp-CVS-2008-02-29.el Fri Feb 29 14:58:50 2008=0A= --- ls-lisp-patched-2008-03-02b.el Sun Mar 2 10:51:18 2008=0A= ***************=0A= *** 260,276 ****=0A= file switches (ls-lisp-time-index switches)=0A= nil full-directory-p))=0A= (signal (car err) (cdr err)))))=0A= - ;; Try to insert the amount of free space.=0A= (save-excursion=0A= (goto-char (point-min))=0A= ! ;; First find the line to put it on.=0A= ! (when (re-search-forward "^total" nil t)=0A= ! (let ((available (get-free-disk-space ".")))=0A= (when available=0A= - ;; Replace "total" with "total used", to avoid confusion.=0A= - (replace-match "total used in directory")=0A= (end-of-line)=0A= ! (insert " available " available)))))))))=0A= =0A= (defun ls-lisp-insert-directory=0A= (file switches time-index wildcard-regexp full-directory-p)=0A= --- 260,287 ----=0A= file switches (ls-lisp-time-index switches)=0A= nil full-directory-p))=0A= (signal (car err) (cdr err)))))=0A= (save-excursion=0A= (goto-char (point-min))=0A= ! (while (re-search-forward "^total" nil t)=0A= ! (beginning-of-line)=0A= ! (insert "files " (number-to-string (save-match-data=0A= ! (count-dired-files)))=0A= ! "/" (number-to-string=0A= ! (- (length (directory-files default-directory=0A= ! nil nil t)) 2))=0A= ! " ")=0A= ! (goto-char (point-min))=0A= ! (re-search-forward "^files [0-9]+/[0-9]+ \\(total\\)" nil = t)=0A= ! (replace-match "space used" nil nil nil 1)=0A= ! (let ((available (and (fboundp 'get-free-disk-space)=0A= ! (get-free-disk-space "."))))=0A= (when available=0A= (end-of-line)=0A= ! (insert " available " available)))=0A= ! (put-text-property (progn (beginning-of-line) (point))=0A= ! (progn (end-of-line) (point))=0A= ! 'help-echo "Files shown, total files in = \=0A= ! dir, Kbytes used in dir, Kbytes available on disk")))))))=0A= =0A= (defun ls-lisp-insert-directory=0A= (file switches time-index wildcard-regexp full-directory-p)=0A= =0A= Diff finished. Sun Mar 02 10:51:42 2008=0A= ------=_NextPart_000_0031_01C87C54.1684D400--