bug#44023: dired-allow-duplicate-buffers

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#44023: dired-allow-duplicate-buffers

Boruch Baum
The attached patch adds a defcustom option to allow multiple buffers to
visit the same directory. This became desirable to me for an extension I
wrote (soon to be submitted) to store each chain of dired buffers'
'navigation history' and allow going back/forward to any point in the
history. As you all know, this has been a feature common to all file
*managers* since almost forever; technically dired is a directory
editor, not a file manager, but I expect many will find the feature
desirable, even expected, since all other similar programs have it.

In going through the existing dired code, it seems that some functions
presume that multiple buffers can be visiting the same directory. See:

  dired-find-buffer-nocreate
  dired-fun-in-all-buffers
  dired-clean-up-after-deletion

Also, implicit in the comment for `dired-find-buffer-nocreate' is that
more than one match may exist for a dired directory buffer.

So, maybe this once existed or was planned?

The first patch is for the option. The second patch is a change of
comments to docstrings.

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0

1.patch (1K) Download Attachment
2.patch (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#44023: dired-allow-duplicate-buffers

Lars Ingebrigtsen
Boruch Baum <[hidden email]> writes:

> Also, implicit in the comment for `dired-find-buffer-nocreate' is that
> more than one match may exist for a dired directory buffer.
>
> So, maybe this once existed or was planned?

Dired has always supported having several buffers visiting the same
directory, so I'm not quite sure what the proposed patch is trying to
fix.  You just rename the buffer to something else, like with any
command that defaults to a single buffer name (like, say, `M-x grep').

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#44023: dired-allow-duplicate-buffers

Boruch Baum
On 2020-10-16 07:32, Lars Ingebrigtsen wrote:

> Boruch Baum <[hidden email]> writes:
>
> > Also, implicit in the comment for `dired-find-buffer-nocreate' is that
> > more than one match may exist for a dired directory buffer.
> >
> > So, maybe this once existed or was planned?
>
> Dired has always supported having several buffers visiting the same
> directory, so I'm not quite sure what the proposed patch is trying to
> fix.  You just rename the buffer to something else, like with any
> command that defaults to a single buffer name (like, say, `M-x grep').

That's not "dired support" in any shape or form! That's an emacs kludge
external to dired that exploits how dired handles buffer names (likewise
for grep). Dired internally (in the very line being modified by my
patch) actively subverts having several buffers visiting the same
directory, and my experience in testing is that no harm is done when
using the patch.

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0



Reply | Threaded
Open this post in threaded view
|

bug#44023: dired-allow-duplicate-buffers

Lars Ingebrigtsen
Boruch Baum <[hidden email]> writes:

> Dired internally (in the very line being modified by my
> patch) actively subverts having several buffers visiting the same
> directory,

What line are you referring to?

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#44023: dired-allow-duplicate-buffers

Boruch Baum
On 2020-10-16 18:25, Lars Ingebrigtsen wrote:
> Boruch Baum <[hidden email]> writes:
>
> > Dired internally (in the very line being modified by my
> > patch) actively subverts having several buffers visiting the same
> > directory,
>
> What line are you referring to?

-         (buffer (dired-find-buffer-nocreate dirname mode))

It's the only line changed in the patch file, at the beginning of
function dired-internal-noselect.

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0



Reply | Threaded
Open this post in threaded view
|

bug#44023: dired-allow-duplicate-buffers

Lars Ingebrigtsen
Boruch Baum <[hidden email]> writes:

>> > Dired internally (in the very line being modified by my
>> > patch) actively subverts having several buffers visiting the same
>> > directory,
>>
>> What line are you referring to?
>
> -         (buffer (dired-find-buffer-nocreate dirname mode))
>
> It's the only line changed in the patch file, at the beginning of
> function dired-internal-noselect.

Ah, yes, it seems like dired is working the same as when visiting a
regular file here.  As find-file says:

---
Switch to a buffer visiting file FILENAME,
creating one if none already exists.
---

Dired buffers aren't "visiting" files in the same way that regular files
are, but it tries to keep the same semantics.

So renaming a dired buffer doesn't help at all, because Emacs will
always root out the already-existing buffer that points to that
directory.  I wonder whether that's on purpose, or whether it just
happens that way by accident.  Or is there a way to rename a dired
buffer so that you can have two of them pointing to the same directory?

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#44023: dired-allow-duplicate-buffers

Boruch Baum
On 2020-10-19 10:11, Lars Ingebrigtsen wrote:
> Ah, yes
> ...
> I wonder
> ...
> is there a way to rename a dired buffer so that you can have two of
> them pointing to the same directory?

The patch does it without any need to explicitly rename anything, It all
happens blissfully auto-magically.

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0