aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/lispref/ChangeLog8
-rw-r--r--doc/lispref/windows.texi108
-rw-r--r--lisp/ChangeLog13
-rw-r--r--lisp/window.el75
4 files changed, 149 insertions, 55 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 89b456f5c22..062692ee9f3 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,11 @@
12012-11-16 Martin Rudalics <rudalics@gmx.at>
2
3 * windows.texi (Choosing Window): Rewrite description of
4 display-buffer-alist (Bug#12167).
5 (Display Action Functions): Mention inhibit-switch-frame. Fix
6 description of display-buffer-below-selected. Reorder actions.
7 Add example (Bug#12848).
8
12012-11-15 Stefan Monnier <monnier@iro.umontreal.ca> 92012-11-15 Stefan Monnier <monnier@iro.umontreal.ca>
2 10
3 * keymaps.texi (Translation Keymaps): Add a subsection "Interaction 11 * keymaps.texi (Translation Keymaps): Add a subsection "Interaction
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index bb02b1d54fd..77f1ff9a179 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -1766,6 +1766,7 @@ Like @code{switch-to-buffer}, this function updates the buffer list
1766unless @var{norecord} is non-@code{nil}. 1766unless @var{norecord} is non-@code{nil}.
1767@end deffn 1767@end deffn
1768 1768
1769
1769@node Choosing Window 1770@node Choosing Window
1770@section Choosing a Window for Display 1771@section Choosing a Window for Display
1771 1772
@@ -1851,10 +1852,14 @@ default value is empty, i.e. @code{(nil . nil)}.
1851@end defvar 1852@end defvar
1852 1853
1853@defopt display-buffer-alist 1854@defopt display-buffer-alist
1854The value of this option is an alist mapping regular expressions to 1855The value of this option is an alist mapping conditions to display
1855display actions. If the name of the buffer passed to 1856actions. Each condition may be either a regular expression matching a
1856@code{display-buffer} matches a regular expression in this alist, then 1857buffer name or a function that takes two arguments - a buffer name and
1857@code{display-buffer} uses the corresponding display action. 1858the @var{action} argument passed to @code{display-buffer}. If the name
1859of the buffer passed to @code{display-buffer} either matches a regular
1860expression in this alist or the function specified by a condition
1861returns non-@code{nil}, then @code{display-buffer} uses the
1862corresponding display action to display the buffer.
1858@end defopt 1863@end defopt
1859 1864
1860@defopt display-buffer-base-action 1865@defopt display-buffer-base-action
@@ -1868,6 +1873,7 @@ This display action specifies the fallback behavior for
1868@code{display-buffer} if no other display actions are given. 1873@code{display-buffer} if no other display actions are given.
1869@end defvr 1874@end defvr
1870 1875
1876
1871@node Display Action Functions 1877@node Display Action Functions
1872@section Action Functions for @code{display-buffer} 1878@section Action Functions for @code{display-buffer}
1873 1879
@@ -1911,8 +1917,9 @@ normally searches just the selected frame; however, if the variable
1911@code{pop-up-frames} is non-@code{nil}, it searches all frames on the 1917@code{pop-up-frames} is non-@code{nil}, it searches all frames on the
1912current terminal. @xref{Choosing Window Options}. 1918current terminal. @xref{Choosing Window Options}.
1913 1919
1914If this function chooses a window on another frame, it makes that 1920If this function chooses a window on another frame, it makes that frame
1915frame visible and raises it if necessary. 1921visible and, unless @var{alist} contains an @code{inhibit-switch-frame}
1922entry (@pxref{Choosing Window Options}), raises that frame if necessary.
1916@end defun 1923@end defun
1917 1924
1918@defun display-buffer-pop-up-frame buffer alist 1925@defun display-buffer-pop-up-frame buffer alist
@@ -1976,16 +1983,12 @@ reason (e.g. if there is just one frame and it has an
1976@code{unsplittable} frame parameter; @pxref{Buffer Parameters}). 1983@code{unsplittable} frame parameter; @pxref{Buffer Parameters}).
1977@end defun 1984@end defun
1978 1985
1979@defun display-buffer-use-some-window buffer alist
1980This function tries to display @var{buffer} by choosing an existing
1981window and displaying the buffer in that window. It can fail if all
1982windows are dedicated to another buffer (@pxref{Dedicated Windows}).
1983@end defun
1984
1985@defun display-buffer-below-selected buffer alist 1986@defun display-buffer-below-selected buffer alist
1986This function tries to display @var{buffer} in a window below the 1987This function tries to display @var{buffer} in a window below the
1987selected window. This means to either split the selected window or 1988selected window. This means to either split the selected window or use
1988reuse the window below the selected one. 1989the window below the selected one. If it does create a new window, it
1990will also adjust its size provided @var{alist} contains a suitable
1991@code{window-height} or @code{window-width} entry, see above.
1989@end defun 1992@end defun
1990 1993
1991@defun display-buffer-in-previous-window buffer alist 1994@defun display-buffer-in-previous-window buffer alist
@@ -2001,6 +2004,83 @@ specified by that entry will override any other window found by the
2001methods above, even if that window never showed @var{buffer} before. 2004methods above, even if that window never showed @var{buffer} before.
2002@end defun 2005@end defun
2003 2006
2007@defun display-buffer-use-some-window buffer alist
2008This function tries to display @var{buffer} by choosing an existing
2009window and displaying the buffer in that window. It can fail if all
2010windows are dedicated to another buffer (@pxref{Dedicated Windows}).
2011@end defun
2012
2013To illustrate the use of action functions, consider the following
2014example.
2015
2016@example
2017@group
2018(display-buffer
2019 (get-buffer-create "*foo*")
2020 '((display-buffer-reuse-window
2021 display-buffer-pop-up-window
2022 display-buffer-pop-up-frame)
2023 (reusable-frames . 0)
2024 (window-height . 10) (window-width . 40)))
2025@end group
2026@end example
2027
2028@noindent
2029Evaluating the form above will cause @code{display-buffer} to proceed as
2030follows: If `*foo*' already appears on a visible or iconified frame, it
2031will reuse its window. Otherwise, it will try to pop up a new window
2032or, if that is impossible, a new frame. If all these steps fail, it
2033will try to use some existing window.
2034
2035 Furthermore, @code{display-buffer} will try to adjust a reused window
2036(provided `*foo*' was put by @code{display-buffer} there before) or a
2037popped-up window as follows: If the window is part of a vertical
2038combination, it will set its height to ten lines. Note that if, instead
2039of the number ``10'', we specified the function
2040@code{fit-window-to-buffer}, @code{display-buffer} would come up with a
2041one-line window to fit the empty buffer. If the window is part of a
2042horizontal combination, it sets its width to 40 columns. Whether a new
2043window is vertically or horizontally combined depends on the shape of
2044the window split and the values of
2045@code{split-window-preferred-function}, @code{split-height-threshold}
2046and @code{split-width-threshold} (@pxref{Choosing Window Options}).
2047
2048 Now suppose we combine this call with a preexisting setup for
2049`display-buffer-alist' as follows.
2050
2051@example
2052@group
2053(let ((display-buffer-alist
2054 (cons
2055 '("\\*foo\\*"
2056 (display-buffer-reuse-window display-buffer-below-selected)
2057 (reusable-frames)
2058 (window-height . 5))
2059 display-buffer-alist)))
2060 (display-buffer
2061 (get-buffer-create "*foo*")
2062 '((display-buffer-reuse-window
2063 display-buffer-pop-up-window
2064 display-buffer-pop-up-frame)
2065 (reusable-frames . 0)
2066 (window-height . 10) (window-width . 40))))
2067@end group
2068@end example
2069
2070@noindent
2071Evaluating this form will cause @code{display-buffer} to first try
2072reusing a window showing @code{*foo*} on the selected frame.
2073If no such window exists, it will try to split the selected window or,
2074if that is impossible, use the window below the selected window.
2075
2076 If there's no window below the selected one, or the window below the
2077selected one is dedicated to its buffer, @code{display-buffer} will
2078proceed as described in the previous example. Note, however, that when
2079it tries to adjust the height of any reused or popped-up window, it will
2080in any case try to set its number of lines to ``5'' since that value
2081overrides the corresponding specification in the @var{action} argument
2082of @code{display-buffer}.
2083
2004 2084
2005@node Choosing Window Options 2085@node Choosing Window Options
2006@section Additional Options for Displaying Buffers 2086@section Additional Options for Displaying Buffers
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 74d66809d55..a267c726986 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,16 @@
12012-11-16 Martin Rudalics <rudalics@gmx.at>
2
3 * window.el (enlarge-window, shrink-window): Don't mention return
4 value in doc-string (Bug#12896).
5 (window--display-buffer): Don't resize frames - it won't work
6 with all window managers and defeat pop-up-frame-alist.
7 (display-buffer-alist): In doc-string explain that CONDITION can
8 be a function and which arguments are passed to it (Bug#12854).
9 (display-buffer-assq-regexp): New argument ACTION. Handle lambda
10 expressions (Bug#12854).
11 (display-buffer): Pass ACTION argument to
12 display-buffer-assq-regexp.
13
12012-11-16 Glenn Morris <rgm@gnu.org> 142012-11-16 Glenn Morris <rgm@gnu.org>
2 15
3 * window.el (fit-frame-to-buffer-bottom-margin) 16 * window.el (fit-frame-to-buffer-bottom-margin)
diff --git a/lisp/window.el b/lisp/window.el
index c9ea8351e8c..9ac3a4ecda0 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -2571,8 +2571,7 @@ move it as far as possible in the desired direction."
2571Interactively, if no argument is given, make the selected window 2571Interactively, if no argument is given, make the selected window
2572one line taller. If optional argument HORIZONTAL is non-nil, 2572one line taller. If optional argument HORIZONTAL is non-nil,
2573make selected window wider by DELTA columns. If DELTA is 2573make selected window wider by DELTA columns. If DELTA is
2574negative, shrink selected window by -DELTA lines or columns. 2574negative, shrink selected window by -DELTA lines or columns."
2575Return nil."
2576 (interactive "p") 2575 (interactive "p")
2577 (let ((minibuffer-window (minibuffer-window))) 2576 (let ((minibuffer-window (minibuffer-window)))
2578 (cond 2577 (cond
@@ -2605,8 +2604,7 @@ Interactively, if no argument is given, make the selected window
2605one line smaller. If optional argument HORIZONTAL is non-nil, 2604one line smaller. If optional argument HORIZONTAL is non-nil,
2606make selected window narrower by DELTA columns. If DELTA is 2605make selected window narrower by DELTA columns. If DELTA is
2607negative, enlarge selected window by -DELTA lines or columns. 2606negative, enlarge selected window by -DELTA lines or columns.
2608Also see the `window-min-height' variable. 2607Also see the `window-min-height' variable."
2609Return nil."
2610 (interactive "p") 2608 (interactive "p")
2611 (let ((minibuffer-window (minibuffer-window))) 2609 (let ((minibuffer-window (minibuffer-window)))
2612 (cond 2610 (cond
@@ -5176,11 +5174,12 @@ is higher than WINDOW."
5176 (error nil)))) 5174 (error nil))))
5177 5175
5178(defun window--display-buffer (buffer window type &optional alist dedicated) 5176(defun window--display-buffer (buffer window type &optional alist dedicated)
5179 "Display BUFFER in WINDOW and make its frame visible. 5177 "Display BUFFER in WINDOW.
5180TYPE must be one of the symbols `reuse', `window' or `frame' and 5178TYPE must be one of the symbols `reuse', `window' or `frame' and
5181is passed unaltered to `display-buffer-record-window'. Set 5179is passed unaltered to `display-buffer-record-window'. ALIST is
5182`window-dedicated-p' to DEDICATED if non-nil. Return WINDOW if 5180the alist argument of `display-buffer'. Set `window-dedicated-p'
5183BUFFER and WINDOW are live." 5181to DEDICATED if non-nil. Return WINDOW if BUFFER and WINDOW are
5182live."
5184 (when (and (buffer-live-p buffer) (window-live-p window)) 5183 (when (and (buffer-live-p buffer) (window-live-p window))
5185 (display-buffer-record-window type window buffer) 5184 (display-buffer-record-window type window buffer)
5186 (unless (eq buffer (window-buffer window)) 5185 (unless (eq buffer (window-buffer window))
@@ -5193,10 +5192,10 @@ BUFFER and WINDOW are live."
5193 (let ((parameter (window-parameter window 'quit-restore)) 5192 (let ((parameter (window-parameter window 'quit-restore))
5194 (height (cdr (assq 'window-height alist))) 5193 (height (cdr (assq 'window-height alist)))
5195 (width (cdr (assq 'window-width alist)))) 5194 (width (cdr (assq 'window-width alist))))
5196 (when (or (memq type '(window frame)) 5195 (when (or (eq type 'window)
5197 (and (eq (car parameter) 'same) 5196 (and (eq (car parameter) 'same)
5198 (memq (nth 1 parameter) '(window frame)))) 5197 (eq (nth 1 parameter) 'window)))
5199 ;; Adjust height of new window or frame. 5198 ;; Adjust height of window if asked for.
5200 (cond 5199 (cond
5201 ((not height)) 5200 ((not height))
5202 ((numberp height) 5201 ((numberp height)
@@ -5207,19 +5206,12 @@ BUFFER and WINDOW are live."
5207 (* (window-total-size (frame-root-window window)) 5206 (* (window-total-size (frame-root-window window))
5208 height)))) 5207 height))))
5209 (delta (- new-height (window-total-size window)))) 5208 (delta (- new-height (window-total-size window))))
5210 (cond 5209 (when (and (window--resizable-p window delta nil 'safe)
5211 ((and (window--resizable-p window delta nil 'safe) 5210 (window-combined-p window))
5212 (window-combined-p window)) 5211 (window-resize window delta nil 'safe))))
5213 (window-resize window delta nil 'safe))
5214 ((or (eq type 'frame)
5215 (and (eq (car parameter) 'same)
5216 (eq (nth 1 parameter) 'frame)))
5217 (set-frame-height
5218 (window-frame window)
5219 (+ (frame-height (window-frame window)) delta))))))
5220 ((functionp height) 5212 ((functionp height)
5221 (ignore-errors (funcall height window)))) 5213 (ignore-errors (funcall height window))))
5222 ;; Adjust width of a window or frame. 5214 ;; Adjust width of window if asked for.
5223 (cond 5215 (cond
5224 ((not width)) 5216 ((not width))
5225 ((numberp width) 5217 ((numberp width)
@@ -5230,18 +5222,12 @@ BUFFER and WINDOW are live."
5230 (* (window-total-size (frame-root-window window) t) 5222 (* (window-total-size (frame-root-window window) t)
5231 width)))) 5223 width))))
5232 (delta (- new-width (window-total-size window t)))) 5224 (delta (- new-width (window-total-size window t))))
5233 (cond 5225 (when (and (window--resizable-p window delta t 'safe)
5234 ((and (window--resizable-p window delta t 'safe) 5226 (window-combined-p window t))
5235 (window-combined-p window t)) 5227 (window-resize window delta t 'safe))))
5236 (window-resize window delta t 'safe))
5237 ((or (eq type 'frame)
5238 (and (eq (car parameter) 'same)
5239 (eq (nth 1 parameter) 'frame)))
5240 (set-frame-width
5241 (window-frame window)
5242 (+ (frame-width (window-frame window)) delta))))))
5243 ((functionp width) 5228 ((functionp width)
5244 (ignore-errors (funcall width window)))))) 5229 (ignore-errors (funcall width window))))))
5230
5245 window)) 5231 window))
5246 5232
5247(defun window--maybe-raise-frame (frame) 5233(defun window--maybe-raise-frame (frame)
@@ -5301,13 +5287,19 @@ See `display-buffer' for details.")
5301 "Alist of conditional actions for `display-buffer'. 5287 "Alist of conditional actions for `display-buffer'.
5302This is a list of elements (CONDITION . ACTION), where: 5288This is a list of elements (CONDITION . ACTION), where:
5303 5289
5304 CONDITION is either a regexp matching buffer names, or a function 5290 CONDITION is either a regexp matching buffer names, or a
5305 that takes a buffer and returns a boolean. 5291 function that takes two arguments - a buffer name and the
5292 ACTION argument of `display-buffer' - and returns a boolean.
5306 5293
5307 ACTION is a cons cell (FUNCTION . ALIST), where FUNCTION is a 5294 ACTION is a cons cell (FUNCTION . ALIST), where FUNCTION is a
5308 function or a list of functions. Each such function should 5295 function or a list of functions. Each such function should
5309 accept two arguments: a buffer to display and an alist of the 5296 accept two arguments: a buffer to display and an alist of the
5310 same form as ALIST. See `display-buffer' for details." 5297 same form as ALIST. See `display-buffer' for details.
5298
5299`display-buffer' scans this alist until it either finds a
5300matching regular expression or the function specified by a
5301condition returns non-nil. In any of these cases, it adds the
5302associated action to the list of actions it will try."
5311 :type `(alist :key-type 5303 :type `(alist :key-type
5312 (choice :tag "Condition" 5304 (choice :tag "Condition"
5313 regexp 5305 regexp
@@ -5341,15 +5333,16 @@ specified, e.g. by the user options `display-buffer-alist' or
5341`display-buffer-base-action'. See `display-buffer'.") 5333`display-buffer-base-action'. See `display-buffer'.")
5342(put 'display-buffer-fallback-action 'risky-local-variable t) 5334(put 'display-buffer-fallback-action 'risky-local-variable t)
5343 5335
5344(defun display-buffer-assq-regexp (buffer-name alist) 5336(defun display-buffer-assq-regexp (buffer-name alist action)
5345 "Retrieve ALIST entry corresponding to BUFFER-NAME." 5337 "Retrieve ALIST entry corresponding to BUFFER-NAME.
5338ACTION is the action argument passed to `display-buffer'."
5346 (catch 'match 5339 (catch 'match
5347 (dolist (entry alist) 5340 (dolist (entry alist)
5348 (let ((key (car entry))) 5341 (let ((key (car entry)))
5349 (when (or (and (stringp key) 5342 (when (or (and (stringp key)
5350 (string-match-p key buffer-name)) 5343 (string-match-p key buffer-name))
5351 (and (symbolp key) (functionp key) 5344 (and (functionp key)
5352 (funcall key buffer-name alist))) 5345 (funcall key buffer-name action)))
5353 (throw 'match (cdr entry))))))) 5346 (throw 'match (cdr entry)))))))
5354 5347
5355(defvar display-buffer--same-window-action 5348(defvar display-buffer--same-window-action
@@ -5459,8 +5452,8 @@ argument, ACTION is t."
5459 (funcall display-buffer-function buffer inhibit-same-window) 5452 (funcall display-buffer-function buffer inhibit-same-window)
5460 ;; Otherwise, use the defined actions. 5453 ;; Otherwise, use the defined actions.
5461 (let* ((user-action 5454 (let* ((user-action
5462 (display-buffer-assq-regexp (buffer-name buffer) 5455 (display-buffer-assq-regexp
5463 display-buffer-alist)) 5456 (buffer-name buffer) display-buffer-alist action))
5464 (special-action (display-buffer--special-action buffer)) 5457 (special-action (display-buffer--special-action buffer))
5465 ;; Extra actions from the arguments to this function: 5458 ;; Extra actions from the arguments to this function:
5466 (extra-action 5459 (extra-action