Skip to content

Commit

Permalink
Consider 'dired-kill-when-opening-new-dired-buffer' in mouse clicks
Browse files Browse the repository at this point in the history
* lisp/dired.el (dired-mouse-find-file): Honor the value of
'dired-kill-when-opening-new-dired-buffer'.  (Bug#64079)
  • Loading branch information
Eli-Zaretskii committed Jun 15, 2023
1 parent bafe71a commit 92faf1f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lisp/dired.el
Original file line number Diff line number Diff line change
Expand Up @@ -2765,17 +2765,24 @@ 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))
pos (posn-point (event-end event)))
(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)
Expand Down

0 comments on commit 92faf1f

Please sign in to comment.