aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2011-09-24 23:32:51 -0400
committerChong Yidong2011-09-24 23:32:51 -0400
commit9ec20d36df3a144ca383b8dd3574b13e479b51bb (patch)
treedb6ae409129a0dd46e8851ad14e2b9f415352a6f
parent32bbb17c0e9e4b6326232466dbb9458b074b27da (diff)
downloademacs-9ec20d36df3a144ca383b8dd3574b13e479b51bb.tar.gz
emacs-9ec20d36df3a144ca383b8dd3574b13e479b51bb.zip
Document display-buffer-alist and related variables in Lisp manual.
* doc/lispref/windows.texi (Display Action Functions) (Choosing Window Options): New nodes.
-rw-r--r--doc/lispref/ChangeLog5
-rw-r--r--doc/lispref/elisp.texi2
-rw-r--r--doc/lispref/vol1.texi2
-rw-r--r--doc/lispref/vol2.texi2
-rw-r--r--doc/lispref/windows.texi129
5 files changed, 115 insertions, 25 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index a0d069ef922..c99d5658950 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,8 @@
12011-09-25 Chong Yidong <cyd@stupidchicken.com>
2
3 * windows.texi (Display Action Functions)
4 (Choosing Window Options): New nodes.
5
12011-09-24 Chong Yidong <cyd@stupidchicken.com> 62011-09-24 Chong Yidong <cyd@stupidchicken.com>
2 7
3 * windows.texi (Window History): New node. Move text here from 8 * windows.texi (Window History): New node. Move text here from
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index 5934f452c52..45eaeb85ad8 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -937,6 +937,8 @@ Windows
937* Buffers and Windows:: Each window displays the contents of a buffer. 937* Buffers and Windows:: Each window displays the contents of a buffer.
938* Switching Buffers:: Higher-level functions for switching to a buffer. 938* Switching Buffers:: Higher-level functions for switching to a buffer.
939* Choosing Window:: How to choose a window for displaying a buffer. 939* Choosing Window:: How to choose a window for displaying a buffer.
940* Display Action Functions:: Subroutines for @code{display-buffer}.
941* Choosing Window Options:: Extra options affecting how buffers are displayed.
940* Window History:: Each window remembers the buffers displayed in it. 942* Window History:: Each window remembers the buffers displayed in it.
941* Dedicated Windows:: How to avoid displaying another buffer in 943* Dedicated Windows:: How to avoid displaying another buffer in
942 a specific window. 944 a specific window.
diff --git a/doc/lispref/vol1.texi b/doc/lispref/vol1.texi
index 0abca1ec502..0fa23d6412c 100644
--- a/doc/lispref/vol1.texi
+++ b/doc/lispref/vol1.texi
@@ -955,6 +955,8 @@ Windows
955* Buffers and Windows:: Each window displays the contents of a buffer. 955* Buffers and Windows:: Each window displays the contents of a buffer.
956* Switching Buffers:: Higher-level functions for switching to a buffer. 956* Switching Buffers:: Higher-level functions for switching to a buffer.
957* Choosing Window:: How to choose a window for displaying a buffer. 957* Choosing Window:: How to choose a window for displaying a buffer.
958* Display Action Functions:: Subroutines for @code{display-buffer}.
959* Choosing Window Options:: Extra options affecting how buffers are displayed.
958* Window History:: Each window remembers the buffers displayed in it. 960* Window History:: Each window remembers the buffers displayed in it.
959* Dedicated Windows:: How to avoid displaying another buffer in 961* Dedicated Windows:: How to avoid displaying another buffer in
960 a specific window. 962 a specific window.
diff --git a/doc/lispref/vol2.texi b/doc/lispref/vol2.texi
index f9ec9200d21..2469a742900 100644
--- a/doc/lispref/vol2.texi
+++ b/doc/lispref/vol2.texi
@@ -954,6 +954,8 @@ Windows
954* Buffers and Windows:: Each window displays the contents of a buffer. 954* Buffers and Windows:: Each window displays the contents of a buffer.
955* Switching Buffers:: Higher-level functions for switching to a buffer. 955* Switching Buffers:: Higher-level functions for switching to a buffer.
956* Choosing Window:: How to choose a window for displaying a buffer. 956* Choosing Window:: How to choose a window for displaying a buffer.
957* Display Action Functions:: Subroutines for @code{display-buffer}.
958* Choosing Window Options:: Extra options affecting how buffers are displayed.
957* Window History:: Each window remembers the buffers displayed in it. 959* Window History:: Each window remembers the buffers displayed in it.
958* Dedicated Windows:: How to avoid displaying another buffer in 960* Dedicated Windows:: How to avoid displaying another buffer in
959 a specific window. 961 a specific window.
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index f455a7d4e02..6565a014415 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -24,6 +24,8 @@ is displayed in windows.
24* Buffers and Windows:: Each window displays the contents of a buffer. 24* Buffers and Windows:: Each window displays the contents of a buffer.
25* Switching Buffers:: Higher-level functions for switching to a buffer. 25* Switching Buffers:: Higher-level functions for switching to a buffer.
26* Choosing Window:: How to choose a window for displaying a buffer. 26* Choosing Window:: How to choose a window for displaying a buffer.
27* Display Action Functions:: Subroutines for @code{display-buffer}.
28* Choosing Window Options:: Extra options affecting how buffers are displayed.
27* Window History:: Each window remembers the buffers displayed in it. 29* Window History:: Each window remembers the buffers displayed in it.
28* Dedicated Windows:: How to avoid displaying another buffer in 30* Dedicated Windows:: How to avoid displaying another buffer in
29 a specific window. 31 a specific window.
@@ -2094,11 +2096,12 @@ option @code{window-auto-delete}.
2094specified buffer in some window. 2096specified buffer in some window.
2095 2097
2096 Do @emph{not} use these functions to make a buffer temporarily 2098 Do @emph{not} use these functions to make a buffer temporarily
2097current so that a Lisp program can access or modify it; they have 2099current just so a Lisp program can access or modify it. They have
2098side-effects that may surprise the user, such as changing window 2100side-effects, such as changing window histories (@pxref{Window
2099histories (@pxref{Window History}). Instead, use 2101History}), which will surprise the user if used that way. If you want
2102to make a buffer current to modify it in Lisp, use
2100@code{with-current-buffer}, @code{save-current-buffer}, or 2103@code{with-current-buffer}, @code{save-current-buffer}, or
2101@code{set-buffer} (@pxref{Current Buffer}). 2104@code{set-buffer}. @xref{Current Buffer}.
2102 2105
2103@deffn Command switch-to-buffer buffer-or-name &optional norecord force-same-window 2106@deffn Command switch-to-buffer buffer-or-name &optional norecord force-same-window
2104This function displays @var{buffer-or-name} in the selected window, 2107This function displays @var{buffer-or-name} in the selected window,
@@ -2203,24 +2206,25 @@ used as a subroutine by many functions and commands, including
2203Buffers}). 2206Buffers}).
2204 2207
2205@cindex display action 2208@cindex display action
2209@cindex action function, for display-buffer
2210@cindex action alist, for display-buffer
2206 This command performs several complex steps to find a window to 2211 This command performs several complex steps to find a window to
2207display in. These steps are described by means of @dfn{display 2212display in. These steps are described by means of @dfn{display
2208actions}, which have the form @code{(@var{function} . @var{alist})}. 2213actions}, which have the form @code{(@var{function} . @var{alist})}.
2209Here, @var{function} is either a function or a list of functions, 2214Here, @var{function} is either a function or a list of functions,
2210while @var{alist} is an association list. In this section, we will 2215which we refer to as @dfn{action functions}; @var{alist} is an
2211refer to such functions as @dfn{action functions}, and such alists as 2216association list, which we refer to as @dfn{action alists}.
2212@dfn{action alists}. 2217
2213 2218 An action function accepts two arguments: the buffer to display and
2214 An action function should accept two arguments: the buffer to 2219an action alist. It attempts to display the buffer in some window,
2215display and an action alist. It should attempt to display the buffer 2220picking or creating a window according to its own criteria. If
2216in some window, picking or creating a window based on some internal 2221successful, it returns the window; otherwise, it returns @code{nil}.
2217criteria (as well as, optionally, the action alist). If successful, 2222@xref{Display Action Functions}, for a list of predefined action
2218it should return the window; otherwise, it should return @code{nil}. 2223functions.
2219 2224
2220 @code{display-buffer} works by combining display actions from 2225 @code{display-buffer} works by combining display actions from
2221several sources (including some user-customizable options), and 2226several sources, and calling the action functions in turn, until one
2222calling the action functions in turn, until one of the action 2227of them manages to display the buffer and returns a non-@code{nil}
2223functions manages to display the buffer and returns a non-@code{nil}
2224value. 2228value.
2225 2229
2226@deffn Command display-buffer buffer-or-name &optional action frame 2230@deffn Command display-buffer buffer-or-name &optional action frame
@@ -2248,9 +2252,7 @@ The @var{action} argument.
2248The user option @code{display-buffer-base-action}. 2252The user option @code{display-buffer-base-action}.
2249 2253
2250@item 2254@item
2251The variable @code{display-buffer-fallback-action}. This is 2255The constant @code{display-buffer-fallback-action}.
2252non-@code{nil} by default, and specifies the fallback behavior if no
2253other display actions are given.
2254@end itemize 2256@end itemize
2255 2257
2256@noindent 2258@noindent
@@ -2266,9 +2268,59 @@ with a prefix argument, @var{action} is @code{t}.
2266 2268
2267The optional argument @var{frame}, if non-@code{nil}, specifies which 2269The optional argument @var{frame}, if non-@code{nil}, specifies which
2268frames to check when deciding whether the buffer is already displayed. 2270frames to check when deciding whether the buffer is already displayed.
2269If the buffer is already displayed in some window on one of these 2271It is equivalent to adding an element @code{(reusable-frames
2270frames, @code{display-buffer} simply returns that window. Here are 2272. @var{frame})} to the action alist of @var{action}. @xref{Display
2271the possible values of @var{frame}: 2273Action Functions}.
2274@end deffn
2275
2276@defvar display-buffer-overriding-action
2277The value of this variable should be a display action, which is
2278treated with the highest priority by @code{display-buffer}. The
2279default value is empty, i.e. @code{(nil . nil)}.
2280@end defvar
2281
2282@defopt display-buffer-alist
2283The value of this option is an alist mapping regular expressions to
2284display actions. If the name of the buffer passed to
2285@code{display-buffer} matches a regular expression in this alist, then
2286@code{display-buffer} uses the corresponding display action.
2287@end defopt
2288
2289@defopt display-buffer-base-action
2290The value of this option should be a display action. This option can
2291be used to define a ``standard'' display action for calls to
2292@code{display-buffer}.
2293@end defopt
2294
2295@defvr Constant display-buffer-fallback-action
2296This display action specifies the fallback behavior for
2297@code{display-buffer} if no other display actions are given.
2298@end defvr
2299
2300@node Display Action Functions
2301@section Action Functions for @code{display-buffer}
2302
2303The following basic action functions are defined in Emacs. Each of
2304these functions takes two arguments: @var{buffer}, the buffer to
2305display, and @var{alist}, an action alist. Each action function
2306returns the window if it succeeds, and @code{nil} if it fails.
2307
2308@defun display-buffer-same-window buffer alist
2309This function tries to display @var{buffer} in the selected window.
2310It fails if the selected window is a minibuffer window or is dedicated
2311to another buffer (@pxref{Dedicated Windows}). It also fails if
2312@var{alist} has a non-nil @code{inhibit-same-window} entry.
2313@end defun
2314
2315@defun display-buffer-reuse-window buffer alist
2316This function tries to ``display'' @var{buffer} by finding a window
2317that is already displaying it.
2318
2319If @var{alist} has a non-@code{nil} @code{inhibit-same-window} entry,
2320the selected window is not eligible for reuse.
2321
2322If @var{alist} contains a @code{reusable-frames} entry, its value
2323determines which frames to search for a reusable window:
2272 2324
2273@itemize @bullet 2325@itemize @bullet
2274@item 2326@item
@@ -2284,9 +2336,36 @@ the possible values of @var{frame}:
2284A frame means consider windows on that frame only. 2336A frame means consider windows on that frame only.
2285@end itemize 2337@end itemize
2286 2338
2287Precisely how @code{display-buffer} finds or creates a window depends on 2339If @var{alist} contains no @code{reusable-frames} entry, this function
2288the variables described below. 2340normally searches just the selected frame; however, if either the
2289@end deffn 2341variable @code{display-buffer-reuse-frames} or the variable
2342@code{pop-up-frames} is non-@code{nil}, it searches all frames on the
2343current terminal. @xref{Choosing Window Options}.
2344@end defun
2345
2346@defun display-buffer-pop-up-frame buffer alist
2347This function creates a new frame, and displays the buffer in that
2348frame's window.
2349@end defun
2350
2351@defun display-buffer-pop-up-window buffer alist
2352This function tries to display @var{buffer} by splitting the selected
2353window. It uses @code{split-window-sensibly} as a subroutine
2354(@pxref{Choosing Window Options}).
2355@end defun
2356
2357@defun display-buffer-use-some-window buffer alist
2358This function tries to display @var{buffer} by choosing an existing
2359buffer and displaying the buffer in that window. It can fail if all
2360windows are dedicated to another buffer (@pxref{Dedicated Windows}).
2361@end defun
2362
2363@node Choosing Window Options
2364@section Additional Options for Displaying Buffers
2365
2366The behavior of the standard display actions of @code{display-buffer}
2367(@pxref{Choosing Window}) can be modified by a variety of user
2368options.
2290 2369
2291@defopt display-buffer-reuse-frames 2370@defopt display-buffer-reuse-frames
2292If this variable is non-@code{nil}, @code{display-buffer} searches 2371If this variable is non-@code{nil}, @code{display-buffer} searches