unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tak Kunihiro <tkk@misasa.okayama-u.ac.jp>
To: eliz@gnu.org
Cc: 27435@debbugs.gnu.org, tkk@misasa.okayama-u.ac.jp
Subject: bug#27435: patch for dired-mouse-find-file-other-window
Date: Sat, 26 Aug 2017 18:26:58 +0900 (JST)	[thread overview]
Message-ID: <20170826.182658.1910804375178800263.tkk@misasa.okayama-u.ac.jp> (raw)
In-Reply-To: <83ziam698h.fsf@gnu.org>

Thank you for the response!

> Can you describe a use case where you need to customize the function
> used to visit a file from Dired?

On dired I use `RET', `o', and `C-o' on different occasions and I
prefer mouse click to work as `RET' instead of `C-o'.  This is
especially true when there are more than three windows in a frame.

The patch lets mouse click on dired visit a file or directory in
<this-window> not in <other-window> with following customization.

  (setq dired-mouse-find-file-func 'find-file)

> (Btw, we use "visit a file", not "open a file" in our terminology, so
> at least that aspect in the doc strings of your patch should be
> amended.)

I revised phrases from "open a file" to "visit a file".  I hope now
this patch is ready for consideration and applied.


# Change log

2017-08-26  Tak Kunihiro  <tkk@misasa.okayama-u.ac.jp>

        Let user specify function to visit a file or directory in dired using mouse-2

        * doc/emacs/dired.texi (Navigation): Document support of customizing functions to be used by mouse-2.
        * lisp/dired.el (dired-mouse-find-file-other-window): Visit a file or directory by `dired-mouse-find-file-func' or `dired-mouse-find-dir-func'.
    (dired-mouse-find-file-func): Specify function to visit a file on `dired-mouse-find-file-other-window'.
    (dired-mouse-find-dir-func): Specify function to visit a directory on `dired-mouse-find-file-other-window'.

# NEWS

** Use can specify function to visit a file or directory in dired using mouse click.
You can specify function to visit a file or directory by
'dired-mouse-find-file-func' and 'dired-mouse-find-dir-func'.

# Code

diff --git a/dired.252.el b/dired.el
index 39dc29e..8c21388 100644
--- a/dired.252.el
+++ b/dired.el
@@ -2117,8 +2117,20 @@ directory in another window."
 ;; Don't override the setting from .emacs.
 ;;;###autoload (put 'dired-find-alternate-file 'disabled t)

+(defcustom dired-mouse-find-file-func 'find-file-other-window
+  "Function to visit a file by `dired-mouse-find-file-other-window'."
+  :group 'mouse
+  :type 'function
+  :version "26.1")
+(defcustom dired-mouse-find-dir-func 'dired-other-window
+  "Function to visit a directory by `dired-mouse-find-file-other-window'."
+  :group 'mouse
+  :type 'function
+  :version "26.1")
 (defun dired-mouse-find-file-other-window (event)
-  "In Dired, visit the file or directory name you click on."
+  "In Dired, visit the file or directory name you click on.
+To visit the file or directory, this uses
+`dired-mouse-find-file-func' or `dired-mouse-find-dir-func'."
   (interactive "e")
   (let (window pos file)
     (save-excursion
@@ -2134,9 +2146,9 @@ directory in another window."
                 (dired-goto-subdir file))
            (progn
              (select-window window)
-             (dired-other-window file)))
+             (funcall dired-mouse-find-dir-func file)))
       (select-window window)
-      (find-file-other-window (file-name-sans-versions file t)))))
+      (funcall dired-mouse-find-file-func (file-name-sans-versions file t)))))

 (defun dired-view-file ()
   "In Dired, examine a file in view mode, returning to Dired when done.

# Info

diff --git a/dired.252.texi b/dired.texi
index 0e62a9e..323d350 100644
--- a/dired.252.texi
+++ b/dired.texi
@@ -358,7 +358,9 @@ another window, but do not select that window (@code{dired-display-file
 @findex dired-mouse-find-file-other-window
 Visit the file whose name you clicked on
 (@code{dired-mouse-find-file-other-window}).  This uses another window
-to display the file, like the @kbd{o} command.
+to display the file, like the @kbd{o} command.  You can change which
+window to display the file by customizing the variables
+@code{dired-mouse-find-file-func} and @code{dired-mouse-find-dir-func}.

 @item v
 @kindex v @r{(Dired)}





  reply	other threads:[~2017-08-26  9:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21  1:41 bug#27435: patch for dired-mouse-find-file-other-window Tak Kunihiro
2017-07-18  4:38 ` Tak Kunihiro
2017-08-26  6:27   ` Tak Kunihiro
2017-08-26  8:09     ` Eli Zaretskii
2017-08-26  9:26       ` Tak Kunihiro [this message]
2017-08-26 10:27         ` Eli Zaretskii
2017-08-27  9:02           ` Tak Kunihiro
2017-08-27 12:56             ` Drew Adams
2017-08-27 14:41             ` Eli Zaretskii
2017-08-28  0:22               ` Tak Kunihiro
2017-09-02 10:20                 ` Eli Zaretskii
2017-09-03  2:08                   ` Tak Kunihiro
2017-09-08  8:56                     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170826.182658.1910804375178800263.tkk@misasa.okayama-u.ac.jp \
    --to=tkk@misasa.okayama-u.ac.jp \
    --cc=27435@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).