From ffdd3b63fe03a2c36dcffdfdc0623dfd29c94624 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Fri, 29 Sep 2017 09:38:40 +0100 Subject: Add helm-window-alternate-split-fn (a helm-switch-to-buffers-function) --- helm-utils.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'helm-utils.el') diff --git a/helm-utils.el b/helm-utils.el index 5f390c84..4abab9f5 100644 --- a/helm-utils.el +++ b/helm-utils.el @@ -286,6 +286,25 @@ This function is suitable for `helm-switch-to-buffers-function'." (helm-switch-to-buffer-other-window b 'balance) (error (setq nosplit t) nil))))) +(defun helm-window-alternate-split-fn (candidates &optional other-window-fn) + "Alternatively split last window left and right. + +This function is suitable for `helm-switch-to-buffers-function'." + (if other-window-fn + (funcall other-window-fn (car candidates)) + (switch-to-buffer (car candidates))) + (let (right-split) + (save-selected-window + (cl-loop with nosplit + for b in candidates + when nosplit return + (message "Too many buffers to visit simultaneously") + do (condition-case _err + (progn + (select-window (split-window (get-buffer-window) nil right-split)) + (setq right-split (not right-split)) + (switch-to-buffer b)) + (error (setq nosplit t) nil)))))) (defun helm-switch-to-buffer-other-window (buffer-or-name &optional balance) "Switch to BUFFER-OR-NAME in other window. -- cgit v1.2.3