diff options
| author | Martin Rudalics | 2015-07-22 12:20:13 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2015-07-22 12:20:13 +0200 |
| commit | 59526c325e7c857776bcfe7560d533391bf045b4 (patch) | |
| tree | 99861d6ff9e2d199fa747840b1a14e3a82d06bf7 | |
| parent | fed091f7c2513631d8c0570f444be9486d7563d1 (diff) | |
| download | emacs-59526c325e7c857776bcfe7560d533391bf045b4.tar.gz emacs-59526c325e7c857776bcfe7560d533391bf045b4.zip | |
2015-07-22 Martin Rudalics <rudalics@gmx.at>
Optionally even widths of `display-buffer' windows. (Bug#21100)
* lisp/window.el (quit-restore-window): Restore width if
requested.
(display-buffer-record-window): Record width when window is
reused and horizontally combined.
(even-window-sizes): New option to allow evening window widths.
(even-window-heights): Defalias to `even-window-sizes'.
(window--even-window-heights): Rename to
`window--even-window-sizes'. Handle side-by-side windows.
(display-buffer-use-some-window): Call `window--even-window-sizes'
instead of `window--even-window-heights'.
* lisp/help.el (resize-temp-buffer-window): Fix indentation.
* doc/lispref/windows.texi (Choosing Window Options): Describe
`even-window-sizes'.
(Coordinates and Windows): Fix typo.
| -rw-r--r-- | doc/lispref/windows.texi | 17 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/help.el | 4 | ||||
| -rw-r--r-- | lisp/window.el | 70 |
4 files changed, 64 insertions, 31 deletions
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index b2bc6378008..750397c7375 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi | |||
| @@ -2547,6 +2547,21 @@ least that many columns. If the value is @code{nil}, that means not | |||
| 2547 | to split this way. | 2547 | to split this way. |
| 2548 | @end defopt | 2548 | @end defopt |
| 2549 | 2549 | ||
| 2550 | @defopt even-window-sizes | ||
| 2551 | This variable, if non-nil, causes @code{display-buffer} to even window | ||
| 2552 | sizes whenever it reuses an existing window and that window is adjacent | ||
| 2553 | to the selected one. | ||
| 2554 | |||
| 2555 | If its value is @code{width-only}, sizes are evened only if the reused | ||
| 2556 | window is on the left or right of the selected one and the selected | ||
| 2557 | window is wider than the reused one. If its value is @code{height-only} | ||
| 2558 | sizes are evened only if the reused window is above or beneath the | ||
| 2559 | selected window and the selected window is higher than the reused one. | ||
| 2560 | Any other non-@code{nil} value means to even sizes in any of these cases | ||
| 2561 | provided the selected window is larger than the reused one in the sense | ||
| 2562 | of their combination. | ||
| 2563 | @end defopt | ||
| 2564 | |||
| 2550 | @defopt pop-up-frames | 2565 | @defopt pop-up-frames |
| 2551 | If the value of this variable is non-@code{nil}, that means | 2566 | If the value of this variable is non-@code{nil}, that means |
| 2552 | @code{display-buffer} may display buffers by making new frames. The | 2567 | @code{display-buffer} may display buffers by making new frames. The |
| @@ -3690,7 +3705,7 @@ The coordinates are in the header line of @var{window}. | |||
| 3690 | The coordinates are in the divider separating @var{window} from a | 3705 | The coordinates are in the divider separating @var{window} from a |
| 3691 | window on the right. | 3706 | window on the right. |
| 3692 | 3707 | ||
| 3693 | @item right-divider | 3708 | @item bottom-divider |
| 3694 | The coordinates are in the divider separating @var{window} from a | 3709 | The coordinates are in the divider separating @var{window} from a |
| 3695 | window beneath. | 3710 | window beneath. |
| 3696 | 3711 | ||
| @@ -1106,6 +1106,10 @@ and `window-divider-default-right-width'. | |||
| 1106 | how `switch-to-buffer' proceeds interactively when the selected window | 1106 | how `switch-to-buffer' proceeds interactively when the selected window |
| 1107 | is strongly dedicated to its buffer. | 1107 | is strongly dedicated to its buffer. |
| 1108 | 1108 | ||
| 1109 | +++ | ||
| 1110 | ** The option `even-window-heights' has been renamed to | ||
| 1111 | `even-window-sizes' and now handles window widths as well. | ||
| 1112 | |||
| 1109 | ** Tearoff menus and detachable toolbars for Gtk+ has been removed. | 1113 | ** Tearoff menus and detachable toolbars for Gtk+ has been removed. |
| 1110 | Those features have been deprecated in Gtk+ for a long time. | 1114 | Those features have been deprecated in Gtk+ for a long time. |
| 1111 | 1115 | ||
diff --git a/lisp/help.el b/lisp/help.el index 1826cb7219a..46136d91003 100644 --- a/lisp/help.el +++ b/lisp/help.el | |||
| @@ -1163,8 +1163,8 @@ size of WINDOW." | |||
| 1163 | (and (window-combined-p window t) | 1163 | (and (window-combined-p window t) |
| 1164 | fit-window-to-buffer-horizontally))) | 1164 | fit-window-to-buffer-horizontally))) |
| 1165 | (and (eq quit-cadr 'frame) | 1165 | (and (eq quit-cadr 'frame) |
| 1166 | fit-frame-to-buffer | 1166 | fit-frame-to-buffer |
| 1167 | (eq window (frame-root-window window)))) | 1167 | (eq window (frame-root-window window)))) |
| 1168 | (fit-window-to-buffer window height nil width nil t)))) | 1168 | (fit-window-to-buffer window height nil width nil t)))) |
| 1169 | 1169 | ||
| 1170 | ;;; Help windows. | 1170 | ;;; Help windows. |
diff --git a/lisp/window.el b/lisp/window.el index a4ed9ea7216..1a76ecec34d 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -4358,11 +4358,18 @@ nil means to not handle the buffer in a particular way. This | |||
| 4358 | (eq (nth 3 quit-restore) buffer)) | 4358 | (eq (nth 3 quit-restore) buffer)) |
| 4359 | ;; Show another buffer stored in quit-restore parameter. | 4359 | ;; Show another buffer stored in quit-restore parameter. |
| 4360 | (when (and (integerp (nth 3 quad)) | 4360 | (when (and (integerp (nth 3 quad)) |
| 4361 | (/= (nth 3 quad) (window-total-height window))) | 4361 | (if (window-combined-p window) |
| 4362 | (/= (nth 3 quad) (window-total-height window)) | ||
| 4363 | (/= (nth 3 quad) (window-total-width window)))) | ||
| 4362 | ;; Try to resize WINDOW to its old height but don't signal an | 4364 | ;; Try to resize WINDOW to its old height but don't signal an |
| 4363 | ;; error. | 4365 | ;; error. |
| 4364 | (condition-case nil | 4366 | (condition-case nil |
| 4365 | (window-resize window (- (nth 3 quad) (window-total-height window))) | 4367 | (window-resize |
| 4368 | window | ||
| 4369 | (- (nth 3 quad) (if (window-combined-p window) | ||
| 4370 | (window-total-height window) | ||
| 4371 | (window-total-width window))) | ||
| 4372 | (window-combined-p window t)) | ||
| 4366 | (error nil))) | 4373 | (error nil))) |
| 4367 | (set-window-dedicated-p window nil) | 4374 | (set-window-dedicated-p window nil) |
| 4368 | ;; Restore WINDOW's previous buffer, start and point position. | 4375 | ;; Restore WINDOW's previous buffer, start and point position. |
| @@ -5500,7 +5507,9 @@ element is BUFFER." | |||
| 5500 | ;; Preserve window-point-insertion-type (Bug#12588). | 5507 | ;; Preserve window-point-insertion-type (Bug#12588). |
| 5501 | (copy-marker | 5508 | (copy-marker |
| 5502 | (window-point window) window-point-insertion-type) | 5509 | (window-point window) window-point-insertion-type) |
| 5503 | (window-total-height window)) | 5510 | (if (window-combined-p window) |
| 5511 | (window-total-height window) | ||
| 5512 | (window-total-width window))) | ||
| 5504 | (selected-window) buffer))))) | 5513 | (selected-window) buffer))))) |
| 5505 | ((eq type 'window) | 5514 | ((eq type 'window) |
| 5506 | ;; WINDOW has been created on an existing frame. | 5515 | ;; WINDOW has been created on an existing frame. |
| @@ -6081,33 +6090,38 @@ represents a live window, nil otherwise." | |||
| 6081 | )) | 6090 | )) |
| 6082 | frame)))) | 6091 | frame)))) |
| 6083 | 6092 | ||
| 6084 | (defcustom even-window-heights t | 6093 | (defcustom even-window-sizes t |
| 6085 | "If non-nil `display-buffer' will try to even window heights. | 6094 | "If non-nil `display-buffer' will try to even window sizes. |
| 6086 | Otherwise `display-buffer' will leave the window configuration | 6095 | Otherwise `display-buffer' will leave the window configuration |
| 6087 | alone. Heights are evened only when `display-buffer' chooses a | 6096 | alone. Special values are `height-only' to even heights only and |
| 6088 | window that appears above or below the selected window." | 6097 | `width-only' to even widths only. Any other value means to even |
| 6098 | any of them." | ||
| 6089 | :type 'boolean | 6099 | :type 'boolean |
| 6090 | :group 'windows) | 6100 | :group 'windows) |
| 6091 | 6101 | (defvaralias 'even-window-heights 'even-window-sizes) | |
| 6092 | (defun window--even-window-heights (window) | 6102 | |
| 6093 | "Even heights of WINDOW and selected window. | 6103 | (defun window--even-window-sizes (window) |
| 6094 | Do this only if these windows are vertically adjacent to each | 6104 | "Even sizes of WINDOW and selected window. |
| 6095 | other, `even-window-heights' is non-nil, and the selected window | 6105 | Even only if these windows are the only children of their parent, |
| 6096 | is higher than WINDOW." | 6106 | `even-window-sizes' has the appropriate value and the selected |
| 6097 | (when (and even-window-heights | 6107 | window is larger than WINDOW." |
| 6098 | ;; Even iff WINDOW forms a vertical combination with the | 6108 | (when (and (= (window-child-count (window-parent window)) 2) |
| 6099 | ;; selected window, and WINDOW's height exceeds that of the | 6109 | (eq (window-parent) (window-parent window))) |
| 6100 | ;; selected window, see also bug#11880. | 6110 | (cond |
| 6101 | (window-combined-p window) | 6111 | ((and (not (memq even-window-sizes '(nil height-only))) |
| 6102 | (= (window-child-count (window-parent window)) 2) | 6112 | (window-combined-p window t) |
| 6103 | (eq (window-parent) (window-parent window)) | 6113 | (> (window-total-width) (window-total-width window))) |
| 6104 | (> (window-total-height) (window-total-height window))) | 6114 | (condition-case nil |
| 6105 | ;; Don't throw an error if we can't even window heights for | 6115 | (enlarge-window |
| 6106 | ;; whatever reason. | 6116 | (/ (- (window-total-width window) (window-total-width)) 2) t) |
| 6107 | (condition-case nil | 6117 | (error nil))) |
| 6108 | (enlarge-window | 6118 | ((and (not (memq even-window-sizes '(nil width-only))) |
| 6109 | (/ (- (window-total-height window) (window-total-height)) 2)) | 6119 | (window-combined-p window) |
| 6110 | (error nil)))) | 6120 | (> (window-total-height) (window-total-height window))) |
| 6121 | (condition-case nil | ||
| 6122 | (enlarge-window | ||
| 6123 | (/ (- (window-total-height window) (window-total-height)) 2)) | ||
| 6124 | (error nil)))))) | ||
| 6111 | 6125 | ||
| 6112 | (defun window--display-buffer (buffer window type &optional alist dedicated) | 6126 | (defun window--display-buffer (buffer window type &optional alist dedicated) |
| 6113 | "Display BUFFER in WINDOW. | 6127 | "Display BUFFER in WINDOW. |
| @@ -6767,7 +6781,7 @@ that frame." | |||
| 6767 | 6781 | ||
| 6768 | (prog1 | 6782 | (prog1 |
| 6769 | (window--display-buffer buffer window 'reuse alist) | 6783 | (window--display-buffer buffer window 'reuse alist) |
| 6770 | (window--even-window-heights window) | 6784 | (window--even-window-sizes window) |
| 6771 | (unless (cdr (assq 'inhibit-switch-frame alist)) | 6785 | (unless (cdr (assq 'inhibit-switch-frame alist)) |
| 6772 | (window--maybe-raise-frame (window-frame window))))))) | 6786 | (window--maybe-raise-frame (window-frame window))))))) |
| 6773 | 6787 | ||