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.

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."
  (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))
      (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)))))