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 16:47:17 -0800 [thread overview]
Message-ID: <005101c87cc8$219dc3f0$0600a8c0@us.oracle.com> (raw)
In-Reply-To: <003701c87c98$91cec6e0$0600a8c0@us.oracle.com>
[-- Attachment #1: Type: text/plain, Size: 1542 bytes --]
New patch attached, for consideration as an alternative to the previous one.
They are the same except for the following new feature, which you might or
might not like:
The directory info line has mouse-face highlighting. Hitting RET or clicking
mouse-2 on it displays more info about the directory, in buffer *Help*.
This is what the *Help* display looks like:
Properties of `c:/foobar':
Type: Directory
Permissions: drwxrwxrwx
Time of last access: Sun Mar 2 00:00:00 2008 (Pacific Standard
Time)
Time of last modification: Tue Aug 21 19:21:00 2007 (Pacific Standard
Time)
Time of last status change: Tue Aug 21 19:20:59 2007 (Pacific Standard
Time)
Number of links: 1
User ID (UID): 5
Group ID (GID): 5
Inode: 26687
Device number: 240391127
[back]
Obviously, a different choice could be made for the time format. Just as
obviously, some of this info is already displayed in the Dired buffer,
unless you use `dired-details-hide' (did that ever get added to Emacs?) to
hide the details.
The help commands involved are general. I added them to files.el, but you
might want to do one or more of the following:
1. Move `describe-file' to help-fns.el (and bind it to, say, `C-h M-f').
2. Move `dired(-mouse)-describe-file' to dired.el.
3. Move `dired(-mouse)-describe-listed-directory' to dired.el.
The commands in #3 are used only in `insert-directory', however, so you
might prefer to keep them in files.el.
[-- Attachment #2: ls-lisp-2008-03-02c.patch --]
[-- Type: application/octet-stream, Size: 2729 bytes --]
diff -c -w ls-lisp-CVS-2008-02-29.el ls-lisp-patched-2008-03-02c.el
*** ls-lisp-CVS-2008-02-29.el Fri Feb 29 14:58:50 2008
--- ls-lisp-patched-2008-03-02c.el Sun Mar 2 15:53: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,295 ----
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)))
! (add-text-properties
! (save-excursion (beginning-of-line) (point))
! (save-excursion (end-of-line) (point))
! `(mouse-face highlight
! keymap
! ,(let ((map (make-sparse-keymap)))
! (define-key map [mouse-2]
! 'dired-mouse-describe-listed-directory)
! (define-key map "\r" 'dired-describe-listed-directory)
! map)
! help-echo "Files shown, total files in dir, Kbytes \
! used in dir, Kbytes available on disk [RET, mouse-2: more info]"))))))))
(defun ls-lisp-insert-directory
(file switches time-index wildcard-regexp full-directory-p)
Diff finished. Sun Mar 02 15:53:46 2008
[-- Attachment #3: files-2008-03-02d.patch --]
[-- Type: application/octet-stream, Size: 9008 bytes --]
diff -c -w "files-CVS-2008-02-29.el" "files-patched-2008-03-02e.el"
*** files-CVS-2008-02-29.el Fri Feb 29 14:59:08 2008
--- files-patched-2008-03-02e.el Sun Mar 2 16:31:56 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,5446 ----
(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)))
! (add-text-properties
! (save-excursion (beginning-of-line) (point))
! (save-excursion (end-of-line) (point))
! `(mouse-face highlight
! keymap
! ,(let ((map (make-sparse-keymap)))
! (define-key map [mouse-2]
! 'dired-mouse-describe-listed-directory)
! (define-key map "\r" 'dired-describe-listed-directory)
! map)
! help-echo "Files shown, total files in dir, Kbytes \
! used in dir, 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."
! (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))
! (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) (point))
! (save-excursion (end-of-line) (point))
! `(mouse-face highlight
! keymap
! ,(let ((map (make-sparse-keymap)))
! (define-key map [mouse-2]
! 'dired-mouse-describe-listed-directory)
! (define-key map "\r" 'dired-describe-listed-directory)
! map)
! help-echo "Files shown, total files in dir, Kbytes \
! used in dir, Kbytes available on disk [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.
Diff finished at Sun Mar 02 16:32:32
next prev parent reply other threads:[~2008-03-03 0:47 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 [this message]
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='005101c87cc8$219dc3f0$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.