Function: window-combinations

window-combinations is a byte-compiled function defined in window.el.gz.

Signature

(window-combinations WINDOW &optional HORIZONTAL IGNORE-FIXED)

Documentation

Return largest number of windows vertically arranged within WINDOW.

WINDOW must be a valid window and defaults to the selected one. If HORIZONTAL is non-nil, return the largest number of windows horizontally arranged within WINDOW.

Optional argument IGNORE-FIXED, if non-nil, means to ignore fixed-size windows in the calculation.

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun window-combinations (window &optional horizontal ignore-fixed)
  "Return largest number of windows vertically arranged within WINDOW.
WINDOW must be a valid window and defaults to the selected one.
If HORIZONTAL is non-nil, return the largest number of
windows horizontally arranged within WINDOW.

Optional argument IGNORE-FIXED, if non-nil, means to ignore
fixed-size windows in the calculation."
  (setq window (window-normalize-window window))
  (cond
   ((window-live-p window)
    ;; If WINDOW is live, return 1.
    1)
   ((if horizontal
	(window-left-child window)
      (window-top-child window))
    ;; If WINDOW is iso-combined, return the sum of the values for all
    ;; child windows of WINDOW.
    (let ((child (window-child window))
	  (count 0))
      (while child
	(unless (and ignore-fixed (window-size-fixed-p child horizontal))
	  (setq count
		(+ (window-combinations child horizontal ignore-fixed)
		   count)))
	(setq child (window-right child)))
      count))
   (t
    ;; If WINDOW is not iso-combined, return the maximum value of any
    ;; child window of WINDOW.
    (let ((child (window-child window))
	  (count 1))
      (while child
	(unless (and ignore-fixed (window-size-fixed-p child horizontal))
	  (setq count
		(max (window-combinations child horizontal ignore-fixed)
		     count)))
	(setq child (window-right child)))
      count))))