Subject: RE: [External] : bug#78658: 30.1; [PATCH] Dired feature suggestion: dired-on-marked-files-in-all-buffers

From: Phil Sainty <[email-masked]>
Date: Thu, 05 Jun 2025 20:30:14 +1200

On 2025-06-05 06:26, Drew Adams wrote:
> I'm afraid I may have led you (and myself) astray, by suggesting to
> use variable `dired-buffers' instead of testing all buffers.
> (I see you adopted that in your latest code.)
> 
> It works fine, and it's much faster by not bothering with non-Dired
> buffers.  The problem is that it doesn't work with commands
> `find-dired' and  `find-lisp-find-dired*'.  They produce legitimate
> Dired buffers, and they work fine with the feature we're discussing,
> but they're excluded from `dired-buffers'.  They have this binding:
> 
>   (let ((dired-buffers dired-buffers))...)

Ah, yes :/  Along with their derivative commands.

> _Should_ they be excluded from `dired-buffers'?  Maybe so, maybe not.
> They support most Dired features, and their mode is `dired-mode', but
> there are perhaps a few Dired features they don't support (dunno what,
> offhand - they support WDired and everything else that occurs to me
> offhand).  (I wish their code included a comment as to _why_ they have
> that binding.)

The following seems to be the best there is, which doesn't help
beyond confirming that it's intentional (which was already clear
from the binding itself).

commit 0322a154b764f8358ba8913dc6fc724ba9f4294d
Author: Richard M. Stallman <[email-masked]>
Date:   Sat Jun 27 21:59:11 1998 +0000

     (find-dired): Bind dired-buffers so it can't change.  Use 
abbreviate-file-name.

The symbol doesn't crop up in too many places:

./find-lisp.el:47:(defvar dired-buffers)
./find-lisp.el:217:  (let ((dired-buffers  dired-buffers)
./find-dired.el:226:  (let ((dired-buffers dired-buffers))
./bs.el:187:    ;; Dired-Buffers
./dired.el:1093:                   dired-buffers)))))
./dired.el:1488:(defvar dired-buffers nil
./dired.el:1520:      (let (found (blist dired-buffers))    ; was 
(buffer-list)
./dired.el:3592:`dired-buffers'."
./dired.el:3595:    (dolist (elt dired-buffers)
./dired.el:3600:	(setq dired-buffers (delq elt dired-buffers)))
./dired.el:3619:`dired-buffers'."
./dired.el:3622:    (dolist (elt dired-buffers)
./dired.el:3627:	(setq dired-buffers (delq elt dired-buffers)))
./dired.el:3667:  ;;"Advertise in variable `dired-buffers' that we dired 
`default-directory'."
./dired.el:3672:      (setq dired-buffers
./dired.el:3674:		  dired-buffers)))))
./dired.el:3677:  ;; Remove DIR from the buffer alist in variable 
dired-buffers.
./dired.el:3681:  (setq dired-buffers
./dired.el:3682:	(delq (assoc (expand-file-name dir) dired-buffers) 
dired-buffers)))
./org/org-capture.el:76:(defvar dired-buffers)
./org/org-capture.el:705:							     dired-buffers))))

So auditing the associated behaviours might be an option,
to see if some reason for it becomes apparent.

Offhand it seems odd to me.

-Phil