branch: master
commit c1b9f5a0f41c88d115d46f5dd3322a1586c2b51b
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
Allow "M-o j" to switch to virtual buffers in other window
* 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 | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/ivy.el b/ivy.el
index 28463b7..5535e1d 100644
--- 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 ()