From 41eb4c518a79050b85add25bf67992e21fa3cd16 Mon Sep 17 00:00:00 2001 From: Tak Kunihiro Date: Fri, 8 Sep 2017 11:52:47 +0300 Subject: [PATCH] Make mouse clicks in Dired more customizable * lisp/dired.el (dired-mouse-find-file): Allow callers to specify functions to visit file/directory. (dired-mouse-find-file-other-window) (dired-mouse-find-file-other-frame): New functions to visit files in another window/frame. (Bug#27435) --- lisp/dired.el | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lisp/dired.el b/lisp/dired.el index ff62183f091..052f9a52143 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2233,9 +2233,15 @@ directory in another window." ;; Don't override the setting from .emacs. ;;;###autoload (put 'dired-find-alternate-file 'disabled t) -(defun dired-mouse-find-file-other-window (event) - "In Dired, visit the file or directory name you click on." +(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)) @@ -2250,9 +2256,19 @@ directory in another window." (dired-goto-subdir file)) (progn (select-window window) - (dired-other-window file))) + (funcall find-dir-func file))) (select-window window) - (find-file-other-window (file-name-sans-versions file t))))) + (funcall find-file-func (file-name-sans-versions file t))))) + +(defun dired-mouse-find-file-other-window (event) + "In Dired, visit the file or directory name you click on in another window." + (interactive "e") + (dired-mouse-find-file event 'find-file-other-window 'dired-other-window)) + +(defun dired-mouse-find-file-other-frame (event) + "In Dired, visit the file or directory name you click on in another frame." + (interactive "e") + (dired-mouse-find-file event 'find-file-other-frame 'dired-other-frame)) (defun dired-view-file () "In Dired, examine a file in view mode, returning to Dired when done. -- 2.39.2