aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/window.el44
1 files changed, 33 insertions, 11 deletions
diff --git a/lisp/window.el b/lisp/window.el
index 9566429627d..98cdf98cda5 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -509,11 +509,14 @@ child if WINDOW is a horizontal combination."
509 (window-left-child window) 509 (window-left-child window)
510 (window-top-child window))) 510 (window-top-child window)))
511 511
512(defun window-combinations (window &optional horizontal) 512(defun window-combinations (window &optional horizontal ignore-fixed)
513 "Return largest number of windows vertically arranged within WINDOW. 513 "Return largest number of windows vertically arranged within WINDOW.
514WINDOW must be a valid window and defaults to the selected one. 514WINDOW must be a valid window and defaults to the selected one.
515If HORIZONTAL is non-nil, return the largest number of 515If HORIZONTAL is non-nil, return the largest number of
516windows horizontally arranged within WINDOW." 516windows horizontally arranged within WINDOW.
517
518Optional argument IGNORE-FIXED, if non-nil, means to ignore
519fixed-size windows in the calculation."
517 (setq window (window-normalize-window window)) 520 (setq window (window-normalize-window window))
518 (cond 521 (cond
519 ((window-live-p window) 522 ((window-live-p window)
@@ -527,9 +530,10 @@ windows horizontally arranged within WINDOW."
527 (let ((child (window-child window)) 530 (let ((child (window-child window))
528 (count 0)) 531 (count 0))
529 (while child 532 (while child
530 (setq count 533 (unless (and ignore-fixed (window-size-fixed-p child horizontal))
531 (+ (window-combinations child horizontal) 534 (setq count
532 count)) 535 (+ (window-combinations child horizontal ignore-fixed)
536 count)))
533 (setq child (window-right child))) 537 (setq child (window-right child)))
534 count)) 538 count))
535 (t 539 (t
@@ -538,9 +542,10 @@ windows horizontally arranged within WINDOW."
538 (let ((child (window-child window)) 542 (let ((child (window-child window))
539 (count 1)) 543 (count 1))
540 (while child 544 (while child
541 (setq count 545 (unless (and ignore-fixed (window-size-fixed-p child horizontal))
542 (max (window-combinations child horizontal) 546 (setq count
543 count)) 547 (max (window-combinations child horizontal ignore-fixed)
548 count)))
544 (setq child (window-right child))) 549 (setq child (window-right child)))
545 count)))) 550 count))))
546 551
@@ -4905,6 +4910,24 @@ showing BUFFER-OR-NAME."
4905 ;; If a window doesn't show BUFFER, unrecord BUFFER in it. 4910 ;; If a window doesn't show BUFFER, unrecord BUFFER in it.
4906 (unrecord-window-buffer window buffer))))) 4911 (unrecord-window-buffer window buffer)))))
4907 4912
4913(defun window--combination-resizable (parent &optional horizontal)
4914 "Return number of pixels recoverable from height of window PARENT.
4915PARENT must be a vertical (horizontal if HORIZONTAL is non-nil)
4916window combination. The return value is the sum of the pixel
4917heights of all non-fixed height child windows of PARENT divided
4918by their number plus 1. If HORIZONTAL is non-nil, return the sum
4919of the pixel widths of all non-fixed width child windows of
4920PARENT divided by their number plus 1."
4921 (let ((sibling (window-child parent))
4922 (number 0)
4923 (size 0))
4924 (while sibling
4925 (unless (window-size-fixed-p sibling horizontal)
4926 (setq number (1+ number))
4927 (setq size (+ (window-size sibling horizontal t) size)))
4928 (setq sibling (window-next-sibling sibling)))
4929 (/ size (1+ number))))
4930
4908(defun split-window (&optional window size side pixelwise) 4931(defun split-window (&optional window size side pixelwise)
4909 "Make a new window adjacent to WINDOW. 4932 "Make a new window adjacent to WINDOW.
4910WINDOW must be a valid window and defaults to the selected one. 4933WINDOW must be a valid window and defaults to the selected one.
@@ -5042,8 +5065,7 @@ frame. The selected window is not changed by this function."
5042 ;; average size of a window in its combination. 5065 ;; average size of a window in its combination.
5043 (max (min (- parent-pixel-size 5066 (max (min (- parent-pixel-size
5044 (window-min-size parent horizontal nil t)) 5067 (window-min-size parent horizontal nil t))
5045 (/ parent-pixel-size 5068 (window--combination-resizable parent horizontal))
5046 (1+ (window-combinations parent horizontal))))
5047 (window-min-pixel-size)) 5069 (window-min-pixel-size))
5048 ;; Else try to give the new window half the size 5070 ;; Else try to give the new window half the size
5049 ;; of WINDOW (plus an eventual odd pixel). 5071 ;; of WINDOW (plus an eventual odd pixel).
@@ -5128,7 +5150,7 @@ frame. The selected window is not changed by this function."
5128 (pixel-size (/ (float new-pixel-size) 5150 (pixel-size (/ (float new-pixel-size)
5129 (if new-parent old-pixel-size parent-pixel-size))) 5151 (if new-parent old-pixel-size parent-pixel-size)))
5130 (new-parent 0.5) 5152 (new-parent 0.5)
5131 (resize (/ 1.0 (1+ (window-combinations parent horizontal)))) 5153 (resize (/ 1.0 (1+ (window-combinations parent horizontal t))))
5132 (t (/ (window-normal-size window horizontal) 2.0)))) 5154 (t (/ (window-normal-size window horizontal) 2.0))))
5133 5155
5134 (if resize 5156 (if resize