]> git.eshelyaron.com Git - emacs.git/commitdiff
Make mouse clicks in Dired more customizable
authorTak Kunihiro <tkk@misasa.okayama-u.ac.jp>
Fri, 8 Sep 2017 08:52:47 +0000 (11:52 +0300)
committerEli Zaretskii <eliz@gnu.org>
Fri, 8 Sep 2017 08:52:47 +0000 (11:52 +0300)
* 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

index ff62183f091fbd34b1b8fb2d05b1b97e5174ad6e..052f9a521436ae50d50dca2fed8b9cb496929336 100644 (file)
@@ -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.