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

From: Stefan Monnier <[email-masked]>
Date: Thu, 05 Nov 2020 10:38:40 -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).

> +(defcustom dired-allow-duplicate-buffers t
[...]
> -         ;; Look for an existing buffer.
> -         (buffer (dired-find-buffer-nocreate dirname mode))
> -	 ;; Note that buffer already is in dired-mode, if found.
> +         (buffer (when (not (bound-and-true-p dired-allow-duplicate-buffers))
> +                   ;; Look for an existing buffer.
> +                   (dired-find-buffer-nocreate dirname mode)
> +                   ;; Note that buffer already is in dired-mode, if found.
> +                   ))

[ The ";; Note ..." comment seems to be misplaced.  ]

I wonder if it's better to add a user-config variable or a new argument
to `dired-internal-noselect`?

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?

        Stefan