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

From: Drew Adams <[email-masked]>
Date: Thu, 5 Jun 2025 16:18:34 +0000

+Eli, Stefan K, Andrea, and RMS, for the find* Dired buffers
question (variable `dired-buffers').
_____

> > _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:

Yes, as I said, only find-dired.el and find-lisp.el.

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

Dunno how to audit such a thing.

> Offhand it seems odd to me.

Yes.

My guess is that it was done only as a precaution, not
knowing what eventual differences might be introduced
between "regular" Dired buffers and the find* ones.

A Dired buffer with cons DIRNAME (i.e., an arbitrary set
of files, not the result of something like `ls') has
similar differences (limitations) wrt "regular" Dired
buffers, and such buffers are included in `dired-buffers'.
To me, the find* Dired buffers are pretty much akin to the
arbitrary-files Dired buffers.

But I may be missing something.  Is there a Dired expert
in the house?  Or someone with memory of this?  Or some
way to check non-vanilla code in the wild, to see if this
really matters for find* buffers?
____

Maybe Eli, Stefan K., Andrea, or RMS has a suggestion.
The question is whether we can reasonably remove this
binding from the find-dired.el and find-lisp.el code:

  (let ((dired-buffers dired-buffers))...)

IOW, is there a good reason to preclude find* Dired
buffers from the value of `dired-buffers'?

The advantage of not excluding them is that when looking
for Dired buffers we don't need to filter the entire
`buffer-list'; we can just use `dired-buffers' as the
search space.

Note: `dired-buffers' are buffers with mode derived from
`dired-mode'.  The list is filled by `dired-advertise'
and reduced by `dired-unadvertise'.  It doesn't include
`wdired-mode' buffers, for example, because WDired uses
`dired-unadvertise'.