diff options
author | Martin Rudalics <rudalics@gmx.at> | 2015-07-22 12:20:13 +0200 |
---|---|---|
committer | Martin Rudalics <rudalics@gmx.at> | 2015-07-22 12:20:13 +0200 |
commit | 59526c325e7c857776bcfe7560d533391bf045b4 (patch) | |
tree | 99861d6ff9e2d199fa747840b1a14e3a82d06bf7 | |
parent | fed091f7c2513631d8c0570f444be9486d7563d1 (diff) | |
download | emacs-59526c325e7c857776bcfe7560d533391bf045b4.tar.gz |
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 to split this way. @end defopt +@defopt even-window-sizes +This variable, if non-nil, causes @code{display-buffer} to even window +sizes whenever it reuses an existing window and that window is adjacent +to the selected one. + +If its value is @code{width-only}, sizes are evened only if the reused +window is on the left or right of the selected one and the selected +window is wider than the reused one. If its value is @code{height-only} +sizes are evened only if the reused window is above or beneath the +selected window and the selected window is higher than the reused one. +Any other non-@code{nil} value means to even sizes in any of these cases +provided the selected window is larger than the reused one in the sense +of their combination. +@end defopt + @defopt pop-up-frames If the value of this variable is non-@code{nil}, that means @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}. The coordinates are in the divider separating @var{window} from a window on the right. -@item right-divider +@item bottom-divider The coordinates are in the divider separating @var{window} from a window beneath. @@ -1106,6 +1106,10 @@ and `window-divider-default-right-width'. how `switch-to-buffer' proceeds interactively when the selected window is strongly dedicated to its buffer. ++++ +** The option `even-window-heights' has been renamed to +`even-window-sizes' and now handles window widths as well. + ** Tearoff menus and detachable toolbars for Gtk+ has been removed. Those features have been deprecated in Gtk+ for a long time. 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." (and (window-combined-p window t) fit-window-to-buffer-horizontally))) (and (eq quit-cadr 'frame) - fit-frame-to-buffer - (eq window (frame-root-window window)))) + fit-frame-to-buffer + (eq window (frame-root-window window)))) (fit-window-to-buffer window height nil width nil t)))) ;;; 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 (eq (nth 3 quit-restore) buffer)) ;; Show another buffer stored in quit-restore parameter. (when (and (integerp (nth 3 quad)) - (/= (nth 3 quad) (window-total-height window))) + (if (window-combined-p window) + (/= (nth 3 quad) (window-total-height window)) + (/= (nth 3 quad) (window-total-width window)))) ;; Try to resize WINDOW to its old height but don't signal an ;; error. (condition-case nil - (window-resize window (- (nth 3 quad) (window-total-height window))) + (window-resize + window + (- (nth 3 quad) (if (window-combined-p window) + (window-total-height window) + (window-total-width window))) + (window-combined-p window t)) (error nil))) (set-window-dedicated-p window nil) ;; Restore WINDOW's previous buffer, start and point position. @@ -5500,7 +5507,9 @@ element is BUFFER." ;; Preserve window-point-insertion-type (Bug#12588). (copy-marker (window-point window) window-point-insertion-type) - (window-total-height window)) + (if (window-combined-p window) + (window-total-height window) + (window-total-width window))) (selected-window) buffer))))) ((eq type 'window) ;; WINDOW has been created on an existing frame. @@ -6081,33 +6090,38 @@ represents a live window, nil otherwise." )) frame)))) -(defcustom even-window-heights t - "If non-nil `display-buffer' will try to even window heights. +(defcustom even-window-sizes t + "If non-nil `display-buffer' will try to even window sizes. Otherwise `display-buffer' will leave the window configuration -alone. Heights are evened only when `display-buffer' chooses a -window that appears above or below the selected window." +alone. Special values are `height-only' to even heights only and +`width-only' to even widths only. Any other value means to even +any of them." :type 'boolean :group 'windows) - -(defun window--even-window-heights (window) - "Even heights of WINDOW and selected window. -Do this only if these windows are vertically adjacent to each -other, `even-window-heights' is non-nil, and the selected window -is higher than WINDOW." - (when (and even-window-heights - ;; Even iff WINDOW forms a vertical combination with the - ;; selected window, and WINDOW's height exceeds that of the - ;; selected window, see also bug#11880. - (window-combined-p window) - (= (window-child-count (window-parent window)) 2) - (eq (window-parent) (window-parent window)) - (> (window-total-height) (window-total-height window))) - ;; Don't throw an error if we can't even window heights for - ;; whatever reason. - (condition-case nil - (enlarge-window - (/ (- (window-total-height window) (window-total-height)) 2)) - (error nil)))) +(defvaralias 'even-window-heights 'even-window-sizes) + +(defun window--even-window-sizes (window) + "Even sizes of WINDOW and selected window. +Even only if these windows are the only children of their parent, +`even-window-sizes' has the appropriate value and the selected +window is larger than WINDOW." + (when (and (= (window-child-count (window-parent window)) 2) + (eq (window-parent) (window-parent window))) + (cond + ((and (not (memq even-window-sizes '(nil height-only))) + (window-combined-p window t) + (> (window-total-width) (window-total-width window))) + (condition-case nil + (enlarge-window + (/ (- (window-total-width window) (window-total-width)) 2) t) + (error nil))) + ((and (not (memq even-window-sizes '(nil width-only))) + (window-combined-p window) + (> (window-total-height) (window-total-height window))) + (condition-case nil + (enlarge-window + (/ (- (window-total-height window) (window-total-height)) 2)) + (error nil)))))) (defun window--display-buffer (buffer window type &optional alist dedicated) "Display BUFFER in WINDOW. @@ -6767,7 +6781,7 @@ that frame." (prog1 (window--display-buffer buffer window 'reuse alist) - (window--even-window-heights window) + (window--even-window-sizes window) (unless (cdr (assq 'inhibit-switch-frame alist)) (window--maybe-raise-frame (window-frame window))))))) |