Function: window--make-major-side-window

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

Signature

(window--make-major-side-window BUFFER SIDE SLOT &optional ALIST)

Documentation

Display BUFFER in a new major side window on the selected frame.

SIDE must be one of left, top, right or bottom. SLOT specifies the slot to use. ALIST is an association list of symbols and values as passed to display-buffer-in-side-window. Return the new window, nil if its creation failed.

This is an auxiliary function of display-buffer-in-side-window and may be called only if no window on SIDE exists yet.

Probably introduced at or before Emacs version 26.1.

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun window--make-major-side-window (buffer side slot &optional alist)
  "Display BUFFER in a new major side window on the selected frame.
SIDE must be one of `left', `top', `right' or `bottom'.  SLOT
specifies the slot to use.  ALIST is an association list of
symbols and values as passed to `display-buffer-in-side-window'.
Return the new window, nil if its creation failed.

This is an auxiliary function of `display-buffer-in-side-window'
and may be called only if no window on SIDE exists yet."
  (let* ((left-or-right (memq side '(left right)))
	 (next-to (window--make-major-side-window-next-to side))
	 (on-side (cond
		   ((eq side 'top) 'above)
		   ((eq side 'bottom) 'below)
		   (t side)))
         (window--sides-inhibit-check t)
	 ;; The following two bindings will tell `split-window' to take
	 ;; the space for the new window from the selected frame's main
	 ;; window and not make a new parent window unless needed.
	 (window-combination-resize 'side)
	 (window-combination-limit nil)
	 (window (split-window-no-error next-to nil on-side))
         (alist (if (assq 'dedicated alist)
                    alist
                  (cons `(dedicated . ,(or display-buffer-mark-dedicated 'side))
                        alist))))
    (when window
      ;; Initialize `window-side' parameter of new window to SIDE and
      ;; make that parameter persistent.
      (set-window-parameter window 'window-side side)
      (add-to-list 'window-persistent-parameters '(window-side . writable))
      ;; Install `window-slot' parameter of new window and make that
      ;; parameter persistent.
      (set-window-parameter window 'window-slot slot)
      (add-to-list 'window-persistent-parameters '(window-slot . writable))
      ;; Auto-adjust height/width of new window unless a size has been
      ;; explicitly requested.
      (unless (if left-or-right
		  (cdr (assq 'window-width alist))
		(cdr (assq 'window-height alist)))
	(setq alist
	      (cons
	       (cons
		(if left-or-right 'window-width 'window-height)
		(/ (window-total-size (frame-root-window) left-or-right)
		   ;; By default use a fourth of the size of the frame's
		   ;; root window.
		   4))
	       alist)))
      (with-current-buffer buffer
        (setq window--sides-shown t))
      ;; Install BUFFER in new window and return WINDOW.
      (window--display-buffer buffer window 'window alist))))