* [PATCH] Dired: with prefix argument, open file in new window; and question about lexical scope
@ 2015-01-20 3:47 samer
2015-01-20 16:13 ` Eli Zaretskii
2015-01-20 17:28 ` Stefan Monnier
0 siblings, 2 replies; 3+ messages in thread
From: samer @ 2015-01-20 3:47 UTC (permalink / raw)
To: emacs-devel
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."
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Dired: with prefix argument, open file in new window; and question about lexical scope
2015-01-20 3:47 [PATCH] Dired: with prefix argument, open file in new window; and question about lexical scope samer
@ 2015-01-20 16:13 ` Eli Zaretskii
2015-01-20 17:28 ` Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2015-01-20 16:13 UTC (permalink / raw)
To: samer; +Cc: emacs-devel
> Date: Mon, 19 Jan 2015 19:47:21 -0800
> From: samer <samer@samertm.com>
>
> 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.
IMO, this goes against the "usual" way we derive "the other window"
commands -- via the "C-x 4" prefix. Besides, the numeric argument in
Dired is mostly used for very different purposes.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Dired: with prefix argument, open file in new window; and question about lexical scope
2015-01-20 3:47 [PATCH] Dired: with prefix argument, open file in new window; and question about lexical scope samer
2015-01-20 16:13 ` Eli Zaretskii
@ 2015-01-20 17:28 ` Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2015-01-20 17:28 UTC (permalink / raw)
To: samer; +Cc: emacs-devel
> 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?
find-file-run-dired is declared with `defcustom' which, like defvar,
declares it as a dynamically scoped variable, so yes it does have an
effect on `find-file'.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-20 17:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-20 3:47 [PATCH] Dired: with prefix argument, open file in new window; and question about lexical scope samer
2015-01-20 16:13 ` Eli Zaretskii
2015-01-20 17:28 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.