Commit 2cffd681 authored by Martin Rudalics's avatar Martin Rudalics
Browse files

Rewrite window-resizable.

* window.el (window-size-fixed-p): Rewrite doc-string.
(window-resizable-p): Rename to window--resizable-p.  Update
callers.
(window--resizable): New function.  Make all callers of
window-resizable call window--resizable instead.
(window-resizable): Rewrite in terms of window--resizable.
* windows.texi (Resizing Windows): Rewrite documentation of
window-resizable.
parent f6f6d7e7
2011-11-09 Martin Rudalics <rudalics@gmx.at>
* windows.texi (Resizing Windows): Rewrite documentation of
window-resizable.
2011-11-09 Chong Yidong <cyd@gnu.org> 2011-11-09 Chong Yidong <cyd@gnu.org>
* windows.texi (Splitting Windows): Simplify example. * windows.texi (Splitting Windows): Simplify example.
......
...@@ -553,7 +553,7 @@ changed except by resizing the frame (@pxref{Size and Position}). ...@@ -553,7 +553,7 @@ changed except by resizing the frame (@pxref{Size and Position}).
arguments. Resizing an internal window causes its child windows to be arguments. Resizing an internal window causes its child windows to be
resized to fit the same space. resized to fit the same space.
@defun window-resizable window delta &optional horizontal ignore side noup nodown @defun window-resizable window delta &optional horizontal ignore
This function returns @var{delta} if the size of @var{window} can be This function returns @var{delta} if the size of @var{window} can be
changed vertically by @var{delta} lines. If the optional argument changed vertically by @var{delta} lines. If the optional argument
@var{horizontal} is non-@code{nil}, it instead returns @var{delta} if @var{horizontal} is non-@code{nil}, it instead returns @var{delta} if
...@@ -562,10 +562,11 @@ does not actually change the window size. ...@@ -562,10 +562,11 @@ does not actually change the window size.
If @var{window} is @code{nil}, it defaults to the selected window. If @var{window} is @code{nil}, it defaults to the selected window.
A positive value of @var{delta} enlarges the window by that number of A positive value of @var{delta} means to check whether the window can be
lines or columns; a negative value of @var{delta} shrinks it. If enlarged by that number of lines or columns; a negative value of
@var{delta} is non-zero, a return value of 0 means that the window @var{delta} means to check whether the window can be shrunk by that many
cannot be resized. lines or columns. If @var{delta} is non-zero, a return value of 0 means
that the window cannot be resized.
Normally, the variables @code{window-min-height} and Normally, the variables @code{window-min-height} and
@code{window-min-width} specify the smallest allowable window size. @code{window-min-width} specify the smallest allowable window size.
...@@ -577,12 +578,6 @@ Instead, it considers the minimum-height window to be one consisting ...@@ -577,12 +578,6 @@ Instead, it considers the minimum-height window to be one consisting
of a header (if any), a mode line, plus a text area one line tall; and of a header (if any), a mode line, plus a text area one line tall; and
a minimum-width window as one consisting of fringes, margins, and a minimum-width window as one consisting of fringes, margins, and
scroll bar (if any), plus a text area two columns wide. scroll bar (if any), plus a text area two columns wide.
If the optional argument @var{noup} is non-@code{nil}, this function
considers a resize operation that does not alter the window parent of
@var{window}, only its siblings. If the optional argument
@var{nodown} is non-@code{nil}, it does not attempt to check whether
@var{window} itself and its child windows can be resized.
@end defun @end defun
@defun window-resize window delta &optional horizontal ignore @defun window-resize window delta &optional horizontal ignore
......
2011-11-09 Martin Rudalics <rudalics@gmx.at>
* window.el (window-size-fixed-p): Rewrite doc-string.
(window-resizable-p): Rename to window--resizable-p. Update
callers.
(window--resizable): New function. Make all callers of
window-resizable call window--resizable instead.
(window-resizable): Rewrite in terms of window--resizable.
2011-11-08 Glenn Morris <rgm@gnu.org> 2011-11-08 Glenn Morris <rgm@gnu.org>
* progmodes/delphi.el (delphi-mode-syntax-table): * progmodes/delphi.el (delphi-mode-syntax-table):
......
...@@ -704,8 +704,8 @@ window. Optional argument HORIZONTAL non-nil means return ...@@ -704,8 +704,8 @@ window. Optional argument HORIZONTAL non-nil means return
non-nil if WINDOW's width is fixed. non-nil if WINDOW's width is fixed.
If this function returns nil, this does not necessarily mean that If this function returns nil, this does not necessarily mean that
WINDOW can be resized in the desired direction. The functions WINDOW can be resized in the desired direction. The function
`window-resizable' and `window-resizable-p' will tell that." `window-resizable' can tell that."
(window-size-fixed-1 (window-size-fixed-1
(window-normalize-window window) horizontal)) (window-normalize-window window) horizontal))
...@@ -865,14 +865,14 @@ only whether other windows can be shrunk appropriately." ...@@ -865,14 +865,14 @@ only whether other windows can be shrunk appropriately."
(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. ;; Make NOUP also inhibit the min-size check.
(defun window-resizable (window delta &optional horizontal ignore trail noup nodown) (defun window--resizable (window delta &optional horizontal ignore trail noup nodown)
"Return DELTA if WINDOW can be resized vertically by DELTA lines. "Return DELTA if WINDOW can be resized vertically by DELTA lines.
Optional argument HORIZONTAL non-nil means return DELTA if WINDOW Optional argument HORIZONTAL non-nil means return DELTA if WINDOW
can be resized horizontally by DELTA columns. A return value of can be resized horizontally by DELTA columns. A return value of
zero means that WINDOW is not resizable. zero means that WINDOW is not resizable.
DELTA positive means WINDOW shall be enlarged by DELTA lines or DELTA positive means WINDOW shall be enlarged by DELTA lines or
columns. If WINDOW cannot be enlarged by DELTA lines or columns columns. If WINDOW cannot be enlarged by DELTA lines or columns,
return the maximum value in the range 0..DELTA by which WINDOW return the maximum value in the range 0..DELTA by which WINDOW
can be enlarged. can be enlarged.
...@@ -894,11 +894,12 @@ of or below WINDOW can be shrunk. Optional argument TRAIL ...@@ -894,11 +894,12 @@ of or below WINDOW can be shrunk. Optional argument TRAIL
shrunk. shrunk.
Optional argument NOUP non-nil means don't go up in the window Optional argument NOUP non-nil means don't go up in the window
tree but try to distribute the space among the other windows tree but check only whether space can be obtained from (or given
within WINDOW's combination. to) WINDOW's siblings.
Optional argument NODOWN non-nil means don't check whether WINDOW Optional argument NODOWN non-nil means don't go down in the
and its child windows can be resized." window tree. This means do not check whether resizing would
violate size restrictions of WINDOW or its child windows."
(setq window (window-normalize-window window)) (setq window (window-normalize-window window))
(cond (cond
((< delta 0) ((< delta 0)
...@@ -909,17 +910,42 @@ and its child windows can be resized." ...@@ -909,17 +910,42 @@ and its child windows can be resized."
delta)) delta))
(t 0))) (t 0)))
(defun window-resizable-p (window delta &optional horizontal ignore trail noup nodown) (defun window--resizable-p (window delta &optional horizontal ignore trail noup nodown)
"Return t if WINDOW can be resized vertically by DELTA lines. "Return t if WINDOW can be resized vertically by DELTA lines.
For the meaning of the arguments of this function see the For the meaning of the arguments of this function see the
doc-string of `window-resizable'." doc-string of `window--resizable'."
(setq window (window-normalize-window window)) (setq window (window-normalize-window window))
(if (> delta 0) (if (> delta 0)
(>= (window-resizable window delta horizontal ignore trail noup nodown) (>= (window--resizable window delta horizontal ignore trail noup nodown)
delta) delta)
(<= (window-resizable window delta horizontal ignore trail noup nodown) (<= (window--resizable window delta horizontal ignore trail noup nodown)
delta))) delta)))
(defun window-resizable (window delta &optional horizontal ignore)
"Return DELTA if WINDOW can be resized vertically by DELTA lines.
Optional argument HORIZONTAL non-nil means return DELTA if WINDOW
can be resized horizontally by DELTA columns. A return value of
zero means that WINDOW is not resizable.
DELTA positive means WINDOW shall be enlarged by DELTA lines or
columns. If WINDOW cannot be enlarged by DELTA lines or columns
return the maximum value in the range 0..DELTA by which WINDOW
can be enlarged.
DELTA negative means WINDOW shall be shrunk by -DELTA lines or
columns. If WINDOW cannot be shrunk by -DELTA lines or columns,
return the minimum value in the range DELTA..0 that can be used
for shrinking WINDOW.
Optional argument IGNORE non-nil means ignore any restrictions
imposed by fixed size windows, `window-min-height' or
`window-min-width' settings. IGNORE a window means ignore
restrictions for that window only. IGNORE equal `safe' means
live windows may get as small as `window-safe-min-height' lines
and `window-safe-min-width' columns."
(setq window (window-normalize-window window))
(window--resizable window delta horizontal ignore))
(defun window-total-size (&optional window horizontal) (defun window-total-size (&optional window horizontal)
"Return the total height or width of window WINDOW. "Return the total height or width of window WINDOW.
If WINDOW is omitted or nil, it defaults to the selected window. If WINDOW is omitted or nil, it defaults to the selected window.
...@@ -1475,7 +1501,7 @@ instead." ...@@ -1475,7 +1501,7 @@ instead."
(error "Cannot resize the root window of a frame")) (error "Cannot resize the root window of a frame"))
((window-minibuffer-p window) ((window-minibuffer-p window)
(window--resize-mini-window window delta)) (window--resize-mini-window window delta))
((window-resizable-p window delta horizontal ignore) ((window--resizable-p window delta horizontal ignore)
(window--resize-reset frame horizontal) (window--resize-reset frame horizontal)
(window--resize-this-window window delta horizontal ignore t) (window--resize-this-window window delta horizontal ignore t)
(if (and (not (window-splits window)) (if (and (not (window-splits window))
...@@ -1829,7 +1855,7 @@ preferably only resize windows adjacent to EDGE." ...@@ -1829,7 +1855,7 @@ preferably only resize windows adjacent to EDGE."
;; Set this-delta to what we can get from WINDOW's siblings. ;; Set this-delta to what we can get from WINDOW's siblings.
(if (= (- delta) (window-total-size window horizontal)) (if (= (- delta) (window-total-size window horizontal))
;; A deletion, presumably. We must handle this case ;; A deletion, presumably. We must handle this case
;; specially since `window-resizable' can't be used. ;; specially since `window--resizable' can't be used.
(if this-delta (if this-delta
;; There's at least one resizable sibling we can ;; There's at least one resizable sibling we can
;; give WINDOW's size to. ;; give WINDOW's size to.
...@@ -1838,7 +1864,7 @@ preferably only resize windows adjacent to EDGE." ...@@ -1838,7 +1864,7 @@ preferably only resize windows adjacent to EDGE."
(setq this-delta 0)) (setq this-delta 0))
;; Any other form of resizing. ;; Any other form of resizing.
(setq this-delta (setq this-delta
(window-resizable window delta horizontal ignore trail t))) (window--resizable window delta horizontal ignore trail t)))
;; Set other-delta to what we still have to get from ;; Set other-delta to what we still have to get from
;; ancestor windows of parent. ;; ancestor windows of parent.
...@@ -1904,7 +1930,7 @@ resize only windows on the left or above EDGE. If TRAIL equals ...@@ -1904,7 +1930,7 @@ resize only windows on the left or above EDGE. If TRAIL equals
preferably only resize windows adjacent to EDGE. preferably only resize windows adjacent to EDGE.
This function recursively resizes WINDOW's child windows to fit the This function recursively resizes WINDOW's child windows to fit the
new size. Make sure that WINDOW is `window-resizable' before new size. Make sure that WINDOW is `window--resizable' before
calling this function. Note that this function does not resize calling this function. Note that this function does not resize
siblings of WINDOW or WINDOW's parent window. You have to siblings of WINDOW or WINDOW's parent window. You have to
eventually call `window-resize-apply' in order to make resizing eventually call `window-resize-apply' in order to make resizing
...@@ -2044,7 +2070,7 @@ move it as far as possible in the desired direction." ...@@ -2044,7 +2070,7 @@ move it as far as possible in the desired direction."
;; Start resizing. ;; Start resizing.
(window--resize-reset frame horizontal) (window--resize-reset frame horizontal)
;; Try to enlarge LEFT first. ;; Try to enlarge LEFT first.
(setq this-delta (window-resizable left delta horizontal)) (setq this-delta (window--resizable left delta horizontal))
(unless (zerop this-delta) (unless (zerop this-delta)
(window--resize-this-window (window--resize-this-window
left this-delta horizontal nil t 'before left this-delta horizontal nil t 'before
...@@ -2067,7 +2093,7 @@ move it as far as possible in the desired direction." ...@@ -2067,7 +2093,7 @@ move it as far as possible in the desired direction."
;; Start resizing. ;; Start resizing.
(window--resize-reset frame horizontal) (window--resize-reset frame horizontal)
;; Try to enlarge RIGHT. ;; Try to enlarge RIGHT.
(setq this-delta (window-resizable right (- delta) horizontal)) (setq this-delta (window--resizable right (- delta) horizontal))
(unless (zerop this-delta) (unless (zerop this-delta)
(window--resize-this-window (window--resize-this-window
right this-delta horizontal nil t 'after right this-delta horizontal nil t 'after
...@@ -2098,7 +2124,7 @@ Return nil." ...@@ -2098,7 +2124,7 @@ Return nil."
((zerop delta)) ((zerop delta))
((window-size-fixed-p nil horizontal) ((window-size-fixed-p nil horizontal)
(error "Selected window has fixed size")) (error "Selected window has fixed size"))
((window-resizable-p nil delta horizontal) ((window--resizable-p nil delta horizontal)
(window-resize nil delta horizontal)) (window-resize nil delta horizontal))
(t (t
(window-resize (window-resize
...@@ -2119,7 +2145,7 @@ Return nil." ...@@ -2119,7 +2145,7 @@ Return nil."
((zerop delta)) ((zerop delta))
((window-size-fixed-p nil horizontal) ((window-size-fixed-p nil horizontal)
(error "Selected window has fixed size")) (error "Selected window has fixed size"))
((window-resizable-p nil (- delta) horizontal) ((window--resizable-p nil (- delta) horizontal)
(window-resize nil (- delta) horizontal)) (window-resize nil (- delta) horizontal))
(t (t
(window-resize (window-resize
...@@ -2392,7 +2418,7 @@ non-side window, signal an error." ...@@ -2392,7 +2418,7 @@ non-side window, signal an error."
(set-window-new-normal (set-window-new-normal
sibling (+ (window-normal-size sibling horizontal) sibling (+ (window-normal-size sibling horizontal)
(window-normal-size window horizontal)))) (window-normal-size window horizontal))))
((window-resizable-p window (- size) horizontal nil nil nil t) ((window--resizable-p window (- size) horizontal nil nil nil t)
;; Can do without resizing fixed-size windows. ;; Can do without resizing fixed-size windows.
(window--resize-siblings window (- size) horizontal)) (window--resize-siblings window (- size) horizontal))
(t (t
...@@ -3763,13 +3789,13 @@ value can be also stored on disk and read back in a new session." ...@@ -3763,13 +3789,13 @@ value can be also stored on disk and read back in a new session."
(let ((delta (- (cdr (assq 'total-height item)) (let ((delta (- (cdr (assq 'total-height item))
(window-total-height window))) (window-total-height window)))
window-size-fixed) window-size-fixed)
(when (window-resizable-p window delta) (when (window--resizable-p window delta)
(window-resize window delta))) (window-resize window delta)))
;; Else check whether the window is not high enough. ;; Else check whether the window is not high enough.
(let* ((min-size (window-min-size window nil ignore)) (let* ((min-size (window-min-size window nil ignore))
(delta (- min-size (window-total-size window)))) (delta (- min-size (window-total-size window))))
(when (and (> delta 0) (when (and (> delta 0)
(window-resizable-p window delta nil ignore)) (window--resizable-p window delta nil ignore))
(window-resize window delta nil ignore)))) (window-resize window delta nil ignore))))
;; Adjust horizontally. ;; Adjust horizontally.
(if (memq window-size-fixed '(t width)) (if (memq window-size-fixed '(t width))
...@@ -3777,13 +3803,13 @@ value can be also stored on disk and read back in a new session." ...@@ -3777,13 +3803,13 @@ value can be also stored on disk and read back in a new session."
(let ((delta (- (cdr (assq 'total-width item)) (let ((delta (- (cdr (assq 'total-width item))
(window-total-width window))) (window-total-width window)))
window-size-fixed) window-size-fixed)
(when (window-resizable-p window delta) (when (window--resizable-p window delta)
(window-resize window delta))) (window-resize window delta)))
;; Else check whether the window is not wide enough. ;; Else check whether the window is not wide enough.
(let* ((min-size (window-min-size window t ignore)) (let* ((min-size (window-min-size window t ignore))
(delta (- min-size (window-total-size window t)))) (delta (- min-size (window-total-size window t))))
(when (and (> delta 0) (when (and (> delta 0)
(window-resizable-p window delta t ignore)) (window--resizable-p window delta t ignore))
(window-resize window delta t ignore)))) (window-resize window delta t ignore))))
;; Set dedicated status. ;; Set dedicated status.
(set-window-dedicated-p window (cdr (assq 'dedicated state))) (set-window-dedicated-p window (cdr (assq 'dedicated state)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment