summaryrefslogtreecommitdiff
path: root/helm-utils.el
diff options
context:
space:
mode:
authorPierre Neidhardt <ambrevar@gmail.com>2017-09-29 09:38:40 +0100
committerPierre Neidhardt <ambrevar@gmail.com>2017-09-29 12:33:11 +0100
commitffdd3b63fe03a2c36dcffdfdc0623dfd29c94624 (patch)
tree868fbfde5ca108995cf2eb71dd541694777b4048 /helm-utils.el
parentd437b58b8d5a8a9e605848ffa0bb0218651983ad (diff)
Add helm-window-alternate-split-fn (a helm-switch-to-buffers-function)
Diffstat (limited to 'helm-utils.el')
-rw-r--r--helm-utils.el19
1 files changed, 19 insertions, 0 deletions
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.