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: Tue, 4 Mar 2008 14:28:32 -0800 Message-ID: <003001c87e47$14f24a60$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><003a01c87d7e$00749210$c2b22382@us.oracle.com> <002801c87e30$243aea70$0600a8c0@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0031_01C87E04.06CF0A60" X-Trace: ger.gmane.org 1204669846 28147 80.91.229.12 (4 Mar 2008 22:30:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 4 Mar 2008 22:30:46 +0000 (UTC) Cc: juri@jurta.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 04 23:31:11 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 1JWff4-0000wi-1f for ged-emacs-devel@m.gmane.org; Tue, 04 Mar 2008 23:31:02 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JWfeW-0002VI-NJ for ged-emacs-devel@m.gmane.org; Tue, 04 Mar 2008 17:30:28 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JWfeS-0002VB-Ay for emacs-devel@gnu.org; Tue, 04 Mar 2008 17:30:24 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JWfeQ-0002Uy-PD for emacs-devel@gnu.org; Tue, 04 Mar 2008 17:30:23 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JWfeQ-0002Uv-KQ for emacs-devel@gnu.org; Tue, 04 Mar 2008 17:30:22 -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 1JWfeM-0004PW-GP; Tue, 04 Mar 2008 17:30:18 -0500 Original-Received: from agmgw2.us.oracle.com (agmgw2.us.oracle.com [152.68.180.213]) by rgminet01.oracle.com (Switch-3.2.4/Switch-3.1.6) with ESMTP id m24MUDSf023122; Tue, 4 Mar 2008 15:30:15 -0700 Original-Received: from acsmt350.oracle.com (acsmt350.oracle.com [141.146.40.150]) by agmgw2.us.oracle.com (Switch-3.2.0/Switch-3.2.0) with ESMTP id m241VKt4022371; Tue, 4 Mar 2008 15:30:10 -0700 Original-Received: from inet-141-146-46-1.oracle.com by acsmt350.oracle.com with ESMTP id 3599829721204669737; Tue, 04 Mar 2008 14:28:57 -0800 Original-Received: from dradamslap1 (/141.144.88.200) by bhmail.oracle.com (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 04 Mar 2008 14:28:56 -0800 X-Mailer: Microsoft Office Outlook 11 Thread-Index: Ach+HqMRqV7w9dGISxezdMoY0fy2vgADvd+AAAWl30A= In-Reply-To: <002801c87e30$243aea70$0600a8c0@us.oracle.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 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:91325 Archived-At: This is a multi-part message in MIME format. ------=_NextPart_000_0031_01C87E04.06CF0A60 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit > > The tooltip also helps: > > > > "Files shown, total files in dir, Kbytes used in dir, > > Kbytes available on disk [RET, mouse-2: more info]" > > > > Each number should have its own tooltip which explains that number > > and not the others. > > Sorry; I don't agree. The meanings of the numbers are related > (similar), at > least in pairs. Four separate tooltips would be more an > annoyance than a > help, because the similarities and differences can't be > grasped without a > silly back-and-forth: > > 420: Number of files and subdirectories currently shown in directory > > 694: Number of files and subdirectories in directory, > including hidden ones > > 19646: Kbytes used in directory > > 56456000: Kbytes available (free) on disk > > To understand 420 or 694, for instance, you would need to go > back and forth between their tooltips, trying to remember what the > non-displayed tooltip said while reading the displayed one, and > comparing them mentally, in order to grasp the difference. > > Two tooltips, for the two pairs, might be reasonable, however. > > In any case, change it however you like. 1. OK, attached is a patch that does what I suggested (two tooltips, not 1 or 4). 2. The patch also fixes the problem of not updating when you perform update operations, such as add a file or directory. However, there remains a case where updating does not refresh the info line: file deletion. For some reason, `dired-after-readin-hook' is not run when you delete files. Is that perhaps a dired bug, or is it by design? `dired-internal-do-deletions' is called whether you flag a file and then use `x' or you mark it and then use `D'. Should `dired-internal-do-deletions' run the hook? HTH. ------=_NextPart_000_0031_01C87E04.06CF0A60 Content-Type: application/octet-stream; name="files-2008-03-04a.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="files-2008-03-04a.patch" diff -c -w "files-CVS-2008-02-29.el" "files-patched-2008-03-04a.el"=0A= *** files-CVS-2008-02-29.el Fri Feb 29 14:59:08 2008=0A= --- files-patched-2008-03-04a.el Tue Mar 4 14:04:36 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,5444 ----=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= ! (map (make-sparse-keymap)))=0A= ! (define-key map [mouse-2] = 'dired-mouse-describe-listed-directory)=0A= ! (define-key map "\r" = 'dired-describe-listed-directory)=0A= ! (when available (end-of-line) (insert " available " = available))=0A= ! (add-text-properties=0A= ! (save-excursion (beginning-of-line) (+ 2 (point)))=0A= ! (1- (match-beginning 1))=0A= ! `(mouse-face highlight keymap ,map=0A= ! help-echo "Files shown / total files in directory = \=0A= ! \[RET, mouse-2: more info]"))=0A= ! (add-text-properties=0A= ! (match-beginning 1) (save-excursion (end-of-line) = (point))=0A= ! `(mouse-face highlight keymap ,map=0A= ! help-echo "Kbytes used in directory, Kbytes \=0A= ! available on disk [RET, mouse-2: more info]")))))))))))=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= ! (save-restriction=0A= ! (widen)=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]+\\)/\\([0-9]+\\)" = nil t)=0A= ! (let ((buffer-read-only nil)=0A= ! (map (make-sparse-keymap)))=0A= ! (define-key map [mouse-2] = 'dired-mouse-describe-listed-directory)=0A= ! (define-key map "\r" 'dired-describe-listed-directory)=0A= ! (replace-match (number-to-string (save-match-data = (count-dired-files)))=0A= ! nil nil nil 1)=0A= ! (replace-match (number-to-string=0A= ! (- (length (directory-files = default-directory=0A= ! nil nil t)) 2))=0A= ! nil nil nil 2)=0A= ! (add-text-properties=0A= ! (save-excursion (beginning-of-line) (+ 2 (point))) = (match-end 2)=0A= ! `(mouse-face highlight keymap ,map=0A= ! help-echo "Files shown / total files in directory \=0A= ! \[RET, mouse-2: more info]")))=0A= ! (set-buffer-modified-p nil))))))=0A= ! =0A= ! (defun dired-describe-listed-directory ()=0A= ! "In Dired, describe the current listed directory."=0A= ! (interactive)=0A= ! (let ((dirname (save-excursion=0A= ! (forward-line -1)=0A= ! (skip-syntax-forward " ")=0A= ! (buffer-substring=0A= ! (point)=0A= ! (save-excursion (end-of-line) (1- (point))))))) ; = Up to colon.=0A= ! =0A= ! (describe-file dirname)))=0A= ! =0A= ! (defun dired-mouse-describe-listed-directory (event)=0A= ! "Describe the current listed directory."=0A= ! (interactive "e")=0A= ! (save-excursion=0A= ! (set-buffer (window-buffer (posn-window (event-end event))))=0A= ! (goto-char (posn-point (event-end event)))=0A= ! (dired-describe-listed-directory)))=0A= ! =0A= ! (defun dired-describe-file ()=0A= ! "In Dired, describe this file or directory."=0A= ! (interactive)=0A= ! (describe-file (dired-get-filename nil t)))=0A= ! =0A= ! (defun dired-mouse-describe-file (event)=0A= ! "Describe the clicked file."=0A= ! (interactive "e")=0A= ! (let (file)=0A= ! (save-excursion=0A= ! (set-buffer (window-buffer (posn-window (event-end event))))=0A= ! (goto-char (posn-point (event-end event)))=0A= ! (setq file (dired-get-filename nil t)))=0A= ! (describe-file file)))=0A= ! =0A= ! ;; This is the same definition as in `help-fns+.el' and `help+20.el'.=0A= ! (defun describe-file (filename)=0A= ! "Describe the file named FILENAME.=0A= ! If FILENAME is nil, describe the current directory."=0A= ! (interactive "FDescribe file: ")=0A= ! (unless filename (setq filename default-directory))=0A= ! (help-setup-xref (list #'describe-file filename) (interactive-p))=0A= ! (let ((attrs (file-attributes filename)))=0A= ! (unless attrs (error(format "Cannot open file `%s'" filename)))=0A= ! (let* ((type (nth 0 attrs))=0A= ! (numlinks (nth 1 attrs))=0A= ! (uid (nth 2 attrs))=0A= ! (gid (nth 3 attrs))=0A= ! (last-access (nth 4 attrs))=0A= ! (last-mod (nth 5 attrs))=0A= ! (last-status-chg (nth 6 attrs))=0A= ! (size (nth 7 attrs))=0A= ! (permissions (nth 8 attrs))=0A= ! ;; Skip 9: t iff file's gid would change if file were = deleted=0A= ! ;; and recreated.=0A= ! (inode (nth 10 attrs))=0A= ! (device (nth 11 attrs))=0A= ! (help-text=0A= ! (concat=0A= ! (format "Properties of `%s':\n\n" filename)=0A= ! (format "Type: %s\n"=0A= ! (cond ((eq t type) "Directory")=0A= ! ((stringp type) (format "Symbolic link to = `%s'" type))=0A= ! (t "Normal file")))=0A= ! (format "Permissions: %s\n" permissions)=0A= ! (and (not (eq t type)) (format "Size in bytes: = %g\n" size))=0A= ! (format-time-string=0A= ! "Time of last access: %a %b %e %T %Y (%Z)\n" = last-access)=0A= ! (format-time-string=0A= ! "Time of last modification: %a %b %e %T %Y (%Z)\n" = last-mod)=0A= ! (format-time-string=0A= ! "Time of last status change: %a %b %e %T %Y (%Z)\n" = last-status-chg)=0A= ! (format "Number of links: %d\n" numlinks)=0A= ! (format "User ID (UID): %s\n" uid)=0A= ! (format "Group ID (GID): %s\n" gid)=0A= ! (format "Inode: %S\n" inode)=0A= ! (format "Device number: %s\n" device))))=0A= ! (with-output-to-temp-buffer "*Help*" (princ help-text))=0A= ! help-text))) ; Return displayed text.=0A= =0A= (defun insert-directory-adj-pos (pos error-lines)=0A= "Convert `ls --dired' file name position value POS to a buffer = position.=0A= ------=_NextPart_000_0031_01C87E04.06CF0A60 Content-Type: application/octet-stream; name="ls-lisp-2008-03-04a.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ls-lisp-2008-03-04a.patch" diff -c -w "ls-lisp-CVS-2008-02-29.el" "ls-lisp-patched-2008-03-04a.el"=0A= *** ls-lisp-CVS-2008-02-29.el Fri Feb 29 14:58:50 2008=0A= --- ls-lisp-patched-2008-03-04a.el Tue Mar 4 14:03:20 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,298 ----=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= ! (map (make-sparse-keymap)))=0A= ! (define-key map [mouse-2]=0A= ! 'dired-mouse-describe-listed-directory)=0A= ! (define-key map "\r" 'dired-describe-listed-directory)=0A= ! (when available (end-of-line) (insert " available "=0A= ! available))=0A= ! (add-text-properties=0A= ! (save-excursion (beginning-of-line) (+ 2 (point)))=0A= ! (1- (match-beginning 1))=0A= ! `(mouse-face highlight keymap ,map=0A= ! help-echo "Files shown / total files in directory \=0A= ! \[RET, mouse-2: more info]"))=0A= ! (add-text-properties=0A= ! (match-beginning 1)=0A= ! (save-excursion (end-of-line) (point))=0A= ! `(mouse-face highlight keymap ,map=0A= ! help-echo "Kbytes used in directory, Kbytes \=0A= ! available on disk [RET, mouse-2: more info]")))))))))=0A= =0A= (defun ls-lisp-insert-directory=0A= (file switches time-index wildcard-regexp full-directory-p)=0A= ------=_NextPart_000_0031_01C87E04.06CF0A60--