Skip to contentSkip to conversation

git.el: Added a function to open the current file in another window.

PATCH New Alexandre Julliard 1 participant 1 message Aug 11, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 2/4 git.el: Added a function to open the current file in another window.

Bound to 'o' by default, compatible with pcl-cvs and buffer-mode. Suggested by Han-Wen Nienhuys.

---
 contrib/emacs/git.el |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
contrib/emacs/git.el +10 -0
index e283df2..08d6404 100644
@@ -910,6 +910,15 @@ and returns the process output as a stri
     (when (eq 'unmerged (git-fileinfo->state info))
       (smerge-mode))))
 
+(defun git-find-file-other-window ()
+  "Visit the current file in its own buffer in another window."
+  (interactive)
+  (unless git-status (error "Not in git-status buffer."))
+  (let ((info (ewoc-data (ewoc-locate git-status))))
+    (find-file-other-window (git-fileinfo->name info))
+    (when (eq 'unmerged (git-fileinfo->state info))
+      (smerge-mode))))
+
 (defun git-find-file-imerge ()
   "Visit the current file in interactive merge mode."
   (interactive)
@@ -994,6 +1003,7 @@ and returns the process output as a stri
     (define-key map "M"   'git-mark-all)
     (define-key map "n"   'git-next-file)
     (define-key map "N"   'git-next-unmerged-file)
+    (define-key map "o"   'git-find-file-other-window)
     (define-key map "p"   'git-prev-file)
     (define-key map "P"   'git-prev-unmerged-file)
     (define-key map "q"   'git-status-quit)
Signature · 4 lines
1.4.3.3.gf3240

-- 
Alexandre Julliard