unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#27435: patch for dired-mouse-find-file-other-window
@ 2017-06-21  1:41 Tak Kunihiro
  2017-07-18  4:38 ` Tak Kunihiro
  0 siblings, 1 reply; 13+ messages in thread
From: Tak Kunihiro @ 2017-06-21  1:41 UTC (permalink / raw)
  To: 27435; +Cc: tkk

For now, mouse click on dired displays file (or directory) in
other-window.  I am sending a patch to display file (or directory)
using specified functions.

# Change log

2017-05-20  Tak Kunihiro  <tkk@misasa.okayama-u.ac.jp>

        Let user specify function to open 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): Open file or directory by `dired-mouse-find-file-func' or `dired-mouse-find-dir-func'.
    (dired-mouse-find-file-func): Specify function to open file on `dired-mouse-find-file-other-window'.
    (dired-mouse-find-dir-func): Specify function to open directory on `dired-mouse-find-file-other-window'.

# NEWS

** Use can specify function to open file or directory in dired using mouse click.
You can specify function to open 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 open 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 open 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 open 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)}





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#27435: patch for dired-mouse-find-file-other-window
  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
  0 siblings, 1 reply; 13+ messages in thread
From: Tak Kunihiro @ 2017-07-18  4:38 UTC (permalink / raw)
  To: 27435; +Cc: tkk

Is the patch I sent 4 weeks ago NG?

From: Tak Kunihiro <tkk@misasa.okayama-u.ac.jp>
Subject: patch for dired-mouse-find-file-other-window
Date: Wed, 21 Jun 2017 10:41:00 +0900 (JST)

> For now, mouse click on dired displays file (or directory) in
> other-window.  I am sending a patch to display file (or directory)
> using specified functions.
> 
> # Change log
> 
> 2017-05-20  Tak Kunihiro  <tkk@misasa.okayama-u.ac.jp>
> 
>         Let user specify function to open 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): Open file or directory by `dired-mouse-find-file-func' or `dired-mouse-find-dir-func'.
>     (dired-mouse-find-file-func): Specify function to open file on `dired-mouse-find-file-other-window'.
>     (dired-mouse-find-dir-func): Specify function to open directory on `dired-mouse-find-file-other-window'.
> 
> # NEWS
> 
> ** Use can specify function to open file or directory in dired using mouse click.
> You can specify function to open 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 open 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 open 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 open 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)}





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27435: patch for dired-mouse-find-file-other-window
  2017-07-18  4:38 ` Tak Kunihiro
@ 2017-08-26  6:27   ` Tak Kunihiro
  2017-08-26  8:09     ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Tak Kunihiro @ 2017-08-26  6:27 UTC (permalink / raw)
  To: 27435; +Cc: tkk

I have sent a patch to let mouse click on dired to open file (or
directory) in this-window not in other-window, 8 weeks ago.  This
patch does not change default, and (I think) lets dired respond to
what non-expert expects, with following two local lines.

  (setq dired-mouse-find-dir-func (lambda (file) (interactive) (dired-find-alternate-file)))
  (setq dired-mouse-find-file-func 'find-file)

Please respond to the patch (including rejection).


> For now, mouse click on dired displays file (or directory) in
> other-window.  I am sending a patch to display file (or directory)
> using specified functions.
> 
> # Change log
> 
> 2017-05-20  Tak Kunihiro  <tkk@misasa.okayama-u.ac.jp>
> 
>         Let user specify function to open 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): Open file or directory by `dired-mouse-find-file-func' or `dired-mouse-find-dir-func'.
>     (dired-mouse-find-file-func): Specify function to open file on `dired-mouse-find-file-other-window'.
>     (dired-mouse-find-dir-func): Specify function to open directory on `dired-mouse-find-file-other-window'.
> 
> # NEWS
> 
> ** Use can specify function to open file or directory in dired using mouse click.
> You can specify function to open 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 open 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 open 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 open 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)}





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27435: patch for dired-mouse-find-file-other-window
  2017-08-26  6:27   ` Tak Kunihiro
@ 2017-08-26  8:09     ` Eli Zaretskii
  2017-08-26  9:26       ` Tak Kunihiro
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2017-08-26  8:09 UTC (permalink / raw)
  To: Tak Kunihiro; +Cc: 27435

> Date: Sat, 26 Aug 2017 15:27:47 +0900 (JST)
> From: Tak Kunihiro <tkk@misasa.okayama-u.ac.jp>
> Cc: tkk@misasa.okayama-u.ac.jp
> 
> I have sent a patch to let mouse click on dired to open file (or
> directory) in this-window not in other-window, 8 weeks ago.  This
> patch does not change default, and (I think) lets dired respond to
> what non-expert expects, with following two local lines.
> 
>   (setq dired-mouse-find-dir-func (lambda (file) (interactive) (dired-find-alternate-file)))
>   (setq dired-mouse-find-file-func 'find-file)
> 
> Please respond to the patch (including rejection).

It is "wishlist" bug report, so lack of response generally means
there's not much interest in the proposal.

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

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

Thanks.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27435: patch for dired-mouse-find-file-other-window
  2017-08-26  8:09     ` Eli Zaretskii
@ 2017-08-26  9:26       ` Tak Kunihiro
  2017-08-26 10:27         ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Tak Kunihiro @ 2017-08-26  9:26 UTC (permalink / raw)
  To: eliz; +Cc: 27435, tkk

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)}





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#27435: patch for dired-mouse-find-file-other-window
  2017-08-26  9:26       ` Tak Kunihiro
@ 2017-08-26 10:27         ` Eli Zaretskii
  2017-08-27  9:02           ` Tak Kunihiro
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2017-08-26 10:27 UTC (permalink / raw)
  To: Tak Kunihiro; +Cc: 27435

> Date: Sat, 26 Aug 2017 18:26:58 +0900 (JST)
> Cc: 27435@debbugs.gnu.org, tkk@misasa.okayama-u.ac.jp
> From: Tak Kunihiro <tkk@misasa.okayama-u.ac.jp>
> 
> > 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)

But you could have the same effect by rebinding mouse-2 to another
function.  We just need to add such a function, which should work like
dired-mouse-find-file-other-window, but visit the file in the same
window.  That sounds like a better alternative for this use case,
because customizing a function-valued variable is trickier for users
than rebinding keys.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27435: patch for dired-mouse-find-file-other-window
  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
  0 siblings, 2 replies; 13+ messages in thread
From: Tak Kunihiro @ 2017-08-27  9:02 UTC (permalink / raw)
  To: eliz; +Cc: 27435, tkk

>> 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)
> 
> But you could have the same effect by rebinding mouse-2 to another
> function.  We just need to add such a function, which should work like
> dired-mouse-find-file-other-window, but visit the file in the same
> window.  That sounds like a better alternative for this use case,
> because customizing a function-valued variable is trickier for users
> than rebinding keys.

I agree.

Then the new function `dired-mouse-find-file-this-window' will look
very similar to `dired-mouse-find-file-other-window' but two lines.
Is that OK?





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27435: patch for dired-mouse-find-file-other-window
  2017-08-27  9:02           ` Tak Kunihiro
@ 2017-08-27 12:56             ` Drew Adams
  2017-08-27 14:41             ` Eli Zaretskii
  1 sibling, 0 replies; 13+ messages in thread
From: Drew Adams @ 2017-08-27 12:56 UTC (permalink / raw)
  To: Tak Kunihiro, eliz; +Cc: 27435

> Then the new function `dired-mouse-find-file-this-window' will look
> very similar to `dired-mouse-find-file-other-window' but two lines.
> Is that OK?

FWIW: Conventionally, we add `-other-window' or `-other-frame'
to the same-window command name, which lacks any such suffix.
IOW, typically we do not use `-this-window'.

FWIW2: Dired+ has had such a same-window mouse command since
1999 (if not before).  There is also an `-other-frame' version.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27435: patch for dired-mouse-find-file-other-window
  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
  1 sibling, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2017-08-27 14:41 UTC (permalink / raw)
  To: Tak Kunihiro; +Cc: 27435

> Date: Sun, 27 Aug 2017 18:02:43 +0900 (JST)
> Cc: 27435@debbugs.gnu.org, tkk@misasa.okayama-u.ac.jp
> From: Tak Kunihiro <tkk@misasa.okayama-u.ac.jp>
> 
> > But you could have the same effect by rebinding mouse-2 to another
> > function.  We just need to add such a function, which should work like
> > dired-mouse-find-file-other-window, but visit the file in the same
> > window.  That sounds like a better alternative for this use case,
> > because customizing a function-valued variable is trickier for users
> > than rebinding keys.
> 
> I agree.
> 
> Then the new function `dired-mouse-find-file-this-window' will look
> very similar to `dired-mouse-find-file-other-window' but two lines.
> Is that OK?

We could factor out the common part into a new function, and then make
those two functions call it.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27435: patch for dired-mouse-find-file-other-window
  2017-08-27 14:41             ` Eli Zaretskii
@ 2017-08-28  0:22               ` Tak Kunihiro
  2017-09-02 10:20                 ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Tak Kunihiro @ 2017-08-28  0:22 UTC (permalink / raw)
  To: drew.adams, Eli Zaretskii; +Cc: 27435, 国広卓也

Thank you for the comments.

>>> But you could have the same effect by rebinding mouse-2 to another
>>> function.  We just need to add such a function, which should work like
>>> dired-mouse-find-file-other-window, but visit the file in the same
>>> window.  That sounds like a better alternative for this use case,
>>> because customizing a function-valued variable is trickier for users
>>> than rebinding keys.
>> 
>> Then the new function `dired-mouse-find-file-this-window' will look
>> very similar to `dired-mouse-find-file-other-window' but two lines.
>> Is that OK?
> 
> We could factor out the common part into a new function, and then make
> those two functions call it.

> FWIW: Conventionally, we add `-other-window' or `-other-frame'

> to the same-window command name, which lacks any such suffix.
> IOW, typically we do not use `-this-window'.
> 
> FWIW2: Dired+ has had such a same-window mouse command since
> 1999 (if not before).  There is also an `-other-frame' version.


With the suggestions, I created two functions.

 - dired-mouse-find-file (new, this inherits common part)
 - dired-mouse-find-file-other-window
 - dired-mouse-find-file-other-frame (new)

I attach the patch.  This does not change the default behavior.

diff --git a/dired.252.el b/dired.el
index 39dc29e..3a4bbce 100644
--- a/dired.252.el
+++ b/dired.el
@@ -2117,9 +2117,12 @@ 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.
+FIND-FILE-FUNC and FIND-DIR-FUNC specify functions to visit the file and directory, respectively."
   (interactive "e")
+  (or find-file-func (setq find-file-func 'find-file))
+  (or find-dir-func (setq find-file-func 'find-alternate-file))
   (let (window pos file)
     (save-excursion
       (setq window (posn-window (event-end event))
@@ -2134,9 +2137,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 other 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 other 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.






^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#27435: patch for dired-mouse-find-file-other-window
  2017-08-28  0:22               ` Tak Kunihiro
@ 2017-09-02 10:20                 ` Eli Zaretskii
  2017-09-03  2:08                   ` Tak Kunihiro
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2017-09-02 10:20 UTC (permalink / raw)
  To: Tak Kunihiro; +Cc: 27435

> From: Tak Kunihiro <tkk@misasa.okayama-u.ac.jp>
> Date: Mon, 28 Aug 2017 09:22:35 +0900
> Cc: 国広卓也 <tkk@misasa.okayama-u.ac.jp>,
>  27435@debbugs.gnu.org
> 
> With the suggestions, I created two functions.
> 
>  - dired-mouse-find-file (new, this inherits common part)
>  - dired-mouse-find-file-other-window
>  - dired-mouse-find-file-other-frame (new)
> 
> I attach the patch.  This does not change the default behavior.

Thanks.  Some minor comments:

> +(defun dired-mouse-find-file (event &optional find-file-func find-dir-func)
> +  "In Dired, visit the file or directory name you click on.
> +FIND-FILE-FUNC and FIND-DIR-FUNC specify functions to visit the file and directory, respectively."

This last line is too long, please break it into 2.  Also, the doc
string should say explicitly these arguments are optional, and what
they default to if omitted or nil.

> +  (or find-file-func (setq find-file-func 'find-file))
> +  (or find-dir-func (setq find-file-func 'find-alternate-file))

I'm not sure I understand why these particular defaults.  Can you
explain?  In particular, find-alternate-file sounds strange to me.

Finally, 2 nits:

  . please always provide a log message for the changes
  . your patch doesn't apply cleanly, presumably due to some
    difference in whitespace vs the Git repository; please make sure
    your diffs are always against the latest Git version

Thanks.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27435: patch for dired-mouse-find-file-other-window
  2017-09-02 10:20                 ` Eli Zaretskii
@ 2017-09-03  2:08                   ` Tak Kunihiro
  2017-09-08  8:56                     ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Tak Kunihiro @ 2017-09-03  2:08 UTC (permalink / raw)
  To: eliz; +Cc: 27435, tkk

Thank you for the response.

>> +(defun dired-mouse-find-file (event &optional find-file-func find-dir-func)
>> +  "In Dired, visit the file or directory name you click on.
>> +FIND-FILE-FUNC and FIND-DIR-FUNC specify functions to visit the file and directory, respectively."
> 
> This last line is too long, please break it into 2.  Also, the doc
> string should say explicitly these arguments are optional, and what
> they default to if omitted or nil.

I separated the line into two.  I revised the doc string to infer
option and default explicitly.  Please modify it if unclear.

>> +  (or find-file-func (setq find-file-func 'find-file))
>> +  (or find-dir-func (setq find-file-func 'find-alternate-file))
> 
> I'm not sure I understand why these particular defaults.  Can you
> explain?  In particular, find-alternate-file sounds strange to me.

I think `dired-mouse-find-file' should behave similar to <RET>
`dired-find-file'.  For visiting a file in this window, the most
similar function to `dired-find-file' with similar argument to
`find-file-other-window' is `find-file'.  For visiting a directory in
this window, the most similar function to `dired-find-file' with
similar argument to `dired-other-window' is `dired'.  Also there was a
typo.  On summary, current defaults are shown below.

    (or find-file-func (setq find-file-func 'find-file))
    (or find-dir-func (setq find-dir-func 'dired))

>   . please always provide a log message for the changes
>   . your patch doesn't apply cleanly, presumably due to some
>     difference in whitespace vs the Git repository; please make sure
>     your diffs are always against the latest Git version

I attach Change Log and a patch relative to the latest Git version.

I hope this meets your comments!


# Change log

2017-09-03  Tak Kunihiro  <tkk@misasa.okayama-u.ac.jp>

	Let mouse-2 on Dired visit a file or directory in this window, other window, and other frame

	* lisp/dired.el (dired-mouse-find-file): Visit a file or directory by this
	window.  User can specify functions to visit a file or directory, respectively.
	(dired-mouse-find-file-other-window): Visit a file or directory in other window.
	(dired-mouse-find-file-other-frame): Visit a file or directory in other frame.

# PATCH

diff --git a/dired.260.el b/dired.el
index ff62183..da5ad0e 100755
--- a/dired.260.el
+++ b/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.  By
+default, the file and directry are visited by `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 other 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 other 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.





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#27435: patch for dired-mouse-find-file-other-window
  2017-09-03  2:08                   ` Tak Kunihiro
@ 2017-09-08  8:56                     ` Eli Zaretskii
  0 siblings, 0 replies; 13+ messages in thread
From: Eli Zaretskii @ 2017-09-08  8:56 UTC (permalink / raw)
  To: Tak Kunihiro; +Cc: 27435-done

> Date: Sun, 03 Sep 2017 11:08:07 +0900 (JST)
> Cc: drew.adams@oracle.com, 27435@debbugs.gnu.org, tkk@misasa.okayama-u.ac.jp
> From: Tak Kunihiro <tkk@misasa.okayama-u.ac.jp>
> 
> I attach Change Log and a patch relative to the latest Git version.
> 
> I hope this meets your comments!

Thanks, pushed.  One more nit: please always mention the bug number in
the log message.  (I added the missing reference this time.)





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-09-08  8:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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