Function: window--resize-siblings

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

Signature

(window--resize-siblings WINDOW DELTA &optional HORIZONTAL IGNORE TRAIL EDGE CHAR-SIZE)

Documentation

Resize other windows when WINDOW is resized vertically by DELTA pixels.

Optional argument HORIZONTAL non-nil means resize other windows when WINDOW is resized horizontally by DELTA pixels. WINDOW itself is not resized by this function.

The optional argument IGNORE has the same meaning as for window-resizable.

Optional arguments TRAIL and EDGE, when non-nil, refine the set of windows that shall be resized. If TRAIL equals before, resize only windows on the left or above EDGE. If TRAIL equals after, resize only windows on the right or below EDGE. Also, preferably only resize windows adjacent to EDGE.

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun window--resize-siblings (window delta &optional horizontal ignore trail edge char-size)
  "Resize other windows when WINDOW is resized vertically by DELTA pixels.
Optional argument HORIZONTAL non-nil means resize other windows
when WINDOW is resized horizontally by DELTA pixels.  WINDOW
itself is not resized by this function.

The optional argument IGNORE has the same meaning as for
`window-resizable'.

Optional arguments TRAIL and EDGE, when non-nil, refine the set
of windows that shall be resized.  If TRAIL equals `before',
resize only windows on the left or above EDGE.  If TRAIL equals
`after', resize only windows on the right or below EDGE.  Also,
preferably only resize windows adjacent to EDGE."
  (when (window-parent window)
    (let* ((parent (window-parent window))
	   (sub (window-child parent)))
      (if (window-combined-p sub horizontal)
	  ;; In an iso-combination try to extract DELTA from WINDOW's
	  ;; siblings.
	  (let ((skip (eq trail 'after))
		this-delta other-delta)
	    ;; Decide which windows shall be left alone.
	    (while sub
	      (cond
	       ((eq sub window)
		;; Make sure WINDOW is left alone when
		;; resizing its siblings.
		(set-window-new-normal sub 'ignore)
		(setq skip (eq trail 'before)))
	       (skip
		;; Make sure this sibling is left alone when
		;; resizing its siblings.
		(set-window-new-normal sub 'ignore))
	       ((not (window-size-fixed-p sub horizontal ignore))
		;; Set this-delta to t to signal that we found a sibling
		;; of WINDOW whose size is not fixed.
		(setq this-delta t)))

	      (setq sub (window-right sub)))

	    ;; Set this-delta to what we can get from WINDOW's siblings.
	    (if (= (- delta) (window-size window horizontal t))
		;; A deletion, presumably.  We must handle this case
		;; specially since `window--resizable' can't be used.
		(if this-delta
		    ;; There's at least one resizable sibling we can
		    ;; give WINDOW's size to.
		    (setq this-delta delta)
		  ;; No resizable sibling exists.
		  (setq this-delta 0))
	      ;; Any other form of resizing.
	      (setq this-delta
		    (window--resizable
		     window delta horizontal ignore trail t nil t)))

	    ;; Set other-delta to what we still have to get from
	    ;; ancestor windows of parent.
	    (setq other-delta (- delta this-delta))
	    (unless (zerop other-delta)
	      ;; Unless we got everything from WINDOW's siblings, PARENT
	      ;; must be resized by other-delta lines or columns.
	      (set-window-new-pixel parent other-delta 'add))

	    (if (zerop this-delta)
		;; We haven't got anything from WINDOW's siblings but we
		;; must update the normal sizes to respect other-delta.
		(window--resize-child-windows-normal
		 parent horizontal window this-delta trail other-delta)
	      ;; We did get something from WINDOW's siblings which means
	      ;; we have to resize their child windows.
	      (unless (eq (window--resize-child-windows
			   parent (- this-delta) horizontal
			   window ignore trail edge char-size)
			  ;; If `window--resize-child-windows' returns
			  ;; 'normalized, this means it has set the
			  ;; normal sizes already.
			  'normalized)
		;; Set the normal sizes.
		(window--resize-child-windows-normal
		 parent horizontal window this-delta trail other-delta))
	      ;; Set DELTA to what we still have to get from ancestor
	      ;; windows.
	      (setq delta other-delta)))

	;; In an ortho-combination all siblings of WINDOW must be
	;; resized by DELTA.
	(set-window-new-pixel parent delta 'add)
	(while sub
	  (unless (eq sub window)
	    (window--resize-this-window
	     sub delta horizontal ignore t))
	  (setq sub (window-right sub))))

      (unless (zerop delta)
	;; "Go up."
	(window--resize-siblings
	 parent delta horizontal ignore trail edge char-size)))))