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

From: Tassilo Horn <[email-masked]>
Date: Wed, 30 Mar 2022 18:32:41 +0200

Eli Zaretskii <[email-masked]> writes:

>> From: Tassilo Horn <[email-masked]>
>> Cc: [email-masked], [email-masked]
>> Date: Wed, 30 Mar 2022 18:02:15 +0200
>> 
>> Eli Zaretskii <[email-masked]> writes:
>> 
>> > So when will SUBDIRS be non-nil?  dired-clean-up-after-deletion is
>> > called not only when a directory is deleted, I think.
>> 
>> Yes, it's also called when deleting a file but in that case
>> dired-buffers-for-dir will return nil, so no buffer will be deleted.
>
> What about moving/renaming a directory?

No, it's only called from dired-delete-entry which is only called from
dired-internal-do-deletions which is only called from dired-do-delete
and dired-do-flagged-delete.  So only real deletions.

>> I think my patch is valid but now I think I should just create a
>> separate function dired-buffers-for-cleanup and use that from
>> dired-clean-up-after-deletion (or just collect the buffers in that
>> function) and remove the SUBDIRS argument from dired-buffers-for-dir as
>> it changes its logic too drastically.
>> 
>> I'll prepare a patch in that direction later.
>
> At this point, I'd prefer the safest, simplest patch for the release
> branch, because I intend to release Emacs 28.1 VSN.  We can make a
> cleaner fix on master later.

The other patch with the separate function only called by
dired-clean-up-after-deletion is equivalent and safer than the
modification of dired-buffers-for-dir which is called in many places.
In the worst case, we have a cleanup problem after directory deletion.

> Do you think this patch you posted is safe enough for Emacs 28.1?

Yes, but I'd very much prefer to use the newer patch from my mail some
minutes ago for the reasons explained above.

Bye,
Tassilo