completion/ivy: add other-window behavior to +ivy/switch-buffer

This commit is contained in:
Henrik Lissner 2017-02-24 20:03:08 -05:00
parent f662f39f75
commit 3bebdb68a3

View file

@ -40,21 +40,29 @@
"[+]" "[+]"
(substring buffer 0 (s-index-of " " buffer))))) (substring buffer 0 (s-index-of " " buffer)))))
;;;###autoload (defun +ivy--select-buffer-other-window-action (buffer)
(defun +ivy/switch-workspace-buffer () (ivy--switch-buffer-other-window-action
"Switch to an open buffer in the current workspace." (s-chop-suffix
(interactive) "[+]"
(+ivy/switch-buffer t)) (substring buffer 0 (s-index-of " " buffer)))))
;;;###autoload ;;;###autoload
(defun +ivy/switch-buffer (&optional workspace-only-p) (defun +ivy/switch-workspace-buffer (&optional other-window-p)
"Switch to an open buffer in the current workspace."
(interactive "P")
(+ivy/switch-buffer other-window-p t))
;;;###autoload
(defun +ivy/switch-buffer (&optional other-window-p workspace-only-p)
"Switch to an open buffer in the global buffer list. If WORKSPACE-ONLY-P, "Switch to an open buffer in the global buffer list. If WORKSPACE-ONLY-P,
limit to buffers in the current workspace." limit to buffers in the current workspace."
(interactive) (interactive "P")
(ivy-read (format "%s buffers: " (if workspace-only-p "Workspace" "Global")) (ivy-read (format "%s buffers: " (if workspace-only-p "Workspace" "Global"))
(+ivy--get-buffers (unless workspace-only-p (buffer-list))) (+ivy--get-buffers (unless workspace-only-p (buffer-list)))
:matcher #'ivy--switch-buffer-matcher :action (if other-window-p
:action #'+ivy--select-buffer-action '+ivy--select-buffer-other-window-action
'+ivy--select-buffer-action)
:matcher 'ivy--switch-buffer-matcher
:keymap ivy-switch-buffer-map :keymap ivy-switch-buffer-map
:caller '+ivy/switch-workspace-buffer)) :caller '+ivy/switch-workspace-buffer))