From: Martin Rudalics Date: Sat, 8 Dec 2018 08:01:23 +0000 (+0100) Subject: Improve how 'balance-windows' handles fixed-size windows (Bug#33254) X-Git-Tag: emacs-27.0.90~4031 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1fc73de597ba395b3575c70dae68b6c3e5b5a3b7;p=emacs.git Improve how 'balance-windows' handles fixed-size windows (Bug#33254) * lisp/window.el (balance-windows-2): When a child window has fixed size, don't count it as resizable (Bug#33254). Handle case where a window has no resizable child windows. --- diff --git a/lisp/window.el b/lisp/window.el index 2634955a755..a16ceb4eb99 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -5317,11 +5317,12 @@ is non-nil)." (total-sum parent-size) failed size sub-total sub-delta sub-amount rest) (while sub - (setq number-of-children (1+ number-of-children)) - (when (window-size-fixed-p sub horizontal) - (setq total-sum - (- total-sum (window-size sub horizontal t))) - (set-window-new-normal sub 'ignore)) + (if (window-size-fixed-p sub horizontal) + (progn + (setq total-sum + (- total-sum (window-size sub horizontal t))) + (set-window-new-normal sub 'ignore)) + (setq number-of-children (1+ number-of-children))) (setq sub (window-right sub))) (setq failed t) @@ -5346,16 +5347,16 @@ is non-nil)." (set-window-new-normal sub 'skip))) (setq sub (window-right sub)))) - ;; How can we be sure that `number-of-children' is NOT zero here ? - (setq rest (% total-sum number-of-children)) - ;; Fix rounding by trying to enlarge non-stuck windows by one line - ;; (column) until `rest' is zero. - (setq sub first) - (while (and sub (> rest 0)) - (unless (window--resize-child-windows-skip-p window) - (set-window-new-pixel sub (min rest char-size) t) - (setq rest (- rest char-size))) - (setq sub (window-right sub))) + (when (> number-of-children 0) + (setq rest (% total-sum number-of-children)) + ;; Fix rounding by trying to enlarge non-stuck windows by one line + ;; (column) until `rest' is zero. + (setq sub first) + (while (and sub (> rest 0)) + (unless (window--resize-child-windows-skip-p window) + (set-window-new-pixel sub (min rest char-size) t) + (setq rest (- rest char-size))) + (setq sub (window-right sub)))) ;; Fix rounding by trying to enlarge stuck windows by one line ;; (column) until `rest' equals zero.