[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Dired: with prefix argument, open file in new window; and questi

From: samer
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
User-agent: Roundcube Webmail/0.9.5


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.



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  <address@hidden>
+       * dired.el (dired-find-file): Open file in other window when given
+       prefix argument.
 2014-12-28  Samer Masterson  <address@hidden>

        * 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."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]