From: Jared Finder via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 67856@debbugs.gnu.org
Subject: bug#67856: Dired navigation via directory line does not respect dired-kill-when-opening-new-dired-buffer
Date: Sun, 24 Dec 2023 12:11:49 -0800 [thread overview]
Message-ID: <9b86ffe265056857ab5ada6870451f84@finder.org> (raw)
In-Reply-To: <83sf3vg0df.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1720 bytes --]
On 2023-12-21 05:18, Eli Zaretskii wrote:
>> Date: Sat, 16 Dec 2023 12:35:10 -0800
>> From: Jared Finder via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>>
>> The option dired-kill-when-opening-new-dired-buffer is not respected
>> when clicking on parent directories in the directory line at the top
>> of dired buffers. This can be fixed by calling
>> dired--find-possibly-alternate-file instead of dired in the
>> callback, as my attached patch does.
>>
>> I believe changing to dired--find-possibly-alternate-file is safe
>> because from playing around with dired, the directory being clicked
>> on must be a directory and can not contain wildcards at this point.
>> Therefore, at this point it is known that the directory is just a
>> plain directory (no wildcards) and so going through find-file
>> machinery will have the intended result.
>
> If we want to install this on the emacs-29 release branch, I'd prefer
> a safer variant, which actually verified that we don't call
> dired--find-possibly-alternate-file with a wildcard. That's because
> we have quite a few features that place buffers in Dired mode, and we
> could easily miss one that does have wildcards there.
>
> So would you mind modifying the patch a little so that it checks
> whether current-dir includes wildcards, and if so, calls 'dired'
> instead of dired--find-possibly-alternate-file?
Done, new patch attached. Luckily, there already is a function that
does exactly the right check.
Feel free to alter the comment explaining why this third code path
exists. I wasn't sure the right style to indicate this type of
defensive code path that I am not certain is needed.
-- MJF
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Clicks-on-directory-line-kill-prev-buffer-if-option-.patch --]
[-- Type: text/x-diff; name=0001-Clicks-on-directory-line-kill-prev-buffer-if-option-.patch, Size: 2131 bytes --]
From 30ad2b8acef36a3ab14f045bca94d7987ecd96e8 Mon Sep 17 00:00:00 2001
From: Jared Finder <jared@finder.org>
Date: Sat, 16 Dec 2023 12:10:03 -0800
Subject: [PATCH] Clicks on directory line kill prev buffer if option is set
The option dired-kill-when-opening-new-dired-buffer should be checked
in this code path as well.
* lisp/dired.el (dired--make-directory-clickable): Call
dired--find-possibly-alternative-file instead of dired in click
callback.
---
lisp/dired.el | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/lisp/dired.el b/lisp/dired.el
index 33e38ed2c1c..fc91b58ecad 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2010,9 +2010,18 @@ dired--make-directory-clickable
keymap ,(let* ((current-dir dir)
(click (lambda ()
(interactive)
- (if (assoc current-dir dired-subdir-alist)
- (dired-goto-subdir current-dir)
- (dired current-dir)))))
+ (cond
+ ((assoc current-dir dired-subdir-alist)
+ (dired-goto-subdir current-dir))
+ ;; If there is a wildcard character in the directory, don't
+ ;; use the alternate file machinery which tries to keep only
+ ;; one dired buffer open at once.
+ ;;
+ ;; FIXME: Is this code path reachable?
+ ((insert-directory-wildcard-in-dir-p current-dir)
+ (dired current-dir))
+ (t
+ (dired--find-possibly-alternative-file current-dir))))))
(define-keymap
"<mouse-2>" click
"<follow-link>" 'mouse-face
--
2.39.2
next prev parent reply other threads:[~2023-12-24 20:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-16 20:35 bug#67856: Dired navigation via directory line does not respect dired-kill-when-opening-new-dired-buffer Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-21 13:18 ` Eli Zaretskii
2023-12-24 20:11 ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-12-25 13:08 ` 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=9b86ffe265056857ab5ada6870451f84@finder.org \
--to=bug-gnu-emacs@gnu.org \
--cc=67856@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=jared@finder.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.