From: Eli Zaretskii Date: Thu, 15 Jun 2023 13:12:24 +0000 (+0300) Subject: Consider 'dired-kill-when-opening-new-dired-buffer' in mouse clicks X-Git-Tag: emacs-29.0.92~17 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=92faf1f5645c6a38e2cfc71f6fdc008f23a3b4e6;p=emacs.git Consider 'dired-kill-when-opening-new-dired-buffer' in mouse clicks * lisp/dired.el (dired-mouse-find-file): Honor the value of 'dired-kill-when-opening-new-dired-buffer'. (Bug#64079) --- diff --git a/lisp/dired.el b/lisp/dired.el index 4a4ecc901c4..de875302793 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2765,10 +2765,11 @@ This kills the Dired buffer, then visits the current line's file or directory." 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 @@ respectively." (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)