From: Fadi Moukayed <smfadi@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 64079@debbugs.gnu.org
Subject: bug#64079: 28.2; dired-mouse-find-file does not respect dired-kill-when-opening-new-dired-buffer
Date: Thu, 15 Jun 2023 13:10:25 +0200 [thread overview]
Message-ID: <CAG_cVu-zeU4zfj6zek3ZbSUr5D-Dw20oWMYOGz1nhUbkaS3D3Q@mail.gmail.com> (raw)
In-Reply-To: <83h6r9t302.fsf@gnu.org>
Hi Eli,
Thanks a lot. Just tested your patch a few moments ago (with
dired-kill-when-opening-new-dired-bufferset to t) and it fixes the issue.
I also tested the default behavior (with
dired-kill-when-opening-new-dired-buffer
set to nil), and everything works as expected in that case as well.
Cheers.
Am Do., 15. Juni 2023 um 12:48 Uhr schrieb Eli Zaretskii <eliz@gnu.org>:
>
> > From: Fadi Moukayed <smfadi@gmail.com>
> > Date: Thu, 15 Jun 2023 10:54:27 +0200
> >
> > 1. Start Emacs
> > 2. Open a `dired' buffer, e.g. using C-x d
> > 3. Use M-: and evaluate the expression `(define-key dired-mode-map [mouse-3]
> > 'dired-mouse-find-file)'
> > 4. Navigate a nested directory tree (e.g. a/b/c/d) in dired by right-clicking
> > on the directory names.
> >
> > Expected behavior:
> >
> > Only a dired buffer for d is retained.
> >
> > Observed behavior:
> >
> > dired buffers a, b, c are created and retained in addition to d.
> >
> > Hints:
> >
> > `dired-mouse-find-file' needs to contain similar logic to
> > `dired--find-possibly-alternative-file' for checking the customization
> > variable, or needs to delegate to the latter function.
>
> Thanks. Does the patch below give good results?
>
> diff --git a/lisp/dired.el b/lisp/dired.el
> index 4a4ecc9..de87530 100644
> --- a/lisp/dired.el
> +++ b/lisp/dired.el
> @@ -2765,10 +2765,11 @@ dired-mouse-find-file
> The optional arguments FIND-FILE-FUNC and FIND-DIR-FUNC specify
> functions to visit the file and directory, respectively. If
> omitted or nil, these arguments default to `find-file' and `dired',
> -respectively."
> +respectively. If `dired-kill-when-opening-new-dired-buffer' is
> +non-nil, FIND-DIR-FUNC defaults to `find-alternate-file' instead,
> +so that the original Dired buffer is not kept."
> (interactive "e")
> (or find-file-func (setq find-file-func 'find-file))
> - (or find-dir-func (setq find-dir-func 'dired))
> (let (window pos file)
> (save-excursion
> (setq window (posn-window (event-end event))
> @@ -2776,6 +2777,12 @@ dired-mouse-find-file
> (if (not (windowp window))
> (error "No file chosen"))
> (set-buffer (window-buffer window))
> + (unless find-dir-func
> + (setq find-dir-func
> + (if (and dired-kill-when-opening-new-dired-buffer
> + (< (length (get-buffer-window-list)) 2))
> + 'find-alternate-file
> + 'dired)))
> (goto-char pos)
> (setq file (dired-get-file-for-visit)))
> (if (file-directory-p file)
next prev parent reply other threads:[~2023-06-15 11:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-15 8:54 bug#64079: 28.2; dired-mouse-find-file does not respect dired-kill-when-opening-new-dired-buffer Fadi Moukayed
2023-06-15 10:48 ` Eli Zaretskii
2023-06-15 11:10 ` Fadi Moukayed [this message]
2023-06-15 13:14 ` 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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAG_cVu-zeU4zfj6zek3ZbSUr5D-Dw20oWMYOGz1nhUbkaS3D3Q@mail.gmail.com \
--to=smfadi@gmail.com \
--cc=64079@debbugs.gnu.org \
--cc=eliz@gnu.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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).