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: Sun, 03 Sep 2017 11:08:07 +0900 (JST)	[thread overview]
Message-ID: <20170903.110807.1522119241005954429.tkk@misasa.okayama-u.ac.jp> (raw)
In-Reply-To: <834lsl1jxl.fsf@gnu.org>

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.





  reply	other threads:[~2017-09-03  2:08 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
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 [this message]
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=20170903.110807.1522119241005954429.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).