From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: samer Newsgroups: gmane.emacs.devel Subject: [PATCH] Dired: with prefix argument, open file in new window; and question about lexical scope Date: Mon, 19 Jan 2015 19:47:21 -0800 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1421725697 27935 80.91.229.3 (20 Jan 2015 03:48:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 20 Jan 2015 03:48:17 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jan 20 04:48:12 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YDPnY-0002s6-7X for ged-emacs-devel@m.gmane.org; Tue, 20 Jan 2015 04:48:12 +0100 Original-Received: from localhost ([::1]:41337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDPnX-0003I7-Hm for ged-emacs-devel@m.gmane.org; Mon, 19 Jan 2015 22:48:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDPnU-0003Hc-56 for emacs-devel@gnu.org; Mon, 19 Jan 2015 22:48:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDPnQ-0000tR-S5 for emacs-devel@gnu.org; Mon, 19 Jan 2015 22:48:08 -0500 Original-Received: from samertm.com ([162.243.37.26]:45061 helo=mail.samertm.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDPnQ-0000au-OF for emacs-devel@gnu.org; Mon, 19 Jan 2015 22:48:04 -0500 Original-Received: by mail.samertm.com (Postfix, from userid 1010) id CC29B81E6B; Tue, 20 Jan 2015 03:47:32 +0000 (UTC) Original-Received: from samertm.com (localhost [127.0.0.1]) by mail.samertm.com (Postfix) with ESMTP id 8644780A2A for ; Tue, 20 Jan 2015 03:47:21 +0000 (UTC) X-Sender: samer@samertm.com User-Agent: Roundcube Webmail/0.9.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 162.243.37.26 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:181462 Archived-At: Hi, In magit, opens a file in the current window, and C-u opens the file in a new window for the thing under the point. I think this is really useful pattern, and I've included a patch that brings this behavior to dired. My papers haven't finished being processed, but once they are, it would be cool to have this merged in. I also have a question about lexical scoping: dired.el is marked as lexically scoped, but you can see that it tries to pass `find-file-run-dired' as true to `find-file' dynamically. That has no effect on `find-file', right? If so, that line should be removed before this patch is installed. -samer patch: 3 files changed, 17 insertions(+), 4 deletions(-) etc/NEWS | 5 +++++ lisp/ChangeLog | 5 +++++ lisp/dired.el | 11 +++++++---- Modified etc/NEWS diff --git a/etc/NEWS b/etc/NEWS index 4d63278..841a982 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -224,6 +224,11 @@ typing RET. *** If `quick-calc' is called with a prefix argument, insert the result of the calculation into the current buffer. +** Dired + +*** When `dired-find-file' is called with a prefix argument, the file +under the point is opened in a new window. + ** ElDoc *** New minor mode global-eldoc-mode *** eldoc-documentation-function now defaults to nil Modified lisp/ChangeLog diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5bd192d..cbcc822 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2015-01-19 Samer Masterson + + * dired.el (dired-find-file): Open file in other window when given + prefix argument. + 2014-12-28 Samer Masterson * pcomplete.el (pcomplete-parse-arguments, pcomplete-stub): Delay Modified lisp/dired.el diff --git a/lisp/dired.el b/lisp/dired.el index 7f7251f..c936246 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2093,13 +2093,16 @@ directory in another window." ;; Force C-m keybinding rather than `f' or `e' in the mode doc: (define-obsolete-function-alias 'dired-advertised-find-file 'dired-find-file "23.2") -(defun dired-find-file () - "In Dired, visit the file or directory named on this line." - (interactive) +(defun dired-find-file (&optional other-window) + "In Dired, visit the file or directory named on this line. +With a prefix argument, visit in other window." + (interactive "P") ;; Bind `find-file-run-dired' so that the command works on directories ;; too, independent of the user's setting. (let ((find-file-run-dired t)) - (find-file (dired-get-file-for-visit)))) + (if other-window + (find-file-other-window (dired-get-file-for-visit)) + (find-file (dired-get-file-for-visit))))) (defun dired-find-alternate-file () "In Dired, visit this file or directory instead of the Dired buffer."