Subject: Re: bug#54636: dired fails to update subdirs when files are created/deleted/renamed

From: Eli Zaretskii <[email-masked]>
Date: Wed, 30 Mar 2022 16:56:38 +0300

> From: Tassilo Horn <[email-masked]>
> Cc: [email-masked], [email-masked]
> Date: Wed, 30 Mar 2022 15:29:36 +0200
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> >> Oh, sorry, I'll look into it ASAP.  I guess this is to be corrected
> >> in emacs-28?
> >
> > Yes.
> >
> > I think I just fixed it there, please take a look.
> 
> That's what I was about to do, too, but that's not right, too.

Well, it fixes the regression.

> Say you have dired buffers for
> 
>   ~/
>   ~/foo/
>   ~/foo/bar/
> 
> and then delete ~/foo from inside the ~/ dired buffer.  You'll be asked
> if the buffers for foo should be delete, too, and when you confirm, what
> is deleted are the buffers ~/ and ~/foo but ~/foo/bar persists.  So the
> buffers are deleted downwards (to the root) instead of upwards which is
> wrong.

This means your fix for the "ask" part is incomplete, and should be
improved.  But that is a new feature in Emacs 28, so it is not a
catastrophe if it is imperfect.  Regressions in previously correct
behavior are much worse.

Of course, if you can come up with a fix for the question-asking part
that makes it delete all the relevant buffers, and if that fix is safe
enough (a high bar at this late stage of the pretest), we can install
that on the release branch.  Failing that, the fix for that will have
to wait till Emacs 28.2 at the very least.

> I guess I recognized that in 7b50ed553f and switched the arguments for
> that very reason.  (file-in-directory-p has the same argument order as
> dired-in-this-tree.)

But reversing the arguments breaks dired-in-this-tree completely,
because it doesn't treat the arguments symmetrically.  In the scenario
described by Andreas, dired-in-this-tree consistently returned nil for
a subdirectory inserted into a Dired buffer of its parent with 'i'.
Specifically, DIR will _never_ match DIR/FILE inside
dired-in-this-tree, only the other way around.