summaryrefslogtreecommitdiff
path: root/lisp/help.el
diff options
context:
space:
mode:
authorMartin Rudalics <rudalics@gmx.at>2012-09-22 14:56:08 +0200
committerMartin Rudalics <rudalics@gmx.at>2012-09-22 14:56:08 +0200
commit8e17c9ba1443c2f21c5801f0c4660ac08dccc837 (patch)
tree440766cd6249af19144f114626180568c5ece697 /lisp/help.el
parentaa1fe812d3e77ed65a5226a42e5dc081eab22b18 (diff)
downloademacs-8e17c9ba1443c2f21c5801f0c4660ac08dccc837.tar.gz
Make Temp Buffer Resize Mode less intrusive (Bug#1806).
* window.c (Fsplit_window_internal): Handle only Qt value of Vwindow_combination_limit separately. (Qtemp_buffer_resize): New symbol. (Vwindow_combination_limit): New default value. Rewrite doc-string. * cus-start.el (window-combination-limit): Add new optional values. * window.el (temp-buffer-window-show) (window--try-to-split-window): Obey new values of window-combination-limit. (split-window): Test window-combination-limit for t instead of non-nil. (display-buffer-at-bottom): New buffer display action function. * help.el (temp-buffer-resize-regexps): New option. (temp-buffer-resize-mode): Rewrite doc-string. (resize-temp-buffer-window): Obey temp-buffer-resize-regexps. Don't resize reused window. Suggested by Glen Morris.
Diffstat (limited to 'lisp/help.el')
-rw-r--r--lisp/help.el63
1 files changed, 43 insertions, 20 deletions
diff --git a/lisp/help.el b/lisp/help.el
index da11389d87c..707c8e3c84f 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -990,6 +990,17 @@ window. The height of the root window is subject to the values of
: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
@@ -1001,6 +1012,12 @@ show a temporary buffer are automatically resized in height to
fit the buffer's contents, but never more than
`temp-buffer-max-height' nor less than `window-min-height'.
+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.
+
This mode is used by `help', `apropos' and `completion' buffers,
and some others."
:global t :group 'help
@@ -1017,27 +1034,33 @@ 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."
+view. Do nothing if the name of WINDOW's buffer matches an
+expression in `temp-buffer-resize-regexps'."
(setq window (window-normalize-window window t))
- (let ((height (if (functionp temp-buffer-max-height)
- (with-selected-window window
- (funcall temp-buffer-max-height (window-buffer)))
- temp-buffer-max-height)))
- (cond
- ((and (pos-visible-in-window-p (point-min) window)
- (window-combined-p window))
- (fit-window-to-buffer window height))
- ((and temp-buffer-resize-frames
- (eq window (frame-root-window window))
- (memq (car (window-parameter window 'quit-restore))
- ;; If 'same is too strong, we might additionally check
- ;; whether the second element is 'frame.
- '(same frame)))
- (let ((frame (window-frame window)))
- (fit-frame-to-buffer
- frame (+ (frame-height frame)
- (- (window-total-size window))
- height)))))))
+ (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)))))))))
;;; Help windows.
(defcustom help-window-select 'other