Subject: bug#70593: 30.0.50; Dired: buffers of renamed dirs are broken

From: Drew Adams <[email-masked]>
Date: Thu, 9 May 2024 21:20:09 +0000

> When I call dired with a cons DIRNAME, `dired-directory' will be bound
> to that cons.  And it is consulted for reverting.
> 
> When I overwrite it with just `default-directory' and revert, the result
> will be a "normal" dired buffer showing this directory - the explicit
> listing is lost.

Right.

> In the scenario of the bug this surely makes a difference.

OK; sounds right.

> My latest patch seems to work as expected.
> Any comment about the patch btw?

I can't really judge.  Eyeballing it, it looks
reasonable.

What I see is that when `dired-directory' is a
cons you replace its car, DIRED-DIR, applying this to that car:

 (abbreviate-file-name
   (file-name-as-directory DIRED-DIR))

But the car of a cons `dired-directory' isn't
necessarily a directory name or any file name.
It's just a string used as the Dired buffer
name.  (Often it is a directory name, but it
need not be.)

If it's a directory name then what you're doing
looks right to me.  If it's not then I think
it's probably still OK - that code would
generally just append a `/' to the string.

But if the string has some particular file-name
syntax then maybe there could be some other 
resulting behavior; dunno.
 
> Subdir insertion in cons value `dired-directory' buffers 
> are not really supported currently it seems

Not sure what you mean.  Even in vanilla Emacs,
I think subdir insertion is supported.  E.g.:

M-: (dired (list "foobar" "/tata/file.txt"
                 "/toto/dir/" "/titi/"))

You get a Dired listing in buffer `foobar' with
those 3 filename entries.  Hitting `i' when on
the second entry inserts a listing of directory 
/toto/dir.  Hitting `i' on the third entry
inserts a listing of directory /titi.  That's
what I see, at least.

But maybe you meant something else?

> so I took this complication aside for now.
> The code does handle the subdir alists, though.

By "the subdir alists" I guess you mean
`dired-subdir-alist'.

___

What I think you've done seems reasonable.  It
should probably be checked in various scenarios,
however - at least a sanity check.