Function: dired-mouse-find-file
dired-mouse-find-file is an interactive and byte-compiled function
defined in dired.el.gz.
Signature
(dired-mouse-find-file EVENT &optional FIND-FILE-FUNC FIND-DIR-FUNC)
Documentation
In Dired, visit the file or directory name you click on.
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. 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.
Probably introduced at or before Emacs version 26.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/dired.el.gz
;; Don't override the setting from .emacs.
;;;###autoload (put 'dired-find-alternate-file 'disabled t)
(defun dired-mouse-find-file (event &optional find-file-func find-dir-func)
"In Dired, visit the file or directory name you click on.
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. 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))
(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)
(or (and (cdr dired-subdir-alist)
(dired-goto-subdir file))
(progn
(select-window window)
(funcall find-dir-func file)))
(select-window window)
(dired--find-file find-file-func (file-name-sans-versions file t)))))