window to a height less than the one specified here, an
application should instead call `window-resize' with a non-nil
IGNORE argument. In order to have `split-window' make a window
-shorter, explictly specify the SIZE argument of that function."
+shorter, explicitly specify the SIZE argument of that function."
:type 'integer
:version "24.1"
:group 'windows)
window to a width less than the one specified here, an
application should instead call `window-resize' with a non-nil
IGNORE argument. In order to have `split-window' make a window
-narrower, explictly specify the SIZE argument of that function."
+narrower, explicitly specify the SIZE argument of that function."
:type 'integer
:version "24.1"
:group 'windows)
(setq child (window-right child)))
count))))
-(defun walk-window-tree-1 (proc walk-window-tree-window any &optional sub-only)
+(defun walk-window-tree-1 (fun walk-window-tree-window any &optional sub-only)
"Helper function for `walk-window-tree' and `walk-window-subtree'."
(let (walk-window-tree-buffer)
(while walk-window-tree-window
(setq walk-window-tree-buffer
(window-buffer walk-window-tree-window))
(when (or walk-window-tree-buffer any)
- (funcall proc walk-window-tree-window))
+ (funcall fun walk-window-tree-window))
(unless walk-window-tree-buffer
(walk-window-tree-1
- proc (window-left-child walk-window-tree-window) any)
+ fun (window-left-child walk-window-tree-window) any)
(walk-window-tree-1
- proc (window-top-child walk-window-tree-window) any))
+ fun (window-top-child walk-window-tree-window) any))
(if sub-only
(setq walk-window-tree-window nil)
(setq walk-window-tree-window
(window-right walk-window-tree-window))))))
-(defun walk-window-tree (proc &optional frame any)
- "Run function PROC on each live window of FRAME.
-PROC must be a function with one argument - a window. FRAME must
+(defun walk-window-tree (fun &optional frame any)
+ "Run function FUN on each live window of FRAME.
+FUN must be a function with one argument - a window. FRAME must
be a live frame and defaults to the selected one. ANY, if
-non-nil means to run PROC on all live and internal windows of
+non-nil means to run FUN on all live and internal windows of
FRAME.
This function performs a pre-order, depth-first traversal of the
-window tree. If PROC changes the window tree, the result is
+window tree. If FUN changes the window tree, the result is
unpredictable."
(let ((walk-window-tree-frame (window-normalize-frame frame)))
(walk-window-tree-1
- proc (frame-root-window walk-window-tree-frame) any)))
+ fun (frame-root-window walk-window-tree-frame) any)))
-(defun walk-window-subtree (proc &optional window any)
- "Run function PROC on the subtree of windows rooted at WINDOW.
-WINDOW defaults to the selected window. PROC must be a function
-with one argument - a window. By default, run PROC only on live
+(defun walk-window-subtree (fun &optional window any)
+ "Run function FUN on the subtree of windows rooted at WINDOW.
+WINDOW defaults to the selected window. FUN must be a function
+with one argument - a window. By default, run FUN only on live
windows of the subtree. If the optional argument ANY is non-nil,
-run PROC on all live and internal windows of the subtree. If
-WINDOW is live, run PROC on WINDOW only.
+run FUN on all live and internal windows of the subtree. If
+WINDOW is live, run FUN on WINDOW only.
This function performs a pre-order, depth-first traversal of the
-subtree rooted at WINDOW. If PROC changes that tree, the result
+subtree rooted at WINDOW. If FUN changes that tree, the result
is unpredictable."
(setq window (window-normalize-window window))
- (walk-window-tree-1 proc window any t))
+ (walk-window-tree-1 fun window any t))
(defun window-with-parameter (parameter &optional value frame any)
"Return first window on FRAME with PARAMETER non-nil.
window).")
(make-variable-buffer-local 'window-size-fixed)
-(defun window-size-ignore (window ignore)
+(defun window--size-ignore (window ignore)
"Return non-nil if IGNORE says to ignore size restrictions for WINDOW."
(if (window-valid-p ignore) (eq window ignore) ignore))
windows may get as small as `window-safe-min-height' lines and
`window-safe-min-width' columns. IGNORE a window means ignore
restrictions for that window only."
- (window-min-size-1
+ (window--min-size-1
(window-normalize-window window) horizontal ignore))
-(defun window-min-size-1 (window horizontal ignore)
+(defun window--min-size-1 (window horizontal ignore)
"Internal function of `window-min-size'."
(let ((sub (window-child window)))
(if sub
;; the minimum sizes of its child windows.
(while sub
(setq value (+ value
- (window-min-size-1 sub horizontal ignore)))
+ (window--min-size-1 sub horizontal ignore)))
(setq sub (window-right sub)))
;; The minimum size of an ortho-combination is the maximum of
;; the minimum sizes of its child windows.
(while sub
(setq value (max value
- (window-min-size-1 sub horizontal ignore)))
+ (window--min-size-1 sub horizontal ignore)))
(setq sub (window-right sub))))
value)
(with-current-buffer (window-buffer window)
(cond
- ((and (not (window-size-ignore window ignore))
+ ((and (not (window--size-ignore window ignore))
(window-size-fixed-p window horizontal))
;; The minimum size of a fixed size window is its size.
(window-total-size window horizontal))
(ceiling (or (frame-parameter frame 'scroll-bar-width) 14)
(frame-char-width)))
(t 0)))
- (if (and (not (window-size-ignore window ignore))
+ (if (and (not (window--size-ignore window ignore))
(numberp window-min-width))
window-min-width
0))))
(max (+ window-safe-min-height
(if header-line-format 1 0)
(if mode-line-format 1 0))
- (if (and (not (window-size-ignore window ignore))
+ (if (and (not (window--size-ignore window ignore))
(numberp window-min-height))
window-min-height
0))))))))
(max (- (window-min-size window horizontal ignore)
(window-total-size window horizontal))
delta))
- ((window-size-ignore window ignore)
+ ((window--size-ignore window ignore)
delta)
((> delta 0)
(if (window-size-fixed-p window horizontal)
(>= (window-sizable window delta horizontal ignore) delta)
(<= (window-sizable window delta horizontal ignore) delta)))
-(defun window-size-fixed-1 (window horizontal)
+(defun window--size-fixed-1 (window horizontal)
"Internal function for `window-size-fixed-p'."
(let ((sub (window-child window)))
(catch 'fixed
;; windows are fixed-size.
(progn
(while sub
- (unless (window-size-fixed-1 sub horizontal)
+ (unless (window--size-fixed-1 sub horizontal)
;; We found a non-fixed-size child window, so
;; WINDOW's size is not fixed.
(throw 'fixed nil))
;; An ortho-combination is fixed-size if at least one of its
;; child windows is fixed-size.
(while sub
- (when (window-size-fixed-1 sub horizontal)
+ (when (window--size-fixed-1 sub horizontal)
;; We found a fixed-size child window, so WINDOW's size
;; is fixed.
(throw 'fixed t))
If this function returns nil, this does not necessarily mean that
WINDOW can be resized in the desired direction. The function
`window-resizable' can tell that."
- (window-size-fixed-1
+ (window--size-fixed-1
(window-normalize-window window) horizontal))
-(defun window-min-delta-1 (window delta &optional horizontal ignore trail noup)
+(defun window--min-delta-1 (window delta &optional horizontal ignore trail noup)
"Internal function for `window-min-delta'."
(if (not (window-parent window))
;; If we can't go up, return zero.
((eq sub window)
(setq skip (eq trail 'before)))
(skip)
- ((and (not (window-size-ignore window ignore))
+ ((and (not (window--size-ignore window ignore))
(window-size-fixed-p sub horizontal)))
(t
;; We found a non-fixed-size child window.
(setq sub (window-right sub))))
(if noup
delta
- (window-min-delta-1 parent delta horizontal ignore trail))))))
+ (window--min-delta-1 parent delta horizontal ignore trail))))))
(defun window-min-delta (&optional window horizontal ignore trail noup nodown)
"Return number of lines by which WINDOW can be shrunk.
(cond
(nodown
;; If NODOWN is t, try to recover the entire size of WINDOW.
- (window-min-delta-1 window size horizontal ignore trail noup))
+ (window--min-delta-1 window size horizontal ignore trail noup))
((= size minimum)
;; If NODOWN is nil and WINDOW's size is already at its minimum,
;; there's nothing to recover.
(t
;; Otherwise, try to recover whatever WINDOW is larger than its
;; minimum size.
- (window-min-delta-1
+ (window--min-delta-1
window (- size minimum) horizontal ignore trail noup)))))
-(defun window-max-delta-1 (window delta &optional horizontal ignore trail noup)
+(defun window--max-delta-1 (window delta &optional horizontal ignore trail noup)
"Internal function of `window-max-delta'."
(if (not (window-parent window))
;; Can't go up. Return DELTA.
;; child window is fixed-size.
(while sub
(when (and (not (eq sub window))
- (not (window-size-ignore sub ignore))
+ (not (window--size-ignore sub ignore))
(window-size-fixed-p sub horizontal))
(throw 'fixed delta))
(setq sub (window-right sub))))
delta
;; Else try with parent of WINDOW, passing the DELTA we
;; recovered so far.
- (window-max-delta-1 parent delta horizontal ignore trail))))))
+ (window--max-delta-1 parent delta horizontal ignore trail))))))
(defun window-max-delta (&optional window horizontal ignore trail noup nodown)
"Return maximum number of lines WINDOW by which WINDOW can be enlarged.
WINDOW itself \(and its child windows) can be enlarged; check
only whether other windows can be shrunk appropriately."
(setq window (window-normalize-window window))
- (if (and (not (window-size-ignore window ignore))
+ (if (and (not (window--size-ignore window ignore))
(not nodown) (window-size-fixed-p window horizontal))
;; With IGNORE and NOWDON nil return zero if WINDOW has fixed
;; size.
0
;; WINDOW has no fixed size.
- (window-max-delta-1 window 0 horizontal ignore trail noup)))
+ (window--max-delta-1 window 0 horizontal ignore trail noup)))
;; Make NOUP also inhibit the min-size check.
(defun window--resizable (window delta &optional horizontal ignore trail noup nodown)
(setq hor (cdr fcsb)))))
(cons vert hor)))
-(defun walk-windows (proc &optional minibuf all-frames)
- "Cycle through all live windows, calling PROC for each one.
-PROC must specify a function with a window as its sole argument.
+(defun walk-windows (fun &optional minibuf all-frames)
+ "Cycle through all live windows, calling FUN for each one.
+FUN must specify a function with a window as its sole argument.
The optional arguments MINIBUF and ALL-FRAMES specify the set of
windows to include in the walk.
(when (framep all-frames)
(select-window (frame-first-window all-frames) 'norecord))
(dolist (walk-windows-window (window-list-1 nil minibuf all-frames))
- (funcall proc walk-windows-window))))
+ (funcall fun walk-windows-window))))
(defun window-point-1 (&optional window)
"Return value of WINDOW's point.
frame)
(nreverse windows)))
-(defun window-in-direction-2 (window posn &optional horizontal)
+(defun window--in-direction-2 (window posn &optional horizontal)
"Support function for `window-in-direction'."
(if horizontal
(let ((top (window-top-line window)))
;; W is to the left or right of WINDOW but does not
;; cover POSN.
(setq best-diff-2-new
- (window-in-direction-2 w posn hor))
+ (window--in-direction-2 w posn hor))
(or (< best-diff-2-new best-diff-2)
(and (= best-diff-2-new best-diff-2)
(if (eq direction 'left)
(and (eq direction 'below) (<= last w-top)))
;; W is above or below WINDOW but does not cover POSN.
(setq best-diff-2-new
- (window-in-direction-2 w posn hor))
+ (window--in-direction-2 w posn hor))
(or (< best-diff-2-new best-diff-2)
(and (= best-diff-2-new best-diff-2)
(if (eq direction 'above)
((window--resizable-p window delta horizontal ignore)
(window--resize-reset frame horizontal)
(window--resize-this-window window delta horizontal ignore t)
- (if (and (not (window-splits window))
+ (if (and (not window-combination-resize)
(window-combined-p window horizontal)
(setq sibling (or (window-right window) (window-left window)))
(window-sizable-p sibling (- delta) horizontal ignore))
- ;; If window-splits returns nil for WINDOW, WINDOW is part of
- ;; an iso-combination, and WINDOW's neighboring right or left
+ ;; If window-combination-resize is nil, WINDOW is part of an
+ ;; iso-combination, and WINDOW's neighboring right or left
;; sibling can be resized as requested, resize that sibling.
(let ((normal-delta
(/ (float delta)
;; Make sure this sibling is left alone when
;; resizing its siblings.
(set-window-new-normal sub 'ignore))
- ((or (window-size-ignore sub ignore)
+ ((or (window--size-ignore sub ignore)
(not (window-size-fixed-p sub horizontal)))
;; Set this-delta to t to signal that we found a sibling
;; of WINDOW whose size is not fixed.
;; two windows we want to resize.
(cond
((> delta 0)
- (setq max-delta (window-max-delta-1 left 0 horizontal nil 'after))
- (setq min-delta (window-min-delta-1 right (- delta) horizontal nil 'before))
+ (setq max-delta (window--max-delta-1 left 0 horizontal nil 'after))
+ (setq min-delta (window--min-delta-1 right (- delta) horizontal nil 'before))
(when (or (< max-delta delta) (> min-delta (- delta)))
;; We can't get the whole DELTA - move as far as possible.
(setq delta (min max-delta (- min-delta))))
(window-left-column right)
(window-top-line right)))))
((< delta 0)
- (setq max-delta (window-max-delta-1 right 0 horizontal nil 'before))
- (setq min-delta (window-min-delta-1 left delta horizontal nil 'after))
+ (setq max-delta (window--max-delta-1 right 0 horizontal nil 'before))
+ (setq min-delta (window--min-delta-1 left delta horizontal nil 'after))
(when (or (< max-delta (- delta)) (> min-delta delta))
;; We can't get the whole DELTA - move as far as possible.
(setq delta (max (- max-delta) min-delta)))
"Return non-nil if WINDOW is the root window of its frame."
(eq window (frame-root-window window)))
-(defun window-tree-1 (window &optional next)
- "Return window tree rooted at WINDOW.
-Optional argument NEXT non-nil means include windows right
+(defun window--subtree (window &optional next)
+ "Return window subtree rooted at WINDOW.
+Optional argument NEXT non-nil means include WINDOW's right
siblings in the return value.
See the documentation of `window-tree' for a description of the
(cond
((window-top-child window)
(cons t (cons (window-edges window)
- (window-tree-1 (window-top-child window) t))))
+ (window--subtree (window-top-child window) t))))
((window-left-child window)
(cons nil (cons (window-edges window)
- (window-tree-1 (window-left-child window) t))))
+ (window--subtree (window-left-child window) t))))
(t window))
list))
(setq window (when next (window-next-sibling window))))
representing a window split, and so on. EDGES is a list \(LEFT
TOP RIGHT BOTTOM) as returned by `window-edges'."
(setq frame (window-normalize-frame frame))
- (window-tree-1 (frame-root-window frame) t))
+ (window--subtree (frame-root-window frame) t))
\f
(defun other-window (count &optional all-frames)
"Select another window in cyclic ordering of windows.
(sibling (or (window-left window) (window-right window))))
(window--resize-reset frame horizontal)
(cond
- ((and (not (window-splits window))
+ ((and (not window-combination-resize)
sibling (window-sizable-p sibling size))
;; Resize WINDOW's sibling.
(window--resize-this-window sibling size horizontal nil t)
This function removes the buffer denoted by BUFFER-OR-NAME from
all window-local buffer lists."
+ (interactive "bBuffer to replace: ")
(let ((buffer (window-normalize-buffer buffer-or-name)))
(dolist (window (window-list-1 nil nil t))
(if (eq (window-buffer window) buffer)
(parent (window-parent window))
(function (window-parameter window 'split-window))
(window-side (window-parameter window 'window-side))
- ;; Rebind `window-nest' since in some cases we may have to
- ;; override its value.
- (window-nest window-nest)
+ ;; Rebind `window-combination-limit' since in some cases we may
+ ;; have to override its value.
+ (window-combination-limit window-combination-limit)
atom-root)
(window--check frame)
(or (not parent)
(not (window-parameter parent 'window-side))))
;; WINDOW is a side root window. To make sure that a new parent
- ;; window gets created set `window-nest' to t.
- (setq window-nest t))
+ ;; window gets created set `window-combination-limit' to t.
+ (setq window-combination-limit t))
- (when (and window-splits size (> size 0))
- ;; If `window-splits' is non-nil and SIZE is a non-negative
- ;; integer, we cannot reasonably resize other windows. Rather
- ;; bind `window-nest' to t to make sure that subsequent window
- ;; deletions are handled correctly.
- (setq window-nest t))
+ (when (and window-combination-resize size (> size 0))
+ ;; If `window-combination-resize' is non-nil and SIZE is a
+ ;; non-negative integer, we cannot reasonably resize other
+ ;; windows. Rather bind `window-combination-limit' to t to make
+ ;; sure that subsequent window deletions are handled correctly.
+ (setq window-combination-limit t))
(let* ((parent-size
;; `parent-size' is the size of WINDOW's parent, provided
;; `resize' non-nil means we are supposed to resize other
;; windows in WINDOW's combination.
(resize
- (and window-splits (not window-nest)
+ (and window-combination-resize (not window-combination-limit)
;; Resize makes sense in iso-combinations only.
(window-combined-p window horizontal)))
;; `old-size' is the current size of WINDOW.
;; Make new-parent non-nil if we need a new parent window;
;; either because we want to nest or because WINDOW is not
;; iso-combined.
- (or window-nest (not (window-combined-p window horizontal))))
+ (or window-combination-limit
+ (not (window-combined-p window horizontal))))
(setq new-normal
;; Make new-normal the normal size of the new window.
(cond
"Balance the sizes of windows of WINDOW-OR-FRAME.
WINDOW-OR-FRAME is optional and defaults to the selected frame.
If WINDOW-OR-FRAME denotes a frame, balance the sizes of all
-windows of that frame. If WINDOW-OR-FRAME denots a window,
+windows of that frame. If WINDOW-OR-FRAME denotes a window,
recursively balance the sizes of all child windows of that
window."
(interactive)
(defvar window-state-ignored-parameters '(quit-restore)
"List of window parameters ignored by `window-state-get'.")
-(defun window-state-get-1 (window &optional markers)
+(defun window--state-get-1 (window &optional markers)
"Helper function for `window-state-get'."
(let* ((type
(cond
(total-width . ,(window-total-size window t))
(normal-height . ,(window-normal-size window))
(normal-width . ,(window-normal-size window t))
- (splits . ,(window-splits window))
- (nest . ,(window-nest window))
+ (combination-limit . ,(window-combination-limit window))
,@(let (list)
(dolist (parameter (window-parameters window))
(unless (memq (car parameter)
(let (list)
(setq window (window-child window))
(while window
- (setq list (cons (window-state-get-1 window markers) list))
+ (setq list (cons (window--state-get-1 window markers) list))
(setq window (window-right window)))
(nreverse list)))))
(append head tail)))
;; These are probably not needed.
,@(when (window-size-fixed-p window) `((fixed-height . t)))
,@(when (window-size-fixed-p window t) `((fixed-width . t))))
- (window-state-get-1 window markers)))
+ (window--state-get-1 window markers)))
(defvar window-state-put-list nil
"Helper variable for `window-state-put'.")
-(defun window-state-put-1 (state &optional window ignore totals)
+(defun window--state-put-1 (state &optional window ignore totals)
"Helper function for `window-state-put'."
(let ((type (car state)))
(setq state (cdr state))
((eq type 'leaf)
;; For a leaf window just add unprocessed entries to
;; `window-state-put-list'.
- (setq window-state-put-list
- (cons (cons window state) window-state-put-list)))
+ (push (cons window state) window-state-put-list))
((memq type '(vc hc))
(let* ((horizontal (eq type 'hc))
(total (window-total-size window horizontal))
;; real window that we want to fill with what we find here.
(when (memq (car item) '(leaf vc hc))
(if (assq 'last item)
- ;; The last child window. Below `window-state-put-1'
+ ;; The last child window. Below `window--state-put-1'
;; will put into it whatever ITEM has in store.
(setq new nil)
;; Not the last child window, prepare for splitting
window-safe-min-width)))
(if (window-sizable-p window (- size) horizontal 'safe)
- (let* ((window-nest (assq 'nest item)))
- ;; We must inherit the nesting, otherwise we might mess
- ;; up handling of atomic and side window.
+ (let* ((window-combination-limit
+ (assq 'combination-limit item)))
+ ;; We must inherit the combiantion limit, otherwise
+ ;; we might mess up handling of atomic and side
+ ;; window.
(setq new (split-window window size horizontal)))
;; Give up if we can't resize window down to safe sizes.
(error "Cannot resize window %s" window))
;; Now process the current window (either the one we've just
;; split or the last child of its parent).
- (window-state-put-1 item window ignore totals)
+ (window--state-put-1 item window ignore totals)
;; Continue with the last window split off.
(setq window new))))))))
-(defun window-state-put-2 (ignore)
+(defun window--state-put-2 (ignore)
"Helper function for `window-state-put'."
(dolist (item window-state-put-list)
(let ((window (car item))
(splits (cdr (assq 'splits item)))
- (nest (cdr (assq 'nest item)))
+ (combination-limit (cdr (assq 'combination-limit item)))
(parameters (cdr (assq 'parameters item)))
(state (cdr (assq 'buffer item))))
- (when splits (set-window-splits window splits))
- (when nest (set-window-nest window nest))
+ (when combination-limit
+ (set-window-combination-limit window combination-limit))
;; Process parameters.
(when parameters
(dolist (parameter parameters)
(cdr (assq 'total-width state)))))
(min-height (cdr (assq 'min-height head)))
(min-width (cdr (assq 'min-width head)))
- window-splits selected)
+ selected)
(if (and (not totals)
(or (> min-height (window-total-size window))
(> min-width (window-total-size window t)))
;; Work on the windows of a temporary buffer to make sure that
;; splitting proceeds regardless of any buffer local values of
;; `window-size-fixed'. Release that buffer after the buffers of
- ;; all live windows have been set by `window-state-put-2'.
+ ;; all live windows have been set by `window--state-put-2'.
(with-temp-buffer
(set-window-buffer window (current-buffer))
- (window-state-put-1 state window nil totals)
- (window-state-put-2 ignore))
+ (window--state-put-1 state window nil totals)
+ (window--state-put-2 ignore))
(window--check frame))))
\f
(defun display-buffer-record-window (type window buffer)
(defun window-normalize-buffer-to-display (buffer-or-name)
"Normalize BUFFER-OR-NAME argument for buffer display functions.
-If BUFFER-OR-NAME is nil, return the curent buffer. Else, if a
+If BUFFER-OR-NAME is nil, return the current buffer. Else, if a
buffer specified by BUFFER-OR-NAME exists, return that buffer.
If no such buffer exists, create a buffer with the name
BUFFER-OR-NAME and return that buffer."
(window--display-buffer-1 window))))
(defun display-buffer--special-action (buffer)
- "Try to display BUFFER using `special-display-function'.
-Call `special-display-p' on BUFFER's name, and if that returns
-non-nil, call `special-display-function' on BUFFER."
+ "Return special display action for BUFFER, if any.
+If `special-display-p' returns non-nil for BUFFER, return an
+appropriate display action involving `special-display-function'.
+See `display-buffer' for the format of display actions."
(and special-display-function
;; `special-display-p' returns either t or a list of frame
;; parameters to pass to `special-display-function'.
(defun read-buffer-to-switch (prompt)
"Read the name of a buffer to switch to, prompting with PROMPT.
-Return the neame of the buffer as a string.
+Return the name of the buffer as a string.
This function is intended for the `switch-to-buffer' family of
commands since these need to omit the name of the current buffer
;;; of buffer).
(defcustom scroll-error-top-bottom nil
- "Move point to top/bottom of buffer before signalling a scrolling error.
+ "Move point to top/bottom of buffer before signaling a scrolling error.
A value of nil means just signal an error if no more scrolling possible.
A value of t means point moves to the beginning or the end of the buffer
\(depending on scrolling direction) when no more scrolling possible.