Subject: bug#44023: dired-allow-duplicate-buffers

From: Stefan Monnier <[email-masked]>
Date: Fri, 06 Nov 2020 09:29:53 -0500

>> > In going through the existing dired code, it seems that some functions
>> > presume that multiple buffers can be visiting the same directory. See:
>> Because of the functionality of Dired (which allows visiting several
>> directories (and subdirectories)) in a single buffer, the code basically
>> "has to" handle that case, indeed (tho I'd be surprised if there aren't
>> improvements to be made in that regard).
> The case you mention sounds like the converse: multiple directories in a
> single buffer, versus what I'm addressing which is multiple buffers for
> a single directory.

Yes, but:
start with a dired in ~/foo and another in ~/foo/bar and then in ~/foo
ask dired to add the contents of ~/foo/bar to it: pronto you have
2 dired buffers that both show the content of ~/foo/bar.  So because of
that kind of scenario, dired has to handle some kind of "two dired
buffers both showing the same directory" (tho it's not exactly the same
as your scenario, admittedly).

>> E.g. I suspect that diredc wants/needs this feature, but it's not
>> diredc's job to set user options, so for diredc it would probably make
>> more sense to pass that as an argument.
>> WDYT?
>
> I prefer the defcustom route because I like giving a user choices (it's
> also more emacs-y).

I don't see this as a question of "choice vs no-choice" but a question
is: should this be decided globally over the whole Emacs session, or
should it be decided one  a case-by-case basis (in both cases the
decision should be under the user's control, either by setting
a variable, or by calling a different command, or by using the same
command bu tin a different context, ...).

> Less subjectively, adding an argument creates a mess
> because the modified function is a generic internal function

Which is why I then suggested a separate function/command (which will
require a bit of refactoring to share the common code, of course, but
that's an implementation detail).

        Stefan