diff options
| author | Chong Yidong | 2011-09-24 23:32:51 -0400 |
|---|---|---|
| committer | Chong Yidong | 2011-09-24 23:32:51 -0400 |
| commit | 9ec20d36df3a144ca383b8dd3574b13e479b51bb (patch) | |
| tree | db6ae409129a0dd46e8851ad14e2b9f415352a6f | |
| parent | 32bbb17c0e9e4b6326232466dbb9458b074b27da (diff) | |
| download | emacs-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/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/elisp.texi | 2 | ||||
| -rw-r--r-- | doc/lispref/vol1.texi | 2 | ||||
| -rw-r--r-- | doc/lispref/vol2.texi | 2 | ||||
| -rw-r--r-- | doc/lispref/windows.texi | 129 |
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 @@ | |||
| 1 | 2011-09-25 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * windows.texi (Display Action Functions) | ||
| 4 | (Choosing Window Options): New nodes. | ||
| 5 | |||
| 1 | 2011-09-24 Chong Yidong <cyd@stupidchicken.com> | 6 | 2011-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}. | |||
| 2094 | specified buffer in some window. | 2096 | specified 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 |
| 2097 | current so that a Lisp program can access or modify it; they have | 2099 | current just so a Lisp program can access or modify it. They have |
| 2098 | side-effects that may surprise the user, such as changing window | 2100 | side-effects, such as changing window histories (@pxref{Window |
| 2099 | histories (@pxref{Window History}). Instead, use | 2101 | History}), which will surprise the user if used that way. If you want |
| 2102 | to 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 |
| 2104 | This function displays @var{buffer-or-name} in the selected window, | 2107 | This function displays @var{buffer-or-name} in the selected window, |
| @@ -2203,24 +2206,25 @@ used as a subroutine by many functions and commands, including | |||
| 2203 | Buffers}). | 2206 | Buffers}). |
| 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 |
| 2207 | display in. These steps are described by means of @dfn{display | 2212 | display in. These steps are described by means of @dfn{display |
| 2208 | actions}, which have the form @code{(@var{function} . @var{alist})}. | 2213 | actions}, which have the form @code{(@var{function} . @var{alist})}. |
| 2209 | Here, @var{function} is either a function or a list of functions, | 2214 | Here, @var{function} is either a function or a list of functions, |
| 2210 | while @var{alist} is an association list. In this section, we will | 2215 | which we refer to as @dfn{action functions}; @var{alist} is an |
| 2211 | refer to such functions as @dfn{action functions}, and such alists as | 2216 | association 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 | 2219 | an action alist. It attempts to display the buffer in some window, |
| 2215 | display and an action alist. It should attempt to display the buffer | 2220 | picking or creating a window according to its own criteria. If |
| 2216 | in some window, picking or creating a window based on some internal | 2221 | successful, it returns the window; otherwise, it returns @code{nil}. |
| 2217 | criteria (as well as, optionally, the action alist). If successful, | 2222 | @xref{Display Action Functions}, for a list of predefined action |
| 2218 | it should return the window; otherwise, it should return @code{nil}. | 2223 | functions. |
| 2219 | 2224 | ||
| 2220 | @code{display-buffer} works by combining display actions from | 2225 | @code{display-buffer} works by combining display actions from |
| 2221 | several sources (including some user-customizable options), and | 2226 | several sources, and calling the action functions in turn, until one |
| 2222 | calling the action functions in turn, until one of the action | 2227 | of them manages to display the buffer and returns a non-@code{nil} |
| 2223 | functions manages to display the buffer and returns a non-@code{nil} | ||
| 2224 | value. | 2228 | value. |
| 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. | |||
| 2248 | The user option @code{display-buffer-base-action}. | 2252 | The user option @code{display-buffer-base-action}. |
| 2249 | 2253 | ||
| 2250 | @item | 2254 | @item |
| 2251 | The variable @code{display-buffer-fallback-action}. This is | 2255 | The constant @code{display-buffer-fallback-action}. |
| 2252 | non-@code{nil} by default, and specifies the fallback behavior if no | ||
| 2253 | other 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 | ||
| 2267 | The optional argument @var{frame}, if non-@code{nil}, specifies which | 2269 | The optional argument @var{frame}, if non-@code{nil}, specifies which |
| 2268 | frames to check when deciding whether the buffer is already displayed. | 2270 | frames to check when deciding whether the buffer is already displayed. |
| 2269 | If the buffer is already displayed in some window on one of these | 2271 | It is equivalent to adding an element @code{(reusable-frames |
| 2270 | frames, @code{display-buffer} simply returns that window. Here are | 2272 | . @var{frame})} to the action alist of @var{action}. @xref{Display |
| 2271 | the possible values of @var{frame}: | 2273 | Action Functions}. |
| 2274 | @end deffn | ||
| 2275 | |||
| 2276 | @defvar display-buffer-overriding-action | ||
| 2277 | The value of this variable should be a display action, which is | ||
| 2278 | treated with the highest priority by @code{display-buffer}. The | ||
| 2279 | default value is empty, i.e. @code{(nil . nil)}. | ||
| 2280 | @end defvar | ||
| 2281 | |||
| 2282 | @defopt display-buffer-alist | ||
| 2283 | The value of this option is an alist mapping regular expressions to | ||
| 2284 | display 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 | ||
| 2290 | The value of this option should be a display action. This option can | ||
| 2291 | be 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 | ||
| 2296 | This 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 | |||
| 2303 | The following basic action functions are defined in Emacs. Each of | ||
| 2304 | these functions takes two arguments: @var{buffer}, the buffer to | ||
| 2305 | display, and @var{alist}, an action alist. Each action function | ||
| 2306 | returns the window if it succeeds, and @code{nil} if it fails. | ||
| 2307 | |||
| 2308 | @defun display-buffer-same-window buffer alist | ||
| 2309 | This function tries to display @var{buffer} in the selected window. | ||
| 2310 | It fails if the selected window is a minibuffer window or is dedicated | ||
| 2311 | to 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 | ||
| 2316 | This function tries to ``display'' @var{buffer} by finding a window | ||
| 2317 | that is already displaying it. | ||
| 2318 | |||
| 2319 | If @var{alist} has a non-@code{nil} @code{inhibit-same-window} entry, | ||
| 2320 | the selected window is not eligible for reuse. | ||
| 2321 | |||
| 2322 | If @var{alist} contains a @code{reusable-frames} entry, its value | ||
| 2323 | determines 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}: | |||
| 2284 | A frame means consider windows on that frame only. | 2336 | A frame means consider windows on that frame only. |
| 2285 | @end itemize | 2337 | @end itemize |
| 2286 | 2338 | ||
| 2287 | Precisely how @code{display-buffer} finds or creates a window depends on | 2339 | If @var{alist} contains no @code{reusable-frames} entry, this function |
| 2288 | the variables described below. | 2340 | normally searches just the selected frame; however, if either the |
| 2289 | @end deffn | 2341 | variable @code{display-buffer-reuse-frames} or the variable |
| 2342 | @code{pop-up-frames} is non-@code{nil}, it searches all frames on the | ||
| 2343 | current terminal. @xref{Choosing Window Options}. | ||
| 2344 | @end defun | ||
| 2345 | |||
| 2346 | @defun display-buffer-pop-up-frame buffer alist | ||
| 2347 | This function creates a new frame, and displays the buffer in that | ||
| 2348 | frame's window. | ||
| 2349 | @end defun | ||
| 2350 | |||
| 2351 | @defun display-buffer-pop-up-window buffer alist | ||
| 2352 | This function tries to display @var{buffer} by splitting the selected | ||
| 2353 | window. 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 | ||
| 2358 | This function tries to display @var{buffer} by choosing an existing | ||
| 2359 | buffer and displaying the buffer in that window. It can fail if all | ||
| 2360 | windows 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 | |||
| 2366 | The behavior of the standard display actions of @code{display-buffer} | ||
| 2367 | (@pxref{Choosing Window}) can be modified by a variety of user | ||
| 2368 | options. | ||
| 2290 | 2369 | ||
| 2291 | @defopt display-buffer-reuse-frames | 2370 | @defopt display-buffer-reuse-frames |
| 2292 | If this variable is non-@code{nil}, @code{display-buffer} searches | 2371 | If this variable is non-@code{nil}, @code{display-buffer} searches |