Function: dired-get-marked-files
dired-get-marked-files is a byte-compiled function defined in
dired.el.gz.
Signature
(dired-get-marked-files &optional LOCALP ARG FILTER DISTINGUISH-ONE-MARKED ERROR)
Documentation
Return the marked files' names as list of strings.
The list is in the same order as the Dired buffer text, that is, the car
is the first marked file.
Values returned are normally absolute file names.
Optional arg LOCALP is as in dired-get-filename.
Optional second argument ARG, if non-nil, specifies files near
point to return instead of marked files. It usually comes from the
prefix argument of the caller.
If ARG is an integer, return the next ARG files (previous if ARG is
negative).
If ARG is the symbol marked, return only marked files; return nil
if none are marked
If ARG is any other non-nil value, return the current file name.
If no files are marked, and ARG is nil, also return the current file name.
Optional third argument FILTER, if non-nil, is a function to select
some of the files--those for which (funcall FILTER FILENAME) is non-nil.
If DISTINGUISH-ONE-MARKED is non-nil, then if we find just one marked file, return (t FILENAME) instead of (FILENAME). Don't use that together with FILTER.
If ERROR is non-nil, signal an error when the list of found files is empty. ERROR can be a string with the error message.
Source Code
;; Defined in /usr/src/emacs/lisp/dired.el.gz
(defun dired-get-marked-files (&optional localp arg filter distinguish-one-marked error)
"Return the marked files' names as list of strings.
The list is in the same order as the Dired buffer text, that is, the car
is the first marked file.
Values returned are normally absolute file names.
Optional arg LOCALP is as in `dired-get-filename'.
Optional second argument ARG, if non-nil, specifies files near
point to return instead of marked files. It usually comes from the
prefix argument of the caller.
If ARG is an integer, return the next ARG files (previous if ARG is
negative).
If ARG is the symbol `marked', return only marked files; return nil
if none are marked
If ARG is any other non-nil value, return the current file name.
If no files are marked, and ARG is nil, also return the current file name.
Optional third argument FILTER, if non-nil, is a function to select
some of the files--those for which (funcall FILTER FILENAME) is non-nil.
If DISTINGUISH-ONE-MARKED is non-nil, then if we find just one marked file,
return (t FILENAME) instead of (FILENAME).
Don't use that together with FILTER.
If ERROR is non-nil, signal an error when the list of found files is empty.
ERROR can be a string with the error message."
(let ((all-of-them
(save-excursion
(delq nil (dired-map-over-marks
(dired-get-filename localp 'no-error-if-not-filep)
arg nil distinguish-one-marked))))
result)
(when (equal all-of-them '(t))
(setq all-of-them nil))
(if (not filter)
(setq result
(if (and distinguish-one-marked (eq (car all-of-them) t))
all-of-them
(nreverse all-of-them)))
(dolist (file all-of-them)
(if (funcall filter file)
(push file result))))
(when (and (null result) error)
(user-error (if (stringp error) error "No files specified")))
result))