Function: window--make-major-side-window-next-to

window--make-major-side-window-next-to is a byte-compiled function defined in window.el.gz.

Signature

(window--make-major-side-window-next-to SIDE)

Documentation

Return window to split for making a major side window.

SIDE must be one of the symbols left, top, right or bottom.

This is an auxiliary function of window--make-major-side-window and must not be called when a window on SIDE exists already.

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun window--make-major-side-window-next-to (side)
  "Return window to split for making a major side window.
SIDE must be one of the symbols `left', `top', `right' or
`bottom'.

This is an auxiliary function of `window--make-major-side-window'
and must not be called when a window on SIDE exists already."
  (let ((root (frame-root-window))
        (window--sides-inhibit-check t)
        window)
    ;; (1) If a window on the opposite side exists, return that window's
    ;;     sibling.
    ;; (2) If the new window shall span the entire side, return the
    ;;     frame's root window.
    ;; (3) If a window on an orthogonal side exists, return that
    ;;     window's sibling.
    ;; (4) Otherwise return the frame's root window.
    (cond
     ((or (and (eq side 'left)
	       (setq window (window-with-parameter 'window-side 'right nil t)))
	  (and (eq side 'top)
	       (setq window (window-with-parameter 'window-side 'bottom nil t))))
      (window-prev-sibling window))
     ((or (and (eq side 'right)
	       (setq window (window-with-parameter 'window-side 'left nil t)))
	  (and (eq side 'bottom)
	       (setq window (window-with-parameter 'window-side 'top nil t))))
      (window-next-sibling window))
     ((memq side '(left right))
      (cond
       (window-sides-vertical
	root)
       ((setq window (window-with-parameter 'window-side 'top nil t))
	(window-next-sibling window))
       ((setq window (window-with-parameter 'window-side 'bottom nil t))
	(window-prev-sibling window))
       (t root)))
     ((memq side '(top bottom))
      (cond
       ((not window-sides-vertical)
	root)
       ((setq window (window-with-parameter 'window-side 'left nil t))
	(window-next-sibling window))
       ((setq window (window-with-parameter 'window-side 'right nil t))
	(window-prev-sibling window))
       (t root))))))