all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: <rms@gnu.org>
Cc: juri@jurta.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: RE: patch for Dired second header line info
Date: Tue, 4 Mar 2008 14:28:32 -0800	[thread overview]
Message-ID: <003001c87e47$14f24a60$0600a8c0@us.oracle.com> (raw)
In-Reply-To: <002801c87e30$243aea70$0600a8c0@us.oracle.com>

[-- Attachment #1: Type: text/plain, Size: 1742 bytes --]

> >     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.

[-- Attachment #2: files-2008-03-04a.patch --]
[-- Type: application/octet-stream, Size: 9006 bytes --]

diff -c -w "files-CVS-2008-02-29.el" "files-patched-2008-03-04a.el"
*** files-CVS-2008-02-29.el	Fri Feb 29 14:59:08 2008
--- files-patched-2008-03-04a.el	Tue Mar  4 14:04:36 2008
***************
*** 5284,5302 ****
  		      (if val
  			  (put-text-property pos (point)
  					     'dired-filename t)))))))
! 
! 	  (if full-directory-p
! 	      ;; Try to insert the amount of free space.
  	      (save-excursion
  		(goto-char beg)
! 		;; First find the line to put it on.
! 		(when (re-search-forward "^ *\\(total\\)" nil t)
! 		  (let ((available (get-free-disk-space ".")))
! 		    (when available
! 		      ;; Replace "total" with "used", to avoid confusion.
! 		      (replace-match "total used in directory" nil nil nil 1)
! 		      (end-of-line)
! 		      (insert " available " available)))))))))))
  
  (defun insert-directory-adj-pos (pos error-lines)
    "Convert `ls --dired' file name position value POS to a buffer position.
--- 5284,5444 ----
  		      (if val
  			  (put-text-property pos (point)
  					     'dired-filename t)))))))
! 	  (when full-directory-p
!             (save-excursion
!               (goto-char beg)
!               (while (re-search-forward "^ *\\(total\\)" nil t)
!                 (beginning-of-line)
!                 (insert "files " (number-to-string (save-match-data
!                                                      (count-dired-files)))
!                         "/" (number-to-string
!                              (- (length (directory-files default-directory
!                                                          nil nil t)) 2))
!                         " ")
!                 (goto-char beg)
!                 (re-search-forward "^files [0-9]+/[0-9]+ \\(total\\)" nil t)
!                 (replace-match "space used" nil nil nil 1)
!                 (let ((available (and (fboundp 'get-free-disk-space)
!                                       (get-free-disk-space ".")))
!                       (map (make-sparse-keymap)))
!                   (define-key map [mouse-2] 'dired-mouse-describe-listed-directory)
!                   (define-key map "\r" 'dired-describe-listed-directory)
!                   (when available (end-of-line) (insert " available " available))
!                   (add-text-properties
!                    (save-excursion (beginning-of-line) (+ 2 (point)))
!                    (1- (match-beginning 1))
!                    `(mouse-face highlight keymap ,map
!                      help-echo "Files shown / total files in directory \
! \[RET, mouse-2: more info]"))
!                   (add-text-properties
!                    (match-beginning 1) (save-excursion (end-of-line) (point))
!                    `(mouse-face highlight keymap ,map
!                      help-echo "Kbytes used in directory, Kbytes \
! available on disk [RET, mouse-2: more info]")))))))))))
! 
! (defun count-dired-files ()
!   "Returns the number of files in the current Dired directory listing.
! This includes directory entries, as well as files, but it excludes `.'
! and `..'."
!   ;; Should we skip `#' files also, as in `dired-trivial-filenames'? Dunno.
    (save-excursion
+     (re-search-backward "^$" nil 'to-bob)
+     (re-search-forward dired-move-to-filename-regexp nil t)
+     (let* ((beg (line-beginning-position))
+            (end (save-excursion (re-search-forward "^$" nil t)))
+            (dots-p (save-excursion      ; Is `..' present?
                       (goto-char beg)
!                      (re-search-forward
!                       (concat directory-listing-before-filename-regexp
!                               "\\.\\./?$")
!                       end t))))
!       (if dots-p (- (count-lines beg end) 2) (count-lines beg end)))))
! 
! (add-hook 'dired-after-readin-hook 'update-dired-files-count)
! (defun update-dired-files-count ()
!   "Update file count in Dired header for each directory listed."
!   (save-restriction
!     (widen)
!     (let ((num-files (number-to-string (count-dired-files))))
!       (save-excursion
!         (goto-char (point-min))
!         (while (re-search-forward "^  files \\([0-9]+\\)/\\([0-9]+\\)" nil t)
!           (let ((buffer-read-only nil)
!                 (map (make-sparse-keymap)))
!             (define-key map [mouse-2] 'dired-mouse-describe-listed-directory)
!             (define-key map "\r" 'dired-describe-listed-directory)
!             (replace-match (number-to-string (save-match-data (count-dired-files)))
!                            nil nil nil 1)
!             (replace-match (number-to-string
!                             (- (length (directory-files default-directory
!                                                         nil nil t)) 2))
!                            nil nil nil 2)
!             (add-text-properties
!              (save-excursion (beginning-of-line) (+ 2 (point))) (match-end 2)
!              `(mouse-face highlight keymap ,map
!                help-echo "Files shown / total files in directory \
! \[RET, mouse-2: more info]")))
!           (set-buffer-modified-p nil))))))
! 
! (defun dired-describe-listed-directory ()
!   "In Dired, describe the current listed directory."
!   (interactive)
!   (let ((dirname (save-excursion
!                    (forward-line -1)
!                    (skip-syntax-forward " ")
!                    (buffer-substring
!                     (point)
!                     (save-excursion (end-of-line) (1- (point))))))) ; Up to colon.
!     
!     (describe-file dirname)))
! 
! (defun dired-mouse-describe-listed-directory (event)
!   "Describe the current listed directory."
!   (interactive "e")
!   (save-excursion
!     (set-buffer (window-buffer (posn-window (event-end event))))
!     (goto-char (posn-point (event-end event)))
!     (dired-describe-listed-directory)))
! 
! (defun dired-describe-file ()
!   "In Dired, describe this file or directory."
!   (interactive)
!   (describe-file (dired-get-filename nil t)))
! 
! (defun dired-mouse-describe-file (event)
!   "Describe the clicked file."
!   (interactive "e")
!   (let (file)
!     (save-excursion
!       (set-buffer (window-buffer (posn-window (event-end event))))
!       (goto-char (posn-point (event-end event)))
!       (setq file (dired-get-filename nil t)))
!     (describe-file file)))
! 
! ;; This is the same definition as in `help-fns+.el' and `help+20.el'.
! (defun describe-file (filename)
!   "Describe the file named FILENAME.
! If FILENAME is nil, describe the current directory."
!   (interactive "FDescribe file: ")
!   (unless filename (setq filename default-directory))
!   (help-setup-xref (list #'describe-file filename) (interactive-p))
!   (let ((attrs (file-attributes filename)))
!     (unless attrs (error(format "Cannot open file `%s'" filename)))
!     (let* ((type            (nth 0 attrs))
!            (numlinks        (nth 1 attrs))
!            (uid             (nth 2 attrs))
!            (gid             (nth 3 attrs))
!            (last-access     (nth 4 attrs))
!            (last-mod        (nth 5 attrs))
!            (last-status-chg (nth 6 attrs))
!            (size            (nth 7 attrs))
!            (permissions     (nth 8 attrs))
!            ;; Skip 9: t iff file's gid would change if file were deleted
!            ;; and recreated.
!            (inode           (nth 10 attrs))
!            (device          (nth 11 attrs))
!            (help-text
!             (concat
!              (format "Properties of `%s':\n\n" filename)
!              (format "Type:                       %s\n"
!                      (cond ((eq t type) "Directory")
!                            ((stringp type) (format "Symbolic link to `%s'" type))
!                            (t "Normal file")))
!              (format "Permissions:                %s\n" permissions)
!              (and (not (eq t type)) (format "Size in bytes:              %g\n" size))
!              (format-time-string
!               "Time of last access:        %a %b %e %T %Y (%Z)\n" last-access)
!              (format-time-string
!               "Time of last modification:  %a %b %e %T %Y (%Z)\n" last-mod)
!              (format-time-string
!               "Time of last status change: %a %b %e %T %Y (%Z)\n" last-status-chg)
!              (format "Number of links:            %d\n" numlinks)
!              (format "User ID (UID):              %s\n" uid)
!              (format "Group ID (GID):             %s\n" gid)
!              (format "Inode:                      %S\n" inode)
!              (format "Device number:              %s\n" device))))
!       (with-output-to-temp-buffer "*Help*" (princ help-text))
!       help-text)))                      ; Return displayed text.
  
  (defun insert-directory-adj-pos (pos error-lines)
    "Convert `ls --dired' file name position value POS to a buffer position.

[-- Attachment #3: ls-lisp-2008-03-04a.patch --]
[-- Type: application/octet-stream, Size: 2911 bytes --]

diff -c -w "ls-lisp-CVS-2008-02-29.el" "ls-lisp-patched-2008-03-04a.el"
*** ls-lisp-CVS-2008-02-29.el	Fri Feb 29 14:58:50 2008
--- ls-lisp-patched-2008-03-04a.el	Tue Mar  4 14:03:20 2008
***************
*** 260,276 ****
  		  file switches (ls-lisp-time-index switches)
  		  nil full-directory-p))
  	     (signal (car err) (cdr err)))))
- 	;; Try to insert the amount of free space.
  	(save-excursion
  	  (goto-char (point-min))
! 	  ;; First find the line to put it on.
! 	  (when (re-search-forward "^total" nil t)
! 	    (let ((available (get-free-disk-space ".")))
! 	      (when available
! 		;; Replace "total" with "total used", to avoid confusion.
! 		(replace-match "total used in directory")
! 		(end-of-line)
! 		(insert " available " available)))))))))
  
  (defun ls-lisp-insert-directory
    (file switches time-index wildcard-regexp full-directory-p)
--- 260,298 ----
  		  file switches (ls-lisp-time-index switches)
  		  nil full-directory-p))
  	     (signal (car err) (cdr err)))))
  	(save-excursion
  	  (goto-char (point-min))
! 	  (while (re-search-forward "^total" nil t)
!             (beginning-of-line)
!             (insert "files " (number-to-string (save-match-data
!                                                  (count-dired-files)))
!                     "/" (number-to-string
!                          (- (length (directory-files default-directory
!                                                      nil nil t)) 2))
!                     " ")
!             (goto-char (point-min))
!             (re-search-forward "^files [0-9]+/[0-9]+ \\(total\\)" nil t)
!             (replace-match "space used" nil nil nil 1)
!             (let ((available (and (fboundp 'get-free-disk-space)
!                                   (get-free-disk-space ".")))
!                   (map (make-sparse-keymap)))
!               (define-key map [mouse-2]
!                 'dired-mouse-describe-listed-directory)
!               (define-key map "\r" 'dired-describe-listed-directory)
!               (when available (end-of-line) (insert " available "
!                                                     available))
!               (add-text-properties
!                (save-excursion (beginning-of-line) (+ 2 (point)))
!                (1- (match-beginning 1))
!                `(mouse-face highlight keymap ,map
!                  help-echo "Files shown / total files in directory \
! \[RET, mouse-2: more info]"))
!               (add-text-properties
!                (match-beginning 1)
!                (save-excursion (end-of-line) (point))
!                `(mouse-face highlight keymap ,map
!                  help-echo "Kbytes used in directory, Kbytes \
! available on disk [RET, mouse-2: more info]")))))))))
  
  (defun ls-lisp-insert-directory
    (file switches time-index wildcard-regexp full-directory-p)

  reply	other threads:[~2008-03-04 22:28 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-01  1:03 patch for Dired second header line info Drew Adams
2008-03-01 13:31 ` Richard Stallman
2008-03-01 16:31   ` Drew Adams
2008-03-01 23:09     ` Richard Stallman
2008-03-02  2:55 ` Juri Linkov
2008-03-02  8:05   ` Drew Adams
2008-03-02 14:36     ` Juri Linkov
2008-03-02 16:27       ` Drew Adams
2008-03-02 17:49         ` Drew Adams
2008-03-02 17:57           ` Juri Linkov
2008-03-02 18:56             ` Drew Adams
2008-03-02 19:06               ` Drew Adams
2008-03-03  0:47                 ` Drew Adams
2008-03-03 18:27             ` Richard Stallman
2008-03-03 21:45               ` Stefan Monnier
2008-03-03 22:29                 ` Drew Adams
2008-03-04 17:38                   ` Richard Stallman
2008-03-04 19:44                     ` Drew Adams
2008-03-04 22:28                       ` Drew Adams [this message]
2008-03-05 21:33                       ` Richard Stallman
2008-03-03 18:27           ` Richard Stallman
2008-03-03 19:01             ` Drew Adams
2008-03-02 17:56         ` Juri Linkov

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='003001c87e47$14f24a60$0600a8c0@us.oracle.com' \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=juri@jurta.org \
    --cc=monnier@iro.umontreal.ca \
    --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 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.