diff options
| author | Martin Rudalics | 2011-11-09 10:36:05 +0100 |
|---|---|---|
| committer | Martin Rudalics | 2011-11-09 10:36:05 +0100 |
| commit | 2cffd68198c4d574f073ab238dc12b1221005eab (patch) | |
| tree | 213580d2d682f86545ae840bb6cc1a91ca481ff0 /lisp | |
| parent | f6f6d7e7b144d4fc5955b91de2c802a19f3bf843 (diff) | |
| download | emacs-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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/window.el | 76 |
2 files changed, 60 insertions, 25 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b1039c77243..d0a50366eff 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2011-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 | |||
| 1 | 2011-11-08 Glenn Morris <rgm@gnu.org> | 10 | 2011-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 | |||
| 704 | non-nil if WINDOW's width is fixed. | 704 | non-nil if WINDOW's width is fixed. |
| 705 | 705 | ||
| 706 | If this function returns nil, this does not necessarily mean that | 706 | If this function returns nil, this does not necessarily mean that |
| 707 | WINDOW can be resized in the desired direction. The functions | 707 | WINDOW 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. |
| 870 | Optional argument HORIZONTAL non-nil means return DELTA if WINDOW | 870 | Optional argument HORIZONTAL non-nil means return DELTA if WINDOW |
| 871 | can be resized horizontally by DELTA columns. A return value of | 871 | can be resized horizontally by DELTA columns. A return value of |
| 872 | zero means that WINDOW is not resizable. | 872 | zero means that WINDOW is not resizable. |
| 873 | 873 | ||
| 874 | DELTA positive means WINDOW shall be enlarged by DELTA lines or | 874 | DELTA positive means WINDOW shall be enlarged by DELTA lines or |
| 875 | columns. If WINDOW cannot be enlarged by DELTA lines or columns | 875 | columns. If WINDOW cannot be enlarged by DELTA lines or columns, |
| 876 | return the maximum value in the range 0..DELTA by which WINDOW | 876 | return the maximum value in the range 0..DELTA by which WINDOW |
| 877 | can be enlarged. | 877 | can be enlarged. |
| 878 | 878 | ||
| @@ -894,11 +894,12 @@ of or below WINDOW can be shrunk. Optional argument TRAIL | |||
| 894 | shrunk. | 894 | shrunk. |
| 895 | 895 | ||
| 896 | Optional argument NOUP non-nil means don't go up in the window | 896 | Optional argument NOUP non-nil means don't go up in the window |
| 897 | tree but try to distribute the space among the other windows | 897 | tree but check only whether space can be obtained from (or given |
| 898 | within WINDOW's combination. | 898 | to) WINDOW's siblings. |
| 899 | 899 | ||
| 900 | Optional argument NODOWN non-nil means don't check whether WINDOW | 900 | Optional argument NODOWN non-nil means don't go down in the |
| 901 | and its child windows can be resized." | 901 | window tree. This means do not check whether resizing would |
| 902 | violate 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. |
| 914 | For the meaning of the arguments of this function see the | 915 | For the meaning of the arguments of this function see the |
| 915 | doc-string of `window-resizable'." | 916 | doc-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. | ||
| 926 | Optional argument HORIZONTAL non-nil means return DELTA if WINDOW | ||
| 927 | can be resized horizontally by DELTA columns. A return value of | ||
| 928 | zero means that WINDOW is not resizable. | ||
| 929 | |||
| 930 | DELTA positive means WINDOW shall be enlarged by DELTA lines or | ||
| 931 | columns. If WINDOW cannot be enlarged by DELTA lines or columns | ||
| 932 | return the maximum value in the range 0..DELTA by which WINDOW | ||
| 933 | can be enlarged. | ||
| 934 | |||
| 935 | DELTA negative means WINDOW shall be shrunk by -DELTA lines or | ||
| 936 | columns. If WINDOW cannot be shrunk by -DELTA lines or columns, | ||
| 937 | return the minimum value in the range DELTA..0 that can be used | ||
| 938 | for shrinking WINDOW. | ||
| 939 | |||
| 940 | Optional argument IGNORE non-nil means ignore any restrictions | ||
| 941 | imposed by fixed size windows, `window-min-height' or | ||
| 942 | `window-min-width' settings. IGNORE a window means ignore | ||
| 943 | restrictions for that window only. IGNORE equal `safe' means | ||
| 944 | live windows may get as small as `window-safe-min-height' lines | ||
| 945 | and `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. |
| 925 | If WINDOW is omitted or nil, it defaults to the selected window. | 951 | If 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 | |||
| 1904 | preferably only resize windows adjacent to EDGE. | 1930 | preferably only resize windows adjacent to EDGE. |
| 1905 | 1931 | ||
| 1906 | This function recursively resizes WINDOW's child windows to fit the | 1932 | This function recursively resizes WINDOW's child windows to fit the |
| 1907 | new size. Make sure that WINDOW is `window-resizable' before | 1933 | new size. Make sure that WINDOW is `window--resizable' before |
| 1908 | calling this function. Note that this function does not resize | 1934 | calling this function. Note that this function does not resize |
| 1909 | siblings of WINDOW or WINDOW's parent window. You have to | 1935 | siblings of WINDOW or WINDOW's parent window. You have to |
| 1910 | eventually call `window-resize-apply' in order to make resizing | 1936 | 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 | ;; 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))) |