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: Mon, 28 Aug 2017 09:22:35 +0900 Message-ID: <35B0B760-56DC-43A4-B6C9-B29A51CF4547@misasa.okayama-u.ac.jp> References: <83ziam698h.fsf@gnu.org> <20170826.182658.1910804375178800263.tkk@misasa.okayama-u.ac.jp> <83o9r262uc.fsf@gnu.org> <20170827.180243.351755072000785818.tkk@misasa.okayama-u.ac.jp> <83zial3wf9.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1503879793 23118 195.159.176.226 (28 Aug 2017 00:23:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 28 Aug 2017 00:23:13 +0000 (UTC) Cc: 27435@debbugs.gnu.org, =?UTF-8?Q?=E5=9B=BD=E5=BA=83=E5=8D=93=E4=B9=9F?= To: drew.adams@oracle.com, Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 28 02:23:09 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 1dm7pV-0005Ph-C9 for geb-bug-gnu-emacs@m.gmane.org; Mon, 28 Aug 2017 02:23:01 +0200 Original-Received: from localhost ([::1]:36188 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dm7pc-0006lc-Ae for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Aug 2017 20:23:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dm7pX-0006lF-8p for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2017 20:23:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dm7pW-0005pD-7U for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2017 20:23:03 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:49752) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dm7pW-0005p9-3U for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2017 20:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dm7pV-0007rm-TC for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2017 20:23: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: Mon, 28 Aug 2017 00:23: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.150387977430224 (code B ref 27435); Mon, 28 Aug 2017 00:23:01 +0000 Original-Received: (at 27435) by debbugs.gnu.org; 28 Aug 2017 00:22:54 +0000 Original-Received: from localhost ([127.0.0.1]:58433 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dm7pN-0007rQ-OO for submit@debbugs.gnu.org; Sun, 27 Aug 2017 20:22:53 -0400 Original-Received: from mxl069v66.mxlogic.net ([208.81.69.66]:43586 helo=s18p02o143.mxlogic.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dm7pL-0007rH-Uq for 27435@debbugs.gnu.org; Sun, 27 Aug 2017 20:22:53 -0400 Original-Received: from unknown [42.127.236.175] (EHLO mlsec.cc.okayama-u.ac.jp) by s18p02o143.mxlogic.net(mxl_mta-8.5.0-1834) over TLS secured channel with ESMTP id 45263a95.0.161831.00-394.312981.s18p02o143.mxlogic.net (envelope-from ); Sun, 27 Aug 2017 18:22:47 -0600 (MDT) X-MXL-Hash: 59a3625710e26df2-936187df2e3158d914b040c91f4182d44b5a1242 Original-Received: from alml002.ouadm.okayama-u.ac.jp (unknown [42.127.236.168]) by mlsec.cc.okayama-u.ac.jp with smtp id 337d_8145_c5c6f2fc_5341_4e9e_a122_ac9cf6c8f5ad; Mon, 28 Aug 2017 09:22:38 +0900 Original-Received: from [192.168.43.59] (p1395043-omed01.osaka.ocn.ne.jp [153.249.98.42]) by alml002.ouadm.okayama-u.ac.jp (Postfix) with ESMTPSA id 827594C0A3B; Mon, 28 Aug 2017 09:22:38 +0900 (JST) In-Reply-To: <83zial3wf9.fsf@gnu.org> X-Mailer: Apple Mail (2.1878.6) X-NAI-Spam-Flag: NO X-NAI-Spam-Level: X-NAI-Spam-Threshold: 11 X-NAI-Spam-Score: 0.1 X-NAI-Spam-Rules: 5 Rules triggered GME_TWTRE=0.1, EDT_SA_AU_PASS=0, EDT_SA_DN_PASS=0, EDT_SA_TS_PASS=0, RV6102=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6102> : inlines <6038> : streams <1760470> : uri <2490795> X-AnalysisOut: [v=2.2 cv=E6K9neVl c=1 sm=1 tr=0 a=8LLPK8U+aGQ6qN8QlyMYtQ==] X-AnalysisOut: [:117 a=8LLPK8U+aGQ6qN8QlyMYtQ==:17 a=kj9zAlcOel0A:10 a=KeK] X-AnalysisOut: [AF7QvOSUA:10 a=B833973xqv_B6eUtGUEA:9 a=CjuIK1q_8ugA:10] X-Spam: [F=0.5100000000; CM=0.500; MH=0.510(2017082707); 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:136282 Archived-At: 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. >>=20 >> 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? >=20 > 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'. >=20 > 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) =20 -(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)) =20 (defun dired-view-file () "In Dired, examine a file in view mode, returning to Dired when done.