Commit 5938d519 authored by Martin Rudalics's avatar Martin Rudalics

Handle window-height and window-width alist entries in `display-buffer'.

In buffer display functions handle window-height/window-width
alist entries.  Suggested by Juri Linkov as fix for Bug#1806.
* window.el (window--display-buffer): New argument ALIST.  Obey
window-height and window-width alist entries.
(window--try-to-split-window): New argument ALIST.  Bind
window-combination-limit to t when the window's size shall be
changed and window-combination-limit equals `window-size'.
(display-buffer-in-atom-window)
(display-buffer-in-major-side-window)
(display-buffer-in-side-window, display-buffer-same-window)
(display-buffer-reuse-window, display-buffer-pop-up-frame)
(display-buffer-pop-up-window, display-buffer-below-selected)
(display-buffer-at-bottom, display-buffer-in-previous-window)
(display-buffer-use-some-window): Adjust all callers of
window--display-buffer and window--try-to-split-window.
(fit-frame-to-buffer): New option.
(fit-window-to-buffer): Can resize frames if fit-frame-to-buffer
is non-nil.
(display-buffer-in-major-side-window): Evaluate window-height /
window-width alist entries.

* help.el (temp-buffer-resize-frames)
(temp-buffer-resize-regexps): Remove options.
(temp-buffer-resize-mode): Adjust doc-string.
(resize-temp-buffer-window): Don't consult
temp-buffer-resize-regexps.  Use fit-frame-to-buffer instead of
temp-buffer-resize-frames.

* dired.el (dired-mark-pop-up): Call
display-buffer-below-selected with a fit-window-to-buffer alist
entry.

* window.c (Vwindow_combination_limit): New default value.
(Qwindow_size): New symbol replacing Qtemp_buffer_resize.
parent a97dc380
......@@ -738,14 +738,11 @@ now accept a third argument to avoid choosing the selected window.
*** New macro `with-temp-buffer-window'.
*** New options `temp-buffer-resize-frames' and
`temp-buffer-resize-regexps'.
*** `temp-buffer-resize-mode' no longer resizes windows that have been
reused.
*** New function `fit-frame-to-buffer' and new option
`fit-frame-to-buffer-bottom-margin'.
*** New function `fit-frame-to-buffer' and new options
`fit-frame-to-buffer' and `fit-frame-to-buffer-bottom-margin'.
*** New display action functions `display-buffer-below-selected',
`display-buffer-at-bottom' and `display-buffer-in-previous-window'.
......@@ -760,6 +757,9 @@ non-nil, specifies frame parameters to give any newly-created frame.
*** New display action alist entry `previous-window', if non-nil,
specifies window to reuse in `display-buffer-in-previous-window'.
*** New display action alist entries `window-height' and `window-width'
to specify size of new window created by `display-buffer'.
*** The following variables are obsolete, as they can be replaced by
appropriate entries in the `display-buffer-alist' function introduced
in Emacs 24.1:
......
2012-09-30 Martin Rudalics <rudalics@gmx.at>
In buffer display functions handle window-height/window-width
alist entries. Suggested by Juri Linkov as fix for Bug#1806.
* window.el (window--display-buffer): New argument ALIST. Obey
window-height and window-width alist entries.
(window--try-to-split-window): New argument ALIST. Bind
window-combination-limit to t when the window's size shall be
changed and window-combination-limit equals `window-size'.
(display-buffer-in-atom-window)
(display-buffer-in-major-side-window)
(display-buffer-in-side-window, display-buffer-same-window)
(display-buffer-reuse-window, display-buffer-pop-up-frame)
(display-buffer-pop-up-window, display-buffer-below-selected)
(display-buffer-at-bottom, display-buffer-in-previous-window)
(display-buffer-use-some-window): Adjust all callers of
window--display-buffer and window--try-to-split-window.
(fit-frame-to-buffer): New option.
(fit-window-to-buffer): Can resize frames if fit-frame-to-buffer
is non-nil.
(display-buffer-in-major-side-window): Evaluate window-height /
window-width alist entries.
* help.el (temp-buffer-resize-frames)
(temp-buffer-resize-regexps): Remove options.
(temp-buffer-resize-mode): Adjust doc-string.
(resize-temp-buffer-window): Don't consult
temp-buffer-resize-regexps. Use fit-frame-to-buffer instead of
temp-buffer-resize-frames.
* dired.el (dired-mark-pop-up): Call
display-buffer-below-selected with a fit-window-to-buffer alist
entry.
2012-09-30 Chong Yidong <cyd@gnu.org>
* simple.el (delete-trailing-whitespace): Avoid an unnecessary
......
......@@ -2997,7 +2997,8 @@ argument or confirmation)."
(let ((split-height-threshold 0))
(with-temp-buffer-window
buffer
(cons 'display-buffer-below-selected nil)
(cons 'display-buffer-below-selected
'((window-height . fit-window-to-buffer)))
#'(lambda (window _value)
(with-selected-window window
(unwind-protect
......
......@@ -981,26 +981,6 @@ function is called, the window to be resized is selected."
:group 'help
:version "24.2")
(defcustom temp-buffer-resize-frames nil
"Non-nil means `temp-buffer-resize-mode' can resize frames.
A frame can be resized if and only if its root window is a live
window. The height of the root window is subject to the values of
`temp-buffer-max-height' and `window-min-height'."
:type 'boolean
:version "24.2"
:group 'help)
(defcustom temp-buffer-resize-regexps nil
"List of regexps that inhibit Temp Buffer Resize mode.
Any window of a buffer whose name matches one of these regular
expressions is left alone by Temp Buffer Resize mode."
:type '(repeat
:tag "Buffer"
:value ""
(regexp :format "%v"))
:version "24.3"
:group 'help)
(define-minor-mode temp-buffer-resize-mode
"Toggle auto-resizing temporary buffer windows (Temp Buffer Resize Mode).
With a prefix argument ARG, enable Temp Buffer Resize mode if ARG
......@@ -1014,9 +994,8 @@ fit the buffer's contents, but never more than
A window is resized only if it has been specially created for the
buffer. Windows that have shown another buffer before are not
resized. A window showing a buffer whose name matches any of the
expressions in `temp-buffer-resize-regexps' is not resized. A
frame is resized only if `temp-buffer-resize-frames' is non-nil.
resized. A frame is resized only if `fit-frame-to-buffer' is
non-nil.
This mode is used by `help', `apropos' and `completion' buffers,
and some others."
......@@ -1034,33 +1013,28 @@ WINDOW can be any live window and defaults to the selected one.
Do not make WINDOW higher than `temp-buffer-max-height' nor
smaller than `window-min-height'. Do nothing if WINDOW is not
vertically combined or some of its contents are scrolled out of
view. Do nothing if the name of WINDOW's buffer matches an
expression in `temp-buffer-resize-regexps'."
view."
(setq window (window-normalize-window window t))
(let ((buffer-name (buffer-name (window-buffer window))))
(unless (catch 'found
(dolist (regexp temp-buffer-resize-regexps)
(when (string-match regexp buffer-name)
(throw 'found t))))
(let ((height (if (functionp temp-buffer-max-height)
(with-selected-window window
(funcall temp-buffer-max-height (window-buffer)))
temp-buffer-max-height))
(quit-cadr (cadr (window-parameter window 'quit-restore))))
(cond
;; Don't resize WINDOW if it showed another buffer before.
((and (eq quit-cadr 'window)
(pos-visible-in-window-p (point-min) window)
(window-combined-p window))
(fit-window-to-buffer window height))
((and temp-buffer-resize-frames
(eq quit-cadr 'frame)
(eq window (frame-root-window window)))
(let ((frame (window-frame window)))
(fit-frame-to-buffer
frame (+ (frame-height frame)
(- (window-total-size window))
height)))))))))
(let ((height (if (functionp temp-buffer-max-height)
(with-selected-window window
(funcall temp-buffer-max-height (window-buffer)))
temp-buffer-max-height))
(quit-cadr (cadr (window-parameter window 'quit-restore))))
(cond
;; Don't resize WINDOW if it showed another buffer before.
((and (eq quit-cadr 'window)
(pos-visible-in-window-p (point-min) window)
(window-combined-p window))
(fit-window-to-buffer window height))
((and fit-frame-to-buffer
(eq quit-cadr 'frame)
(eq window (frame-root-window window)))
(let ((frame (window-frame window)))
(fit-frame-to-buffer
frame (+ (frame-height frame)
(- (window-total-size window))
height))))))))
;;; Help windows.
(defcustom help-window-select 'other
......
This diff is collapsed.
2012-09-30 Martin Rudalics <rudalics@gmx.at>
* window.c (Vwindow_combination_limit): New default value.
(Qwindow_size): New symbol replacing Qtemp_buffer_resize.
2012-09-30 Paul Eggert <eggert@cs.ucla.edu>
* syssignal.h (PROFILER_CPU_SUPPORT): Don't define if PROFILING.
......@@ -131,6 +136,7 @@
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
2012-09-25 Eli Zaretskii <eliz@gnu.org>
2012-09-25 Juanma Barranquero <lekktu@gmail.com>
* makefile.w32-in ($(BLD)/callproc.$(O)): Update dependencies.
......
......@@ -60,7 +60,7 @@ static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer;
static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window;
static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically;
static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command;
static Lisp_Object Qsafe, Qabove, Qbelow, Qtemp_buffer_resize, Qclone_of;
static Lisp_Object Qsafe, Qabove, Qbelow, Qwindow_size, Qclone_of;
static int displayed_window_lines (struct window *);
static int count_windows (struct window *);
......@@ -6704,7 +6704,7 @@ syms_of_window (void)
DEFSYM (Qreplace_buffer_in_windows, "replace-buffer-in-windows");
DEFSYM (Qrecord_window_buffer, "record-window-buffer");
DEFSYM (Qget_mru_window, "get-mru-window");
DEFSYM (Qtemp_buffer_resize, "temp-buffer-resize");
DEFSYM (Qwindow_size, "window-size");
DEFSYM (Qtemp_buffer_show_hook, "temp-buffer-show-hook");
DEFSYM (Qabove, "above");
DEFSYM (Qbelow, "below");
......@@ -6804,19 +6804,19 @@ This variable takes no effect if `window-combination-limit' is non-nil. */);
The following values are recognized:
nil means splitting a window will create a new parent window only if the
window has no parent window or the window shall become a combination
orthogonal to the one it is part of.
window has no parent window or the window shall become part of a
combination orthogonal to the one it is part of.
`temp-buffer-resize' means that splitting a window for displaying a
temporary buffer makes a new parent window provided
`temp-buffer-resize-mode' is enabled. Otherwise, this value is
handled like nil.
`window-size' means that splitting a window for displaying a buffer
makes a new parent window provided `display-buffer' is supposed to
explicitly set the window's size due to the presence of a
`window-height' or `window-width' entry in the alist used by
`display-buffer'. Otherwise, this value is handled like nil.
`temp-buffer' means that splitting a window for displaying a temporary
buffer always makes a new parent window. Otherwise, this value is
handled like nil.
`display-buffer' means that splitting a window for displaying a buffer
always makes a new parent window. Since temporary buffers are
displayed by the function `display-buffer', this value is stronger
......@@ -6829,7 +6829,7 @@ t means that splitting a window always creates a new parent window. If
sibling.
Other values are reserved for future use. */);
Vwindow_combination_limit = Qtemp_buffer_resize;
Vwindow_combination_limit = Qwindow_size;
DEFVAR_LISP ("window-persistent-parameters", Vwindow_persistent_parameters,
doc: /* Alist of persistent window parameters.
......
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