]> code.delx.au - gnu-emacs-elpa/commitdiff
Allow "M-o j" to switch to virtual buffers in other window
authorOleh Krehel <ohwoeowho@gmail.com>
Sun, 26 Jul 2015 13:24:34 +0000 (15:24 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Sun, 26 Jul 2015 13:24:34 +0000 (15:24 +0200)
* ivy.el (ivy--switch-buffer-other-window-action): New defun.
(ivy-set-actions): Use `ivy--switch-buffer-other-window-action' instead
of `switch-to-buffer-other-window'.

ivy.el

diff --git a/ivy.el b/ivy.el
index 28463b77c6a6f3a0c3f946b3527256e4a4c763d8..5535e1dd9e754437e26adec60a2e8cc576348e8a 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -1550,6 +1550,17 @@ BUFFER may be a string or nil."
         (switch-to-buffer
          buffer nil 'force-same-window)))))
 
+(defun ivy--switch-buffer-other-window-action (buffer)
+  "Switch to BUFFER in other window.
+BUFFER may be a string or nil."
+  (if (zerop (length buffer))
+      (switch-to-buffer-other-window ivy-text)
+    (let ((virtual (assoc buffer ivy--virtual-buffers)))
+      (if (and virtual
+               (not (get-buffer buffer)))
+          (find-file-other-window (cdr virtual))
+        (switch-to-buffer-other-window buffer)))))
+
 (defvar ivy-switch-buffer-map (make-sparse-keymap))
 
 (ivy-set-actions
@@ -1560,7 +1571,7 @@ BUFFER may be a string or nil."
       (ivy--reset-state ivy-last))
     "kill")
    ("j"
-    switch-to-buffer-other-window
+    ivy--switch-buffer-other-window-action
     "other")))
 
 (defun ivy-switch-buffer ()