mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-27 19:31:38 +00:00
Add a new command to report the number and size of the marked files
2019-06-25 Constantino Calancha <f92capac@gmail.com> * lisp/dired.el (dired-mode-map): New keystroke and menu binding (bug#22829). 2019-06-25 Lars Ingebrigtsen <larsi@gnus.org> * doc/emacs/dired.texi (Marks vs Flags): Document it. * lisp/dired.el (dired-number-of-marked-files): New command.
This commit is contained in:
parent
9e81b22113
commit
b26c2767ed
@ -435,6 +435,12 @@ the previous @minus{}@var{n} files). If invoked on a subdirectory
|
||||
header line (@pxref{Subdirectories in Dired}), this command marks all
|
||||
the files in that subdirectory.
|
||||
|
||||
@item * N
|
||||
@kindex * N @r{(Dired)}
|
||||
@findex dired-number-of-marked-files
|
||||
Report what the number and size of the marked files are
|
||||
(@code{dired-number-of-marked-files}).
|
||||
|
||||
@item * *
|
||||
@kindex * * @r{(Dired)}
|
||||
@findex dired-mark-executables
|
||||
|
4
etc/NEWS
4
etc/NEWS
@ -607,6 +607,10 @@ remapped to these, respectively.
|
||||
+++
|
||||
*** New command 'dired-create-empty-file'.
|
||||
|
||||
+++
|
||||
*** New command and keystroke `dired-number-of-marked-files' bound to
|
||||
`* N'.
|
||||
|
||||
** Find-Dired
|
||||
|
||||
*** New customizable variable 'find-dired-refine-function'.
|
||||
|
@ -1669,6 +1669,7 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST."
|
||||
(define-key map "*/" 'dired-mark-directories)
|
||||
(define-key map "*@" 'dired-mark-symlinks)
|
||||
(define-key map "*%" 'dired-mark-files-regexp)
|
||||
(define-key map "*N" 'dired-number-of-marked-files)
|
||||
(define-key map "*c" 'dired-change-marks)
|
||||
(define-key map "*s" 'dired-mark-subdir-files)
|
||||
(define-key map "*m" 'dired-mark)
|
||||
@ -1815,6 +1816,9 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST."
|
||||
(define-key map [menu-bar immediate revert-buffer]
|
||||
'(menu-item "Refresh" revert-buffer
|
||||
:help "Update contents of shown directories"))
|
||||
(define-key map [menu-bar immediate dired-number-of-marked-files]
|
||||
'(menu-item "#Marked Files" dired-number-of-marked-files
|
||||
:help "Display the number and size of the marked files"))
|
||||
|
||||
(define-key map [menu-bar immediate dashes]
|
||||
'("--"))
|
||||
@ -3607,6 +3611,30 @@ object files--just `.o' will mark more than you might think."
|
||||
(and fn (string-match-p regexp fn))))
|
||||
"matching file")))
|
||||
|
||||
(defun dired-number-of-marked-files ()
|
||||
"Display the number and total size of the marked files."
|
||||
(interactive)
|
||||
(let* ((files (dired-get-marked-files nil nil nil t))
|
||||
(nmarked
|
||||
(cond ((null (cdr files))
|
||||
0)
|
||||
((and (= (length files) 2)
|
||||
(eq (car files) t))
|
||||
1)
|
||||
(t
|
||||
(length files))))
|
||||
(size (cl-loop for file in files
|
||||
when (stringp file)
|
||||
sum (file-attribute-size (file-attributes file)))))
|
||||
(if (zerop nmarked)
|
||||
(message "No marked files"))
|
||||
(message "%d marked file%s (%sB total size)"
|
||||
nmarked
|
||||
(if (= nmarked 1)
|
||||
""
|
||||
"s")
|
||||
(file-size-human-readable size))))
|
||||
|
||||
(defun dired-mark-files-containing-regexp (regexp &optional marker-char)
|
||||
"Mark all files with contents containing REGEXP for use in later commands.
|
||||
A prefix argument means to unmark them instead.
|
||||
|
Loading…
Reference in New Issue
Block a user