

(For more details, see the manual.)Ĭonsequently, if you want to specify what happens when you left-click on the link, but not elsewhere, you slightly perversely have to change the binding of mouse-2. This means that when you left-click on the link ( but not elsewhere), emacs "translates" your left-click to a middle-click ( mouse-2). In the dired-mode-map, the "key sequence" is bound to mouse-face. The reason why we're binding mouse-2 rather than mouse-1, even to specify the action taken when you click on the link with the left mouse button ( mouse-1) is slightly complicated.ĭired specifies (via dired-insert-set-properties) that in the dired buffer, the name of the file or folder (as opposed to the displayed permissions, name of the owner and other metadata) is a link.
#Emacs dired code#
(For license purposes, the code is under GPLv3+, not under CC BY-SA!) Explanation (funcall find-file-func (file-name-sans-versions file t)))))) (setq window (posn-window (event-end event)) (or find-dir-func (setq find-dir-func 'dired)) Share Improve this answer Follow answered at 12:22 Robin Green 31. For a dired buffer, its current directory is simply the directory you are looking at. This will prompt for a filename, using the current directory of the current buffer as the directory to put it in. (or find-file-func (setq find-file-func 'find-file)) 6 Answers Sorted by: 62 Just press C-x C-f. Omitted or nil, these arguments default to `find-file' and `dired', The customized options apply to newly created dired buffers. You can customize the hidden fields by M-x customize-option RET diredTZA-invisible-props RET. The optional arguments FIND-FILE-FUNC and FIND-DIR-FUNC specifyįunctions to visit the file and directory, respectively. Usage After pasting the code into your init file and re-starting emacs it should already work. "In Dired, visit the file or directory name you click on. (defun dired-mouse-find-file (event &optional find-file-func find-dir-func)
#Emacs dired upgrade#
I've taken the function from here and wrapped it in a check for the version of Emacs, so that if you upgrade to a later Emacs and the definition of the function changes, the stale definition doesn't override the new one. I've tested with Emacs 24.5, and it works.

If you're using Emacs 24 or 25, you'll need to copy the definition of the function, from the Emacs sources (or from this answer - I've copied the definition below, for completeness) into you init.el. (The default binding is dired-mouse-find-file-other-window.) If you're using Emacs 26 or later (unlike what is specified in the question.), you can just use: (define-key dired-mode-map 'dired-mouse-find-file)
