From: Tassilo Horn <tsdh@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 54636@debbugs.gnu.org, schwab@linux-m68k.org
Subject: bug#54636: dired fails to update subdirs when files are created/deleted/renamed
Date: Wed, 30 Mar 2022 16:30:22 +0200 [thread overview]
Message-ID: <87czi31p1l.fsf@gnu.org> (raw)
In-Reply-To: <831qyj8rxl.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1439 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
Hi Eli,
>> > 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.
That's true.
>> 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.
It's still a major annoyance since the feature is not opt-in.
> Regressions in previously correct behavior are much worse.
Of course.
> 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.
Here's a patch. I've created a separate cond-arm for the SUBDIRS case,
so any callers which are not dired-clean-up-after-deletion (the only one
setting SUBDIRS) are not affected.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: dired.patch --]
[-- Type: text/x-patch, Size: 1723 bytes --]
diff --git a/lisp/dired.el b/lisp/dired.el
index 75dcd33e67..972a0865f4 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2874,8 +2874,9 @@ dired-buffers-for-dir
"Return a list of buffers for DIR (top level or in-situ subdir).
If FILE is non-nil, include only those whose wildcard pattern (if any)
matches FILE.
-If SUBDIRS is non-nil, also include the dired buffers of
-directories below DIR.
+If SUBDIRS is non-nil, include the dired buffers of DIR and the
+directories below DIR instead (but no dired buffers with in-situ
+subdir DIR).
The list is in reverse order of buffer creation, most recent last.
As a side effect, killed dired buffers for DIR are removed from
`dired-buffers'."
@@ -2887,10 +2888,9 @@ dired-buffers-for-dir
((null (buffer-name buf))
;; Buffer is killed - clean up:
(setq dired-buffers (delq elt dired-buffers)))
- ((dired-in-this-tree-p dir (car elt))
+ ((and (null subdirs) (dired-in-this-tree-p dir (car elt)))
(with-current-buffer buf
- (when (and (or subdirs
- (assoc dir dired-subdir-alist))
+ (when (and (assoc dir dired-subdir-alist)
(or (null file)
(if (stringp dired-directory)
(let ((wildcards (file-name-nondirectory
@@ -2900,7 +2900,9 @@ dired-buffers-for-dir
file)))
(member (expand-file-name file dir)
(cdr dired-directory)))))
- (setq result (cons buf result)))))))
+ (setq result (cons buf result)))))
+ ((and subdirs (dired-in-this-tree-p (car elt) dir))
+ (setq result (cons buf result)))))
result))
(defun dired-glob-regexp (pattern)
[-- Attachment #3: Type: text/plain, Size: 47 bytes --]
Can we agree it is safe enough?
Bye,
Tassilo
next prev parent reply other threads:[~2022-03-30 14:30 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-30 11:15 bug#54636: dired fails to update subdirs when files are created/deleted/renamed Andreas Schwab
2022-03-30 12:03 ` Eli Zaretskii
2022-03-30 12:11 ` Andreas Schwab
2022-03-30 12:43 ` Tassilo Horn
2022-03-30 13:22 ` Eli Zaretskii
2022-03-30 13:29 ` Tassilo Horn
2022-03-30 13:56 ` Eli Zaretskii
2022-03-30 14:30 ` Tassilo Horn [this message]
2022-03-30 15:51 ` Eli Zaretskii
2022-03-30 16:02 ` Tassilo Horn
2022-03-30 16:29 ` Tassilo Horn
2022-03-30 16:42 ` Eli Zaretskii
2022-03-30 16:47 ` Tassilo Horn
2022-03-30 16:55 ` Eli Zaretskii
2022-03-30 17:51 ` Tassilo Horn
2022-04-05 11:30 ` Eli Zaretskii
2022-03-30 16:30 ` Eli Zaretskii
2022-03-30 16:32 ` Tassilo Horn
2023-07-08 18:31 ` Jakub Ječmínek
2023-07-09 11:09 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87czi31p1l.fsf@gnu.org \
--to=tsdh@gnu.org \
--cc=54636@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=schwab@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.