From: samer <samer@samertm.com>
To: emacs-devel@gnu.org
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 [thread overview]
Message-ID: <d589707abd042f722d794df1dd28e923@samertm.com> (raw)
Hi,
In magit, <enter> opens a file in the current window, and C-u <enter>
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 <samer@samertm.com>
+
+ * dired.el (dired-find-file): Open file in other window when given
+ prefix argument.
+
2014-12-28 Samer Masterson <samer@samertm.com>
* 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."
next reply other threads:[~2015-01-20 3:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-20 3:47 samer [this message]
2015-01-20 16:13 ` [PATCH] Dired: with prefix argument, open file in new window; and question about lexical scope Eli Zaretskii
2015-01-20 17:28 ` Stefan Monnier
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=d589707abd042f722d794df1dd28e923@samertm.com \
--to=samer@samertm.com \
--cc=emacs-devel@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).