Subject: bug#79042: 29.4; dired-get-marked-files docstring is incorrect

From: Drew Adams <[email-masked]>
Date: Fri, 18 Jul 2025 16:27:36 +0000

>> It's not a doc bug, it's a product bug - a regression
>> introduced in Emacs 29.  In prior versions it works
>> as the doc says: (dired-get-marked-files nil 'marked)
>> returns the file name on the current line.
>
> Wait, so dired-get-marked-files isn't supposed to be able to 
> distinguish between a single explicitly marked file and no files 
> being marked?  But that's information that I need.
> How do I get it, if not with dired-get-marked-files?

Mea culpa.  I shouldn't have said the Emacs 29+ behavior
of recognizing a special `marked' value for ARG is a bug.
(It's maybe not the best way to allow that behavior, but
it's OK.)

And I guess you're right, that that code change made the
`dired-get-marked-files' doc incorrect.  So your report
is a good one.  Sorry for the noise.

`dired-get-marked-files' is pretty much a utility function
for defining commands, i.e., for interactive use, which is
why it returns the file name of the current line if there
are no explicit marks.

You can use macro `dired-map-over-marks' (in Emacs 29+) to
do what you want:

(defun my-marked-files-list (&optional localp distinguish-one-marked)
  "..."
  (delq nil (save-excursion
              (dired-map-over-marks (dired-get-filename localp 'NO-ERROR)
				              'marked
				              nil
				              distinguish-one-marked))))