aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics2011-11-09 10:36:05 +0100
committerMartin Rudalics2011-11-09 10:36:05 +0100
commit2cffd68198c4d574f073ab238dc12b1221005eab (patch)
tree213580d2d682f86545ae840bb6cc1a91ca481ff0
parentf6f6d7e7b144d4fc5955b91de2c802a19f3bf843 (diff)
downloademacs-2cffd68198c4d574f073ab238dc12b1221005eab.tar.gz
emacs-2cffd68198c4d574f073ab238dc12b1221005eab.zip
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.
-rw-r--r--doc/lispref/ChangeLog5
-rw-r--r--doc/lispref/windows.texi17
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/window.el76
4 files changed, 71 insertions, 36 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 2b1e210fc73..cbe016ac96d 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,8 @@
12011-11-09 Martin Rudalics <rudalics@gmx.at>
2
3 * windows.texi (Resizing Windows): Rewrite documentation of
4 window-resizable.
5
12011-11-09 Chong Yidong <cyd@gnu.org> 62011-11-09 Chong Yidong <cyd@gnu.org>
2 7
3 * windows.texi (Splitting Windows): Simplify example. 8 * windows.texi (Splitting Windows): Simplify example.
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index 17483d4c0ed..52ac5a53900 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -553,7 +553,7 @@ changed except by resizing the frame (@pxref{Size and Position}).
553arguments. Resizing an internal window causes its child windows to be 553arguments. Resizing an internal window causes its child windows to be
554resized to fit the same space. 554resized to fit the same space.
555 555
556@defun window-resizable window delta &optional horizontal ignore side noup nodown 556@defun window-resizable window delta &optional horizontal ignore
557This function returns @var{delta} if the size of @var{window} can be 557This function returns @var{delta} if the size of @var{window} can be
558changed vertically by @var{delta} lines. If the optional argument 558changed vertically by @var{delta} lines. If the optional argument
559@var{horizontal} is non-@code{nil}, it instead returns @var{delta} if 559@var{horizontal} is non-@code{nil}, it instead returns @var{delta} if
@@ -562,10 +562,11 @@ does not actually change the window size.
562 562
563If @var{window} is @code{nil}, it defaults to the selected window. 563If @var{window} is @code{nil}, it defaults to the selected window.
564 564
565A positive value of @var{delta} enlarges the window by that number of 565A positive value of @var{delta} means to check whether the window can be
566lines or columns; a negative value of @var{delta} shrinks it. If 566enlarged by that number of lines or columns; a negative value of
567@var{delta} is non-zero, a return value of 0 means that the window 567@var{delta} means to check whether the window can be shrunk by that many
568cannot be resized. 568lines or columns. If @var{delta} is non-zero, a return value of 0 means
569that the window cannot be resized.
569 570
570Normally, the variables @code{window-min-height} and 571Normally, the variables @code{window-min-height} and
571@code{window-min-width} specify the smallest allowable window size. 572@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
577of a header (if any), a mode line, plus a text area one line tall; and 578of a header (if any), a mode line, plus a text area one line tall; and
578a minimum-width window as one consisting of fringes, margins, and 579a minimum-width window as one consisting of fringes, margins, and
579scroll bar (if any), plus a text area two columns wide. 580scroll bar (if any), plus a text area two columns wide.
580
581If the optional argument @var{noup} is non-@code{nil}, this function
582considers a resize operation that does not alter the window parent of
583@var{window}, only its siblings. If the optional argument
584@var{nodown} is non-@code{nil}, it does not attempt to check whether
585@var{window} itself and its child windows can be resized.
586@end defun 581@end defun
587 582
588@defun window-resize window delta &optional horizontal ignore 583@defun window-resize window delta &optional horizontal ignore
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b1039c77243..d0a50366eff 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12011-11-09 Martin Rudalics <rudalics@gmx.at>
2
3 * window.el (window-size-fixed-p): Rewrite doc-string.
4 (window-resizable-p): Rename to window--resizable-p. Update
5 callers.
6 (window--resizable): New function. Make all callers of
7 window-resizable call window--resizable instead.
8 (window-resizable): Rewrite in terms of window--resizable.
9
12011-11-08 Glenn Morris <rgm@gnu.org> 102011-11-08 Glenn Morris <rgm@gnu.org>
2 11
3 * progmodes/delphi.el (delphi-mode-syntax-table): 12 * progmodes/delphi.el (delphi-mode-syntax-table):
diff --git a/lisp/window.el b/lisp/window.el
index 1e95a647b1f..ecd4a62b093 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -704,8 +704,8 @@ window. Optional argument HORIZONTAL non-nil means return
704non-nil if WINDOW's width is fixed. 704non-nil if WINDOW's width is fixed.
705 705
706If this function returns nil, this does not necessarily mean that 706If this function returns nil, this does not necessarily mean that
707WINDOW can be resized in the desired direction. The functions 707WINDOW can be resized in the desired direction. The function
708`window-resizable' and `window-resizable-p' will tell that." 708`window-resizable' can tell that."
709 (window-size-fixed-1 709 (window-size-fixed-1
710 (window-normalize-window window) horizontal)) 710 (window-normalize-window window) horizontal))
711 711
@@ -865,14 +865,14 @@ only whether other windows can be shrunk appropriately."
865 (window-max-delta-1 window 0 horizontal ignore trail noup))) 865 (window-max-delta-1 window 0 horizontal ignore trail noup)))
866 866
867;; Make NOUP also inhibit the min-size check. 867;; Make NOUP also inhibit the min-size check.
868(defun window-resizable (window delta &optional horizontal ignore trail noup nodown) 868(defun window--resizable (window delta &optional horizontal ignore trail noup nodown)
869 "Return DELTA if WINDOW can be resized vertically by DELTA lines. 869 "Return DELTA if WINDOW can be resized vertically by DELTA lines.
870Optional argument HORIZONTAL non-nil means return DELTA if WINDOW 870Optional argument HORIZONTAL non-nil means return DELTA if WINDOW
871can be resized horizontally by DELTA columns. A return value of 871can be resized horizontally by DELTA columns. A return value of
872zero means that WINDOW is not resizable. 872zero means that WINDOW is not resizable.
873 873
874DELTA positive means WINDOW shall be enlarged by DELTA lines or 874DELTA positive means WINDOW shall be enlarged by DELTA lines or
875columns. If WINDOW cannot be enlarged by DELTA lines or columns 875columns. If WINDOW cannot be enlarged by DELTA lines or columns,
876return the maximum value in the range 0..DELTA by which WINDOW 876return the maximum value in the range 0..DELTA by which WINDOW
877can be enlarged. 877can be enlarged.
878 878
@@ -894,11 +894,12 @@ of or below WINDOW can be shrunk. Optional argument TRAIL
894shrunk. 894shrunk.
895 895
896Optional argument NOUP non-nil means don't go up in the window 896Optional argument NOUP non-nil means don't go up in the window
897tree but try to distribute the space among the other windows 897tree but check only whether space can be obtained from (or given
898within WINDOW's combination. 898to) WINDOW's siblings.
899 899
900Optional argument NODOWN non-nil means don't check whether WINDOW 900Optional argument NODOWN non-nil means don't go down in the
901and its child windows can be resized." 901window tree. This means do not check whether resizing would
902violate size restrictions of WINDOW or its child windows."
902 (setq window (window-normalize-window window)) 903 (setq window (window-normalize-window window))
903 (cond 904 (cond
904 ((< delta 0) 905 ((< delta 0)
@@ -909,17 +910,42 @@ and its child windows can be resized."
909 delta)) 910 delta))
910 (t 0))) 911 (t 0)))
911 912
912(defun window-resizable-p (window delta &optional horizontal ignore trail noup nodown) 913(defun window--resizable-p (window delta &optional horizontal ignore trail noup nodown)
913 "Return t if WINDOW can be resized vertically by DELTA lines. 914 "Return t if WINDOW can be resized vertically by DELTA lines.
914For the meaning of the arguments of this function see the 915For the meaning of the arguments of this function see the
915doc-string of `window-resizable'." 916doc-string of `window--resizable'."
916 (setq window (window-normalize-window window)) 917 (setq window (window-normalize-window window))
917 (if (> delta 0) 918 (if (> delta 0)
918 (>= (window-resizable window delta horizontal ignore trail noup nodown) 919 (>= (window--resizable window delta horizontal ignore trail noup nodown)
919 delta) 920 delta)
920 (<= (window-resizable window delta horizontal ignore trail noup nodown) 921 (<= (window--resizable window delta horizontal ignore trail noup nodown)
921 delta))) 922 delta)))
922 923
924(defun window-resizable (window delta &optional horizontal ignore)
925 "Return DELTA if WINDOW can be resized vertically by DELTA lines.
926Optional argument HORIZONTAL non-nil means return DELTA if WINDOW
927can be resized horizontally by DELTA columns. A return value of
928zero means that WINDOW is not resizable.
929
930DELTA positive means WINDOW shall be enlarged by DELTA lines or
931columns. If WINDOW cannot be enlarged by DELTA lines or columns
932return the maximum value in the range 0..DELTA by which WINDOW
933can be enlarged.
934
935DELTA negative means WINDOW shall be shrunk by -DELTA lines or
936columns. If WINDOW cannot be shrunk by -DELTA lines or columns,
937return the minimum value in the range DELTA..0 that can be used
938for shrinking WINDOW.
939
940Optional argument IGNORE non-nil means ignore any restrictions
941imposed by fixed size windows, `window-min-height' or
942`window-min-width' settings. IGNORE a window means ignore
943restrictions for that window only. IGNORE equal `safe' means
944live windows may get as small as `window-safe-min-height' lines
945and `window-safe-min-width' columns."
946 (setq window (window-normalize-window window))
947 (window--resizable window delta horizontal ignore))
948
923(defun window-total-size (&optional window horizontal) 949(defun window-total-size (&optional window horizontal)
924 "Return the total height or width of window WINDOW. 950 "Return the total height or width of window WINDOW.
925If WINDOW is omitted or nil, it defaults to the selected window. 951If WINDOW is omitted or nil, it defaults to the selected window.
@@ -1475,7 +1501,7 @@ instead."
1475 (error "Cannot resize the root window of a frame")) 1501 (error "Cannot resize the root window of a frame"))
1476 ((window-minibuffer-p window) 1502 ((window-minibuffer-p window)
1477 (window--resize-mini-window window delta)) 1503 (window--resize-mini-window window delta))
1478 ((window-resizable-p window delta horizontal ignore) 1504 ((window--resizable-p window delta horizontal ignore)
1479 (window--resize-reset frame horizontal) 1505 (window--resize-reset frame horizontal)
1480 (window--resize-this-window window delta horizontal ignore t) 1506 (window--resize-this-window window delta horizontal ignore t)
1481 (if (and (not (window-splits window)) 1507 (if (and (not (window-splits window))
@@ -1829,7 +1855,7 @@ preferably only resize windows adjacent to EDGE."
1829 ;; Set this-delta to what we can get from WINDOW's siblings. 1855 ;; Set this-delta to what we can get from WINDOW's siblings.
1830 (if (= (- delta) (window-total-size window horizontal)) 1856 (if (= (- delta) (window-total-size window horizontal))
1831 ;; A deletion, presumably. We must handle this case 1857 ;; A deletion, presumably. We must handle this case
1832 ;; specially since `window-resizable' can't be used. 1858 ;; specially since `window--resizable' can't be used.
1833 (if this-delta 1859 (if this-delta
1834 ;; There's at least one resizable sibling we can 1860 ;; There's at least one resizable sibling we can
1835 ;; give WINDOW's size to. 1861 ;; give WINDOW's size to.
@@ -1838,7 +1864,7 @@ preferably only resize windows adjacent to EDGE."
1838 (setq this-delta 0)) 1864 (setq this-delta 0))
1839 ;; Any other form of resizing. 1865 ;; Any other form of resizing.
1840 (setq this-delta 1866 (setq this-delta
1841 (window-resizable window delta horizontal ignore trail t))) 1867 (window--resizable window delta horizontal ignore trail t)))
1842 1868
1843 ;; Set other-delta to what we still have to get from 1869 ;; Set other-delta to what we still have to get from
1844 ;; ancestor windows of parent. 1870 ;; ancestor windows of parent.
@@ -1904,7 +1930,7 @@ resize only windows on the left or above EDGE. If TRAIL equals
1904preferably only resize windows adjacent to EDGE. 1930preferably only resize windows adjacent to EDGE.
1905 1931
1906This function recursively resizes WINDOW's child windows to fit the 1932This function recursively resizes WINDOW's child windows to fit the
1907new size. Make sure that WINDOW is `window-resizable' before 1933new size. Make sure that WINDOW is `window--resizable' before
1908calling this function. Note that this function does not resize 1934calling this function. Note that this function does not resize
1909siblings of WINDOW or WINDOW's parent window. You have to 1935siblings of WINDOW or WINDOW's parent window. You have to
1910eventually call `window-resize-apply' in order to make resizing 1936eventually call `window-resize-apply' in order to make resizing
@@ -2044,7 +2070,7 @@ move it as far as possible in the desired direction."
2044 ;; Start resizing. 2070 ;; Start resizing.
2045 (window--resize-reset frame horizontal) 2071 (window--resize-reset frame horizontal)
2046 ;; Try to enlarge LEFT first. 2072 ;; Try to enlarge LEFT first.
2047 (setq this-delta (window-resizable left delta horizontal)) 2073 (setq this-delta (window--resizable left delta horizontal))
2048 (unless (zerop this-delta) 2074 (unless (zerop this-delta)
2049 (window--resize-this-window 2075 (window--resize-this-window
2050 left this-delta horizontal nil t 'before 2076 left this-delta horizontal nil t 'before
@@ -2067,7 +2093,7 @@ move it as far as possible in the desired direction."
2067 ;; Start resizing. 2093 ;; Start resizing.
2068 (window--resize-reset frame horizontal) 2094 (window--resize-reset frame horizontal)
2069 ;; Try to enlarge RIGHT. 2095 ;; Try to enlarge RIGHT.
2070 (setq this-delta (window-resizable right (- delta) horizontal)) 2096 (setq this-delta (window--resizable right (- delta) horizontal))
2071 (unless (zerop this-delta) 2097 (unless (zerop this-delta)
2072 (window--resize-this-window 2098 (window--resize-this-window
2073 right this-delta horizontal nil t 'after 2099 right this-delta horizontal nil t 'after
@@ -2098,7 +2124,7 @@ Return nil."
2098 ((zerop delta)) 2124 ((zerop delta))
2099 ((window-size-fixed-p nil horizontal) 2125 ((window-size-fixed-p nil horizontal)
2100 (error "Selected window has fixed size")) 2126 (error "Selected window has fixed size"))
2101 ((window-resizable-p nil delta horizontal) 2127 ((window--resizable-p nil delta horizontal)
2102 (window-resize nil delta horizontal)) 2128 (window-resize nil delta horizontal))
2103 (t 2129 (t
2104 (window-resize 2130 (window-resize
@@ -2119,7 +2145,7 @@ Return nil."
2119 ((zerop delta)) 2145 ((zerop delta))
2120 ((window-size-fixed-p nil horizontal) 2146 ((window-size-fixed-p nil horizontal)
2121 (error "Selected window has fixed size")) 2147 (error "Selected window has fixed size"))
2122 ((window-resizable-p nil (- delta) horizontal) 2148 ((window--resizable-p nil (- delta) horizontal)
2123 (window-resize nil (- delta) horizontal)) 2149 (window-resize nil (- delta) horizontal))
2124 (t 2150 (t
2125 (window-resize 2151 (window-resize
@@ -2392,7 +2418,7 @@ non-side window, signal an error."
2392 (set-window-new-normal 2418 (set-window-new-normal
2393 sibling (+ (window-normal-size sibling horizontal) 2419 sibling (+ (window-normal-size sibling horizontal)
2394 (window-normal-size window horizontal)))) 2420 (window-normal-size window horizontal))))
2395 ((window-resizable-p window (- size) horizontal nil nil nil t) 2421 ((window--resizable-p window (- size) horizontal nil nil nil t)
2396 ;; Can do without resizing fixed-size windows. 2422 ;; Can do without resizing fixed-size windows.
2397 (window--resize-siblings window (- size) horizontal)) 2423 (window--resize-siblings window (- size) horizontal))
2398 (t 2424 (t
@@ -3763,13 +3789,13 @@ value can be also stored on disk and read back in a new session."
3763 (let ((delta (- (cdr (assq 'total-height item)) 3789 (let ((delta (- (cdr (assq 'total-height item))
3764 (window-total-height window))) 3790 (window-total-height window)))
3765 window-size-fixed) 3791 window-size-fixed)
3766 (when (window-resizable-p window delta) 3792 (when (window--resizable-p window delta)
3767 (window-resize window delta))) 3793 (window-resize window delta)))
3768 ;; Else check whether the window is not high enough. 3794 ;; Else check whether the window is not high enough.
3769 (let* ((min-size (window-min-size window nil ignore)) 3795 (let* ((min-size (window-min-size window nil ignore))
3770 (delta (- min-size (window-total-size window)))) 3796 (delta (- min-size (window-total-size window))))
3771 (when (and (> delta 0) 3797 (when (and (> delta 0)
3772 (window-resizable-p window delta nil ignore)) 3798 (window--resizable-p window delta nil ignore))
3773 (window-resize window delta nil ignore)))) 3799 (window-resize window delta nil ignore))))
3774 ;; Adjust horizontally. 3800 ;; Adjust horizontally.
3775 (if (memq window-size-fixed '(t width)) 3801 (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 (let ((delta (- (cdr (assq 'total-width item)) 3803 (let ((delta (- (cdr (assq 'total-width item))
3778 (window-total-width window))) 3804 (window-total-width window)))
3779 window-size-fixed) 3805 window-size-fixed)
3780 (when (window-resizable-p window delta) 3806 (when (window--resizable-p window delta)
3781 (window-resize window delta))) 3807 (window-resize window delta)))
3782 ;; Else check whether the window is not wide enough. 3808 ;; Else check whether the window is not wide enough.
3783 (let* ((min-size (window-min-size window t ignore)) 3809 (let* ((min-size (window-min-size window t ignore))
3784 (delta (- min-size (window-total-size window t)))) 3810 (delta (- min-size (window-total-size window t))))
3785 (when (and (> delta 0) 3811 (when (and (> delta 0)
3786 (window-resizable-p window delta t ignore)) 3812 (window--resizable-p window delta t ignore))
3787 (window-resize window delta t ignore)))) 3813 (window-resize window delta t ignore))))
3788 ;; Set dedicated status. 3814 ;; Set dedicated status.
3789 (set-window-dedicated-p window (cdr (assq 'dedicated state))) 3815 (set-window-dedicated-p window (cdr (assq 'dedicated state)))