summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2016-10-08 19:31:09 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2016-10-09 12:45:29 +0200
commit163b8600722f367024871d007b09afb8a418ef6e (patch)
tree805ccb1d82cb8d358309f1962dedbc465a747432
parentc396ffe031be0221eb77da5e8937339ae925a627 (diff)
Ensure to not resplit window while selecting actions.
* helm.el (helm-toggle-resplit-window): Do it. (helm-swap-windows): Do it.
-rw-r--r--helm.el128
1 files changed, 67 insertions, 61 deletions
diff --git a/helm.el b/helm.el
index 5a14a2e9..9f020afd 100644
--- a/helm.el
+++ b/helm.el
@@ -4691,30 +4691,33 @@ Returns the resulting buffer."
(helm-prevent-switching-other-window :enabled nil))
(unwind-protect
(with-helm-window
- (if (or helm-full-frame (one-window-p t))
- (message "Error: Attempt to resplit a single window")
- (let ((before-height (window-height)))
- (delete-window)
- (set-window-buffer
- (select-window
- (if (= (window-height) before-height) ; initial split was horizontal.
- ;; Split window vertically with `helm-buffer' placed
- ;; on the good side according to actual value of
- ;; `helm-split-window-default-side'.
- (prog1
- (cond ((or (eq helm-split-window-default-side 'above)
- (eq helm-split-window-default-side 'left))
- (split-window
- (selected-window) nil 'above))
- (t (split-window-vertically)))
- (setq helm-split-window-state 'vertical))
- ;; Split window vertically, same comment as above.
- (setq helm-split-window-state 'horizontal)
- (cond ((or (eq helm-split-window-default-side 'left)
- (eq helm-split-window-default-side 'above))
- (split-window (selected-window) nil 'left))
- (t (split-window-horizontally)))))
- helm-buffer)))
+ (cond ((or helm-full-frame (one-window-p t))
+ (user-error "Attempt to resplit a single window"))
+ ((helm-action-window)
+ (user-error "Can't resplit while selecting actions"))
+ (t
+ (let ((before-height (window-height)))
+ (delete-window)
+ (set-window-buffer
+ (select-window
+ (if (= (window-height) before-height) ; initial split was horizontal.
+ ;; Split window vertically with `helm-buffer' placed
+ ;; on the good side according to actual value of
+ ;; `helm-split-window-default-side'.
+ (prog1
+ (cond ((or (eq helm-split-window-default-side 'above)
+ (eq helm-split-window-default-side 'left))
+ (split-window
+ (selected-window) nil 'above))
+ (t (split-window-vertically)))
+ (setq helm-split-window-state 'vertical))
+ ;; Split window vertically, same comment as above.
+ (setq helm-split-window-state 'horizontal)
+ (cond ((or (eq helm-split-window-default-side 'left)
+ (eq helm-split-window-default-side 'above))
+ (split-window (selected-window) nil 'left))
+ (t (split-window-horizontally)))))
+ helm-buffer))))
(setq helm--window-side-state (helm--get-window-side-state)))
(when helm-prevent-escaping-from-minibuffer
(helm-prevent-switching-other-window :enabled t)))))
@@ -4747,43 +4750,46 @@ If N is positive enlarge, if negative narrow."
"Swap window holding `helm-buffer' with other window."
(interactive)
(with-helm-alive-p
- (if (and helm-full-frame (one-window-p t))
- (error "Error: Can't swap windows in a single window")
- (let* ((w1 (helm-window))
- (split-state (eq helm-split-window-state 'horizontal))
- (w1size (window-total-size w1 split-state))
- (b1 (window-buffer w1)) ; helm-buffer
- (s1 (window-start w1))
- (cur-frame (window-frame w1))
- (w2 (with-selected-window (helm-window)
- ;; Don't try to display helm-buffer
- ;; in a dedicated window.
- (get-window-with-predicate
- (lambda (w) (not (window-dedicated-p w)))
- 1 cur-frame)))
- (w2size (window-total-size w2 split-state))
- (b2 (window-buffer w2)) ; probably helm-current-buffer
- (s2 (window-start w2))
- resize)
- (with-selected-frame (window-frame w1)
- (helm-replace-buffer-in-window w1 b1 b2)
- (helm-replace-buffer-in-window w2 b2 b1)
- (setq resize
- (cond ( ;; helm-window is smaller than other window.
- (< w1size w2size)
- (- (- (max w2size w1size)
- (min w2size w1size))))
- ( ;; helm-window is larger than other window.
- (> w1size w2size)
- (- (max w2size w1size)
- (min w2size w1size)))
- ( ;; windows have probably same size.
- t nil)))
- ;; Maybe resize the window holding helm-buffer.
- (and resize (window-resize w2 resize split-state))
- (set-window-start w1 s2 t)
- (set-window-start w2 s1 t))
- (setq helm--window-side-state (helm--get-window-side-state))))))
+ (cond ((and helm-full-frame (one-window-p t))
+ (user-error "Can't swap windows in a single window"))
+ ((helm-action-window)
+ (user-error "Can't resplit while selecting actions"))
+ (t
+ (let* ((w1 (helm-window))
+ (split-state (eq helm-split-window-state 'horizontal))
+ (w1size (window-total-size w1 split-state))
+ (b1 (window-buffer w1)) ; helm-buffer
+ (s1 (window-start w1))
+ (cur-frame (window-frame w1))
+ (w2 (with-selected-window (helm-window)
+ ;; Don't try to display helm-buffer
+ ;; in a dedicated window.
+ (get-window-with-predicate
+ (lambda (w) (not (window-dedicated-p w)))
+ 1 cur-frame)))
+ (w2size (window-total-size w2 split-state))
+ (b2 (window-buffer w2)) ; probably helm-current-buffer
+ (s2 (window-start w2))
+ resize)
+ (with-selected-frame (window-frame w1)
+ (helm-replace-buffer-in-window w1 b1 b2)
+ (helm-replace-buffer-in-window w2 b2 b1)
+ (setq resize
+ (cond ( ;; helm-window is smaller than other window.
+ (< w1size w2size)
+ (- (- (max w2size w1size)
+ (min w2size w1size))))
+ ( ;; helm-window is larger than other window.
+ (> w1size w2size)
+ (- (max w2size w1size)
+ (min w2size w1size)))
+ ( ;; windows have probably same size.
+ t nil)))
+ ;; Maybe resize the window holding helm-buffer.
+ (and resize (window-resize w2 resize split-state))
+ (set-window-start w1 s2 t)
+ (set-window-start w2 s1 t))
+ (setq helm--window-side-state (helm--get-window-side-state)))))))
(put 'helm-swap-windows 'helm-only t)
(defun helm--get-window-side-state ()