all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Juri Linkov'" <juri@jurta.org>
Cc: emacs-devel@gnu.org
Subject: RE: patch for Dired second header line info
Date: Sun, 2 Mar 2008 10:56:36 -0800	[thread overview]
Message-ID: <003001c87c97$24a81400$0600a8c0@us.oracle.com> (raw)
In-Reply-To: <87zlth7zwh.fsf@jurta.org>

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

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


[-- Attachment #2: files-2008-03-02b.patch --]
[-- Type: application/octet-stream, Size: 4039 bytes --]

diff -c -w files-CVS-2008-02-29.el files-patched-2008-03-02b.el
*** files-CVS-2008-02-29.el	Fri Feb 29 14:59:08 2008
--- files-patched-2008-03-02b.el	Sun Mar  2 10:49:54 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,5342 ----
  		      (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 "."))))
                    (when available
                      (end-of-line)
!                     (insert " available " available)))
!                 (put-text-property (progn (beginning-of-line) (point))
!                                    (progn (end-of-line) (point))
!                                    'help-echo "Files shown, total files in \
! dir, Kbytes used in dir, Kbytes available on disk")))))))))
! 
! (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."
!   (let ((num-files (number-to-string (count-dired-files))))
!     (save-excursion
!       (goto-char (point-min))
!       (while (re-search-forward "^  files \\([0-9]+\\)" nil t)
!         (let ((buffer-read-only nil))
!           (replace-match (number-to-string (save-match-data (count-dired-files)))
!                          nil nil nil 1))
!         (set-buffer-modified-p nil)))))
  
  (defun insert-directory-adj-pos (pos error-lines)
    "Convert `ls --dired' file name position value POS to a buffer position.

Diff finished.  Sun Mar 02 10:53:36 2008

[-- Attachment #3: ls-lisp-2008-03-02b.patch --]
[-- Type: application/octet-stream, Size: 2360 bytes --]

diff -c -w ls-lisp-CVS-2008-02-29.el ls-lisp-patched-2008-03-02b.el
*** ls-lisp-CVS-2008-02-29.el	Fri Feb 29 14:58:50 2008
--- ls-lisp-patched-2008-03-02b.el	Sun Mar  2 10:51:18 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,287 ----
  		  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 "."))))
                (when available
                  (end-of-line)
!                 (insert " available " available)))
!             (put-text-property (progn (beginning-of-line) (point))
!                                (progn (end-of-line) (point))
!                                'help-echo "Files shown, total files in \
! dir, Kbytes used in dir, Kbytes available on disk")))))))
  
  (defun ls-lisp-insert-directory
    (file switches time-index wildcard-regexp full-directory-p)

Diff finished.  Sun Mar 02 10:51:42 2008

  reply	other threads:[~2008-03-02 18:56 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 [this message]
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
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='003001c87c97$24a81400$0600a8c0@us.oracle.com' \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=juri@jurta.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.