From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tak Kunihiro Newsgroups: gmane.emacs.bugs Subject: bug#27435: patch for dired-mouse-find-file-other-window Date: Sun, 03 Sep 2017 11:08:07 +0900 (JST) Message-ID: <20170903.110807.1522119241005954429.tkk@misasa.okayama-u.ac.jp> References: <83zial3wf9.fsf@gnu.org> <35B0B760-56DC-43A4-B6C9-B29A51CF4547@misasa.okayama-u.ac.jp> <834lsl1jxl.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1504404577 10423 195.159.176.226 (3 Sep 2017 02:09:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 3 Sep 2017 02:09:37 +0000 (UTC) Cc: 27435@debbugs.gnu.org, tkk@misasa.okayama-u.ac.jp To: eliz@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 03 04:09:19 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1doKLY-0001Q7-EP for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Sep 2017 04:09:12 +0200 Original-Received: from localhost ([::1]:53484 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doKLd-0006Jq-NM for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Sep 2017 22:09:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doKLT-0006Iw-FR for bug-gnu-emacs@gnu.org; Sat, 02 Sep 2017 22:09:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doKLO-0005Bm-Ba for bug-gnu-emacs@gnu.org; Sat, 02 Sep 2017 22:09:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35686) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1doKLO-0005BR-6x for bug-gnu-emacs@gnu.org; Sat, 02 Sep 2017 22:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1doKLN-0000hM-Pg for bug-gnu-emacs@gnu.org; Sat, 02 Sep 2017 22:09:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tak Kunihiro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Sep 2017 02:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27435 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 27435-submit@debbugs.gnu.org id=B27435.15044044982635 (code B ref 27435); Sun, 03 Sep 2017 02:09:01 +0000 Original-Received: (at 27435) by debbugs.gnu.org; 3 Sep 2017 02:08:18 +0000 Original-Received: from localhost ([127.0.0.1]:44367 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1doKKg-0000gQ-GJ for submit@debbugs.gnu.org; Sat, 02 Sep 2017 22:08:18 -0400 Original-Received: from mxl065v65.mxlogic.net ([208.81.65.65]:54752 helo=s14p02o142.mxlogic.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1doKKd-0000gH-Tg for 27435@debbugs.gnu.org; Sat, 02 Sep 2017 22:08:17 -0400 Original-Received: from unknown [42.127.236.175] (EHLO mlsec.cc.okayama-u.ac.jp) by s14p02o142.mxlogic.net(mxl_mta-8.5.0-1834) over TLS secured channel with ESMTP id c046ba95.0.190993.00-384.402612.s14p02o142.mxlogic.net (envelope-from ); Sat, 02 Sep 2017 20:08:13 -0600 (MDT) X-MXL-Hash: 59ab640d0a8ce7a8-9e55fbefc8785dbe66245b3773718e5f4892ba03 Original-Received: from alml002.ouadm.okayama-u.ac.jp (unknown [42.127.236.168]) by mlsec.cc.okayama-u.ac.jp with smtp id 16a4_2fbf_bdd134ea_1a3c_4821_9d44_260120400009; Sun, 03 Sep 2017 11:08:10 +0900 Original-Received: from localhost (p219225-ipngn200207tottori.tottori.ocn.ne.jp [153.182.218.225]) by alml002.ouadm.okayama-u.ac.jp (Postfix) with ESMTPSA id 8E8C84C08E6; Sun, 3 Sep 2017 11:08:10 +0900 (JST) In-Reply-To: <834lsl1jxl.fsf@gnu.org> X-Mailer: Mew version 6.7 on Emacs 25.2 / Mule 6.0 (HANACHIRUSATO) X-NAI-Spam-Flag: NO X-NAI-Spam-Level: ********** X-NAI-Spam-Threshold: 11 X-NAI-Spam-Score: 10.1 X-NAI-Spam-Rules: 6 Rules triggered TS_MSG_REP_80_512=10, RCVD_BAD_SIP=0.1, EDT_SA_AU_PASS=0, EDT_SA_DN_PASS=0, EDT_SA_TS_FAIL=0, RV6107=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6107> : inlines <6052> : streams <1761340> : uri <2494050> X-AnalysisOut: [v=2.2 cv=DI//22Fb c=1 sm=1 tr=0 a=8LLPK8U+aGQ6qN8QlyMYtQ==] X-AnalysisOut: [:117 a=8LLPK8U+aGQ6qN8QlyMYtQ==:17 a=kj9zAlcOel0A:10 a=2JC] X-AnalysisOut: [JgTwv5E4A:10 a=h9Prw4JL4Da9W-3YIaoA:9 a=CjuIK1q_8ugA:10] X-Spam: [F=0.5100000000; CM=0.500; MH=0.510(2017090212); S=0.200(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [42.127.236.175] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:136526 Archived-At: 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 `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 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.