diff options
| author | Martin Rudalics | 2016-10-05 10:28:36 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2016-10-05 10:28:36 +0200 |
| commit | b8fd71d5709650c1aced92c772f70595c51881d2 (patch) | |
| tree | c40e7b3a63e7168d5bb337d5d19a9643fe1901f9 /doc | |
| parent | 13ba5af7427bdbd022a9d449dc2987d6a96591eb (diff) | |
| download | emacs-b8fd71d5709650c1aced92c772f70595c51881d2.tar.gz emacs-b8fd71d5709650c1aced92c772f70595c51881d2.zip | |
Document and fix some bugs with side windows
Add a documentation for side windows and fix some bugs
found when testing their behavior. Also add a new window
parameter `no-delete-other-window', a new `display-buffer'
alist member called `window-parameters', and functions to
toggle and reverse side windows on a frame. Add new function
`window-swap-states' to exchange states of two live windows.
* lisp/window.el (display-buffer-in-atom-window): Use
`split-window-no-error'.
(window-sides-vertical): Maybe change layouts when setting this
variable.
(window-sides-reversed): New option.
(window-sides-slots): Rewrite doc-string and help echoes.
(window-sides-shown): New buffer-local variable set when showing
a buffer in a side window.
(window--sides-inhibit-check): New variable.
(window--sides-reverse-on-frame-p, window-toggle-side-windows)
(window--sides-reverse-all, window--sides-reverse-frame)
(window--sides-reverse-side, window--sides-reverse)
(window--sides-verticalize-frame, window--sides-verticalize)
(window--sides-check-failed): New functions.
(window--side-window-p): Remove function.
(window--major-non-side-window): Rename to `window-main-window',
adjust callers, rewrite doc-string.
(window--major-side-window): Rename to
`window--make-major-side-window-next-to', adjust caller, fix
doc-string.
(display-buffer-in-major-side-window): Rename to
`window--make-major-side-window', adjust
caller, rewrite doc-string. Make `window-side' and
`window-slot' parameters persistent (Bug#23858). Don't set
`delete-window' parameter. Add `preserve-size' entry to ALIST.
(delete-side-window): Remove function.
(display-buffer-in-side-window): Fix doc-string. Don't set
`delete-window' parameter. Add `preserve-size' entry to ALIST.
(window--side-check): Rename to window--sides-check. Rewrite
completely. Adjust caller.
(window-resize-no-error): Don't describe PIXELWISE argument.
(adjust-window-trailing-edge): Fix bug that disallowed
re-enlarging windows that were too small.
(window-deletable-p): Don't tell that a minibuffer window on a
non-minibuffer-only frame can be deleted. Fix doc-string.
(delete-window): Handle deleting a side window here (the
`delete-window' parameter is no more set for side windows).
(delete-other-windows): Handle ‘no-delete-other-window'
parameter. Don't treat side windows separately (see discussion
of Bug#24368) but keep optimization that makes the main window
the root window of its frame.
(switch-to-prev-buffer, switch-to-next-buffer): Handle side
windows and buffers shown in side windows separately.
(split-window-no-error): New function.
(window--state-get-1): Use right buffer when storing window
point and start positions and WRITABLE is nil (Bug#24368).
(window--state-put-1): Fix handling of `window-combination-limit'.
Use `split-window-no-error'.
(window--state-put-2): Try to restore windows with preserved
size to their original size. Fix bug where a fixed window's width
was not preserved.
(window-state-put): When reducing an internal window to a live
one, don't choose a side window.
(window-swap-states): New function.
(window-splittable-p): Don't call `window--side-window-p'.
(window--display-buffer): Handle `window-parameters' ALIST entry.
Minor rewrite.
(display-buffer): Mention `window-parameters' entry in
doc-string.
(display-buffer-at-bottom): Call `split-window-no-error'.
* doc/lispref/elisp.texi (Top): New section "Side Windows".
* doc/lispref/windows.texi (Deleting Windows): Fix descriptions
of `delete-window' and `delete-other-windows' wrt window
parameters and side windows.
(Display Action Functions): Mention `window-parameters' ALIST
entry.
(Side Windows): New section (Bug#18170).
(Window Configurations): Describe new function `window-swap-states'.
(Window Parameters): Say that functions may behave specially when
their homonymous window parameter has been set. Mention new
parameter `no-delete-other-window'. Add cross reference for
`window-side' and `window-slot' parameters.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/elisp.texi | 9 | ||||
| -rw-r--r-- | doc/lispref/windows.texi | 394 |
2 files changed, 369 insertions, 34 deletions
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi index 3297e5308ae..1c6e05901c1 100644 --- a/doc/lispref/elisp.texi +++ b/doc/lispref/elisp.texi | |||
| @@ -1038,6 +1038,7 @@ Windows | |||
| 1038 | a specific window. | 1038 | a specific window. |
| 1039 | * Quitting Windows:: How to restore the state prior to displaying a | 1039 | * Quitting Windows:: How to restore the state prior to displaying a |
| 1040 | buffer. | 1040 | buffer. |
| 1041 | * Side Windows:: Special windows on a frame's sides. | ||
| 1041 | * Window Point:: Each window has its own location of point. | 1042 | * Window Point:: Each window has its own location of point. |
| 1042 | * Window Start and End:: Buffer positions indicating which text is | 1043 | * Window Start and End:: Buffer positions indicating which text is |
| 1043 | on-screen in a window. | 1044 | on-screen in a window. |
| @@ -1051,6 +1052,14 @@ Windows | |||
| 1051 | redisplay going past a certain point, | 1052 | redisplay going past a certain point, |
| 1052 | or window configuration changes. | 1053 | or window configuration changes. |
| 1053 | 1054 | ||
| 1055 | Side Windows | ||
| 1056 | |||
| 1057 | * Displaying Buffers in Side Windows:: An action function for displaying | ||
| 1058 | buffers in side windows. | ||
| 1059 | * Side Window Options and Functions:: Further tuning of side windows. | ||
| 1060 | * Frame Layouts with Side Windows:: Setting up frame layouts with side | ||
| 1061 | windows. | ||
| 1062 | |||
| 1054 | Frames | 1063 | Frames |
| 1055 | 1064 | ||
| 1056 | * Creating Frames:: Creating additional frames. | 1065 | * Creating Frames:: Creating additional frames. |
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 3c9df0b306d..3ab8c952af8 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi | |||
| @@ -33,6 +33,7 @@ is displayed in windows. | |||
| 33 | a specific window. | 33 | a specific window. |
| 34 | * Quitting Windows:: How to restore the state prior to displaying a | 34 | * Quitting Windows:: How to restore the state prior to displaying a |
| 35 | buffer. | 35 | buffer. |
| 36 | * Side Windows:: Special windows on a frame's sides. | ||
| 36 | * Window Point:: Each window has its own location of point. | 37 | * Window Point:: Each window has its own location of point. |
| 37 | * Window Start and End:: Buffer positions indicating which text is | 38 | * Window Start and End:: Buffer positions indicating which text is |
| 38 | on-screen in a window. | 39 | on-screen in a window. |
| @@ -1275,9 +1276,12 @@ Configurations}). | |||
| 1275 | @deffn Command delete-window &optional window | 1276 | @deffn Command delete-window &optional window |
| 1276 | This function removes @var{window} from display and returns | 1277 | This function removes @var{window} from display and returns |
| 1277 | @code{nil}. If @var{window} is omitted or @code{nil}, it defaults to | 1278 | @code{nil}. If @var{window} is omitted or @code{nil}, it defaults to |
| 1278 | the selected window. If deleting the window would leave no more | 1279 | the selected window. |
| 1279 | windows in the window tree (e.g., if it is the only live window in the | 1280 | |
| 1280 | frame), an error is signaled. | 1281 | If deleting the window would leave no more windows in the window tree |
| 1282 | (e.g., if it is the only live window in the frame) or all remaining | ||
| 1283 | windows on @var{window}'s frame are side windows (@pxref{Side Windows}), | ||
| 1284 | an error is signaled. | ||
| 1281 | 1285 | ||
| 1282 | By default, the space taken up by @var{window} is given to one of its | 1286 | By default, the space taken up by @var{window} is given to one of its |
| 1283 | adjacent sibling windows, if any. However, if the variable | 1287 | adjacent sibling windows, if any. However, if the variable |
| @@ -1285,33 +1289,34 @@ adjacent sibling windows, if any. However, if the variable | |||
| 1285 | proportionally distributed among any remaining windows in the same | 1289 | proportionally distributed among any remaining windows in the same |
| 1286 | window combination. @xref{Recombining Windows}. | 1290 | window combination. @xref{Recombining Windows}. |
| 1287 | 1291 | ||
| 1288 | The behavior of this function may be altered by the window parameters | 1292 | The behavior of this function may be altered by the window parameters of |
| 1289 | of @var{window}, so long as the variable | 1293 | @var{window}, so long as the variable @code{ignore-window-parameters} is |
| 1290 | @code{ignore-window-parameters} is @code{nil}. If the value of | 1294 | @code{nil}. If the value of the @code{delete-window} window parameter |
| 1291 | the @code{delete-window} window parameter is @code{t}, this function | 1295 | is @code{t}, this function ignores all other window parameters. |
| 1292 | ignores all other window parameters. Otherwise, if the value of the | 1296 | Otherwise, if the value of the @code{delete-window} window parameter is |
| 1293 | @code{delete-window} window parameter is a function, that function is | 1297 | a function, that function is called with the argument @var{window}, in |
| 1294 | called with the argument @var{window}, in lieu of the usual action of | 1298 | lieu of the usual action of @code{delete-window}. @xref{Window |
| 1295 | @code{delete-window}. Otherwise, this function obeys the | 1299 | Parameters}. |
| 1296 | @code{window-atom} or @code{window-side} window parameter, if any. | ||
| 1297 | @xref{Window Parameters}. | ||
| 1298 | @end deffn | 1300 | @end deffn |
| 1299 | 1301 | ||
| 1300 | @deffn Command delete-other-windows &optional window | 1302 | @deffn Command delete-other-windows &optional window |
| 1301 | This function makes @var{window} fill its frame, by deleting other | 1303 | This function makes @var{window} fill its frame, deleting other windows |
| 1302 | windows as necessary. If @var{window} is omitted or @code{nil}, it | 1304 | as necessary. If @var{window} is omitted or @code{nil}, it defaults to |
| 1303 | defaults to the selected window. The return value is @code{nil}. | 1305 | the selected window. An error is signaled if @var{window} is a side |
| 1304 | 1306 | window (@pxref{Side Windows}). The return value is @code{nil}. | |
| 1305 | The behavior of this function may be altered by the window parameters | 1307 | |
| 1306 | of @var{window}, so long as the variable | 1308 | The behavior of this function may be altered by the window parameters of |
| 1307 | @code{ignore-window-parameters} is @code{nil}. If the value of | 1309 | @var{window}, so long as the variable @code{ignore-window-parameters} is |
| 1308 | the @code{delete-other-windows} window parameter is @code{t}, this | 1310 | @code{nil}. If the value of the @code{delete-other-windows} window |
| 1309 | function ignores all other window parameters. Otherwise, if the value | 1311 | parameter is @code{t}, this function ignores all other window |
| 1310 | of the @code{delete-other-windows} window parameter is a function, | 1312 | parameters. Otherwise, if the value of the @code{delete-other-windows} |
| 1311 | that function is called with the argument @var{window}, in lieu of the | 1313 | window parameter is a function, that function is called with the |
| 1312 | usual action of @code{delete-other-windows}. Otherwise, this function | 1314 | argument @var{window}, in lieu of the usual action of |
| 1313 | obeys the @code{window-atom} or @code{window-side} window parameter, | 1315 | @code{delete-other-windows}. @xref{Window Parameters}. |
| 1314 | if any. @xref{Window Parameters}. | 1316 | |
| 1317 | Also, if @code{ignore-window-parameters} is @code{nil}, this function | ||
| 1318 | does not delete any window whose @code{no-delete-other-window} parameter | ||
| 1319 | is non-@code{nil}. | ||
| 1315 | @end deffn | 1320 | @end deffn |
| 1316 | 1321 | ||
| 1317 | @deffn Command delete-windows-on &optional buffer-or-name frame | 1322 | @deffn Command delete-windows-on &optional buffer-or-name frame |
| @@ -2574,7 +2579,12 @@ assumed that when the caller specifies a non-@code{nil} | |||
| 2574 | from @code{display-buffer} in this case. | 2579 | from @code{display-buffer} in this case. |
| 2575 | @end defun | 2580 | @end defun |
| 2576 | 2581 | ||
| 2577 | To illustrate the use of action functions, consider the following | 2582 | If the @var{alist} argument of any of these functions contains a |
| 2583 | @code{window-parameters} entry, @code{display-buffer} assigns the | ||
| 2584 | elements of the associated value as window parameters of the chosen | ||
| 2585 | window. | ||
| 2586 | |||
| 2587 | To illustrate the use of action functions, consider the following | ||
| 2578 | example. | 2588 | example. |
| 2579 | 2589 | ||
| 2580 | @example | 2590 | @example |
| @@ -3068,6 +3078,295 @@ other frame on the same terminal. | |||
| 3068 | @end defopt | 3078 | @end defopt |
| 3069 | 3079 | ||
| 3070 | 3080 | ||
| 3081 | @node Side Windows | ||
| 3082 | @section Side Windows | ||
| 3083 | @cindex side windows | ||
| 3084 | @cindex main window | ||
| 3085 | @cindex main window of a frame | ||
| 3086 | |||
| 3087 | Side windows are special windows positioned at any of the four sides of | ||
| 3088 | a frame's root window (@pxref{Windows and Frames}). In practice, this | ||
| 3089 | means that the area of the frame's root window is subdivided into a main | ||
| 3090 | window and a number of side windows surrounding that main window. The | ||
| 3091 | main window is either a ``normal'' live window or specifies the area | ||
| 3092 | containing all the normal windows. | ||
| 3093 | |||
| 3094 | In their most simple form of use, side windows allow to display | ||
| 3095 | specific buffers always in the same area of a frame. Hence they can be | ||
| 3096 | regarded as a generalization of the concept provided by | ||
| 3097 | @code{display-buffer-at-bottom} (@pxref{Display Action Functions}) to | ||
| 3098 | the remaining sides of a frame. With suitable customizations, however, | ||
| 3099 | side windows can be also used to provide frame layouts similar to those | ||
| 3100 | found in so-called integrated development environments (IDEs). | ||
| 3101 | |||
| 3102 | @menu | ||
| 3103 | * Displaying Buffers in Side Windows:: An action function for displaying | ||
| 3104 | buffers in side windows. | ||
| 3105 | * Side Window Options and Functions:: Further tuning of side windows. | ||
| 3106 | * Frame Layouts with Side Windows:: Setting up frame layouts with side | ||
| 3107 | windows. | ||
| 3108 | @end menu | ||
| 3109 | |||
| 3110 | |||
| 3111 | @node Displaying Buffers in Side Windows | ||
| 3112 | @subsection Displaying Buffers in Side Windows | ||
| 3113 | |||
| 3114 | The following action function for @code{display-buffer} (@pxref{Display | ||
| 3115 | Action Functions}) creates or reuses a side window for displaying the | ||
| 3116 | specified buffer. | ||
| 3117 | |||
| 3118 | @defun display-buffer-in-side-window buffer alist | ||
| 3119 | This function displays @var{buffer} in a side window of the selected | ||
| 3120 | frame. @var{alist} is an association list of symbols and values as for | ||
| 3121 | @code{display-buffer}. The following symbols in @var{alist} are special | ||
| 3122 | for this function: | ||
| 3123 | |||
| 3124 | @table @code | ||
| 3125 | @item side | ||
| 3126 | Denotes the side of the frame where the window shall be located. Valid | ||
| 3127 | values are @code{left}, @code{top}, @code{right} and @code{bottom}. If | ||
| 3128 | unspecified, the window is located at the bottom of the frame. | ||
| 3129 | |||
| 3130 | @item slot | ||
| 3131 | Denotes a slot at the specified side where to locate the window. A | ||
| 3132 | value of zero means to preferably position the window in the middle of | ||
| 3133 | the specified side. A negative value means to use a slot preceding | ||
| 3134 | (that is, above or on the left of) the middle slot. A positive value | ||
| 3135 | means to use a slot following (that is, below or on the right of) the | ||
| 3136 | middle slot. Hence, all windows on a specific side are ordered by their | ||
| 3137 | @code{slot} value. If unspecified, the window is located in the middle | ||
| 3138 | of the specified side. | ||
| 3139 | @end table | ||
| 3140 | |||
| 3141 | If you specify the same slot on the same side for two or more different | ||
| 3142 | buffers, the buffer displayed last is shown in the corresponding window. | ||
| 3143 | Hence, slots can be used for sharing the same side window between | ||
| 3144 | buffers. | ||
| 3145 | |||
| 3146 | This function installs the @code{window-side} and @code{window-slot} | ||
| 3147 | parameters (@pxref{Window Parameters}) and makes them persistent. It | ||
| 3148 | does not install any other window parameters unless they have been | ||
| 3149 | explicitly provided via a @code{window-parameters} entry in @var{alist}. | ||
| 3150 | @end defun | ||
| 3151 | |||
| 3152 | By default, side windows cannot be split via @code{split-window} | ||
| 3153 | (@pxref{Splitting Windows}). Also, a side window is not reused or split | ||
| 3154 | by any buffer display action (@pxref{Display Action Functions}) unless | ||
| 3155 | it is explicitly specified as target of that action. Note also that | ||
| 3156 | @code{delete-other-windows} cannot make a side window the only window on | ||
| 3157 | its frame (@pxref{Deleting Windows}). | ||
| 3158 | |||
| 3159 | Once set up, side windows also change the behavior of the commands | ||
| 3160 | @code{switch-to-prev-buffer} and @code{switch-to-next-buffer} | ||
| 3161 | (@pxref{Window History}). In particular, these commands will refrain | ||
| 3162 | from showing, in a side window, buffers that have not been displayed in | ||
| 3163 | that window before. And, they will refrain from having a normal, | ||
| 3164 | non-side window show a buffer that has been already displayed in a side | ||
| 3165 | window. A notable exception to the latter rule occurs when an | ||
| 3166 | application, after displaying a buffer, resets that buffer's local | ||
| 3167 | variables. | ||
| 3168 | |||
| 3169 | |||
| 3170 | @node Side Window Options and Functions | ||
| 3171 | @subsection Side Window Options and Functions | ||
| 3172 | |||
| 3173 | The following options provide additional control over the placement of | ||
| 3174 | side windows. | ||
| 3175 | |||
| 3176 | @defopt window-sides-vertical | ||
| 3177 | If non-@code{nil}, this means that the side windows on the left and | ||
| 3178 | right of a frame occupy the frame's full height. Otherwise, the side | ||
| 3179 | windows on the top and bottom of the frame occupy the frame's full | ||
| 3180 | width. | ||
| 3181 | @end defopt | ||
| 3182 | |||
| 3183 | @defopt window-sides-slots | ||
| 3184 | This option specifies the maximum number of side windows on each side of | ||
| 3185 | a frame. The value is a list of four elements specifying the number of | ||
| 3186 | side window slots on (in this order) the left, top, right and bottom of | ||
| 3187 | each frame. If an element is a number, this means to display at most | ||
| 3188 | that many windows on the corresponding side. If an element is | ||
| 3189 | @code{nil}, this means there's no bound on the number of slots on that | ||
| 3190 | side. | ||
| 3191 | |||
| 3192 | If any of the specified values is zero, no window can be created on the | ||
| 3193 | corresponding side. @code{display-buffer-in-side-window} will not | ||
| 3194 | signal an error in that case but return @code{nil}. If a specified | ||
| 3195 | value just forbids the creation of an additional side window, the most | ||
| 3196 | suitable window on that side is reused and may have its | ||
| 3197 | @code{window-slot} parameter changed accordingly. | ||
| 3198 | @end defopt | ||
| 3199 | |||
| 3200 | @defopt window-sides-reversed | ||
| 3201 | This option specifies whether top/bottom side windows should appear in | ||
| 3202 | reverse order. When this is @code{nil}, side windows on the top and | ||
| 3203 | bottom of a frame are always drawn from left to right with increasing | ||
| 3204 | slot values. When this is @code{t}, the drawing order is reversed and | ||
| 3205 | side windows on the top and bottom of a frame are drawn from right to | ||
| 3206 | left with increasing slot values. | ||
| 3207 | |||
| 3208 | When this is @code{bidi}, the drawing order is reversed if and only if | ||
| 3209 | the value of @code{bidi-paragraph-direction} is @code{right-to-left} in | ||
| 3210 | the buffer displayed in the window most recently selected within the | ||
| 3211 | main window area of this frame. Sometimes that window may be hard to | ||
| 3212 | find, so heuristics are used to avoid that the drawing order changes | ||
| 3213 | inadvertently when another window gets selected. | ||
| 3214 | |||
| 3215 | The layout of side windows on the left or right of a frame is not | ||
| 3216 | affected by the value of this variable. | ||
| 3217 | @end defopt | ||
| 3218 | |||
| 3219 | When a frame has side windows, the following function returns the main | ||
| 3220 | window of that frame. | ||
| 3221 | |||
| 3222 | @defun window-main-window &optional frame | ||
| 3223 | This function returns the main window of the specified @var{frame}. The | ||
| 3224 | optional argument @var{frame} must be a live frame and defaults to the | ||
| 3225 | selected one. | ||
| 3226 | |||
| 3227 | If @var{frame} has no side windows, it returns @var{frame}'s root | ||
| 3228 | window. Otherwise, it returns either an internal non-side window such | ||
| 3229 | that all other non-side windows on @var{frame} descend from it, or the | ||
| 3230 | single live non-side window of @var{frame}. Note that the main window | ||
| 3231 | of a frame cannot be deleted via @code{delete-window}. | ||
| 3232 | @end defun | ||
| 3233 | |||
| 3234 | The following command is handy to toggle the appearance of all side | ||
| 3235 | windows on a specified frame. | ||
| 3236 | |||
| 3237 | @deffn Command window-toggle-side-windows &optional frame | ||
| 3238 | This command toggles side windows on the specified @var{frame}. The | ||
| 3239 | optional argument @var{frame} must be a live frame and defaults to the | ||
| 3240 | selected one. | ||
| 3241 | |||
| 3242 | If @var{frame} has at least one side window, this command saves the | ||
| 3243 | state of @var{frame}'s root window in the @var{frame}'s | ||
| 3244 | @code{window-state} frame parameter and deletes all side windows on | ||
| 3245 | @var{frame} afterwards. | ||
| 3246 | |||
| 3247 | If @var{frame} has no side window but a @code{window-state} parameter, | ||
| 3248 | it uses that parameter's value to restore the side windows on | ||
| 3249 | @var{frame} leaving @var{frame}'s main window alone. | ||
| 3250 | |||
| 3251 | An error is signaled if @var{frame} has no side window and no saved | ||
| 3252 | state is found. | ||
| 3253 | @end deffn | ||
| 3254 | |||
| 3255 | |||
| 3256 | @node Frame Layouts with Side Windows | ||
| 3257 | @subsection Frame Layouts with Side Windows | ||
| 3258 | |||
| 3259 | Side windows can be used to create more complex frame layouts like those | ||
| 3260 | provided by integrated development environments (IDEs). In such | ||
| 3261 | layouts, the area of the main window is where the normal editing | ||
| 3262 | activities take place. Side windows are not conceived for editing in | ||
| 3263 | the usual sense. Rather, they are supposed to display information | ||
| 3264 | complementary to the current editing activity, like lists of files, tags | ||
| 3265 | or buffers, help information, search or grep results or shell output. | ||
| 3266 | |||
| 3267 | The layout of such a frame might appear as follows: | ||
| 3268 | |||
| 3269 | @smallexample | ||
| 3270 | @group | ||
| 3271 | ___________________________________ | ||
| 3272 | | *Buffer List* | | ||
| 3273 | |___________________________________| | ||
| 3274 | | | | | | ||
| 3275 | | * | | * | | ||
| 3276 | | d | | T | | ||
| 3277 | | i | | a | | ||
| 3278 | | r | Main Window Area | g | | ||
| 3279 | | e | | s | | ||
| 3280 | | d | | * | | ||
| 3281 | | * | | | | ||
| 3282 | |_____|_______________________|_____| | ||
| 3283 | | *help*/*grep*/ | *shell*/ | | ||
| 3284 | | *Completions* | *compilation* | | ||
| 3285 | |_________________|_________________| | ||
| 3286 | | Echo Area | | ||
| 3287 | |___________________________________| | ||
| 3288 | |||
| 3289 | |||
| 3290 | @end group | ||
| 3291 | @end smallexample | ||
| 3292 | |||
| 3293 | The following example illustrates how window parameters (@pxref{Window | ||
| 3294 | Parameters}) can be used with @code{display-buffer-in-side-window} | ||
| 3295 | (@pxref{Displaying Buffers in Side Windows}) to set up code for | ||
| 3296 | producing the frame sketched above. | ||
| 3297 | |||
| 3298 | @example | ||
| 3299 | @group | ||
| 3300 | (defvar parameters | ||
| 3301 | '(window-parameters . ((no-other-window . t) (no-delete-other-window . t)))) | ||
| 3302 | |||
| 3303 | (setq fit-window-to-buffer-horizontally t) | ||
| 3304 | (setq window-resize-pixelwise t) | ||
| 3305 | |||
| 3306 | (setq | ||
| 3307 | display-buffer-alist | ||
| 3308 | `(("\\*Buffer List\\*" display-buffer-in-side-window | ||
| 3309 | (side . top) (slot . 0) (window-height . fit-window-to-buffer) | ||
| 3310 | (preserve-size . (nil . t)) ,parameters) | ||
| 3311 | ("\\*Tags List\\*" display-buffer-in-side-window | ||
| 3312 | (side . right) (slot . 0) (window-width . fit-window-to-buffer) | ||
| 3313 | (preserve-size . (t . nil)) ,parameters) | ||
| 3314 | ("\\*\\(?:help\\|grep\\|Completions\\)\\*" display-buffer-in-side-window | ||
| 3315 | (side . bottom) (slot . -1) (preserve-size . (nil . t)) ,parameters) | ||
| 3316 | ("\\*\\(?:shell\\|compilation\\)\\*" display-buffer-in-side-window | ||
| 3317 | (side . bottom) (slot . 1) (preserve-size . (nil . t)) ,parameters))) | ||
| 3318 | @end group | ||
| 3319 | @end example | ||
| 3320 | |||
| 3321 | This specifies @code{display-buffer-alist} entries (@pxref{Choosing | ||
| 3322 | Window}) for buffers with fixed names. In particular, it asks for | ||
| 3323 | showing @file{*Buffer List*} with adjustable height at the top of the | ||
| 3324 | frame and @file{*Tags List*} with adjustable width on the frame's right. | ||
| 3325 | It also asks for having the @file{*help*}, @file{*grep*} and | ||
| 3326 | @file{*Completions*} buffers share a window on the bottom left side of | ||
| 3327 | the frame and the @file{*shell*} and @file{*compilation*} buffers appear | ||
| 3328 | in a window on the bottom right side of the frame. | ||
| 3329 | |||
| 3330 | Note that the option @code{fit-window-to-buffer-horizontally} must | ||
| 3331 | have a non-@code{nil} value in order to allow horizontal adjustment of | ||
| 3332 | windows. We also added entries that ask for preserving the height of | ||
| 3333 | side windows at the top and bottom of the frame and the width of side | ||
| 3334 | windows at the left or right of the frame. To assure that side windows | ||
| 3335 | retain their respective sizes when maximizing the associated frame, we | ||
| 3336 | have also set the variable @code{window-resize-pixelwise}. | ||
| 3337 | @xref{Resizing Windows}. | ||
| 3338 | |||
| 3339 | The last form also makes sure that none of the side windows it | ||
| 3340 | creates are accessible via @kbd{C-x o} by installing a | ||
| 3341 | @code{no-other-window} parameter for each of these windows. In addition | ||
| 3342 | it also makes sure that side windows are not deleted via @kbd{C-x 1} by | ||
| 3343 | installing a @code{no-delete-other-window} parameter on each of these | ||
| 3344 | windows. | ||
| 3345 | |||
| 3346 | Since @code{dired} buffers have no fixed names, we use a special | ||
| 3347 | function @code{dired-default-directory-on-left} in order to display a | ||
| 3348 | lean directory buffer on the left side of the frame. | ||
| 3349 | |||
| 3350 | @example | ||
| 3351 | @group | ||
| 3352 | (defun dired-default-directory-on-left () | ||
| 3353 | "Display `default-directory' in side window on left, hiding details." | ||
| 3354 | (interactive) | ||
| 3355 | (let ((buffer (dired-noselect default-directory))) | ||
| 3356 | (with-current-buffer buffer (dired-hide-details-mode t)) | ||
| 3357 | (display-buffer-in-side-window | ||
| 3358 | buffer `((side . left) (slot . 0) | ||
| 3359 | (window-width . fit-window-to-buffer) | ||
| 3360 | (preserve-size . (t . nil)) ,parameters)))) | ||
| 3361 | @end group | ||
| 3362 | @end example | ||
| 3363 | |||
| 3364 | Evaluating the preceding forms and typing, in any order, @kbd{M-x | ||
| 3365 | list-buffers}, @kbd{C-h f}, @kbd{M-x shell}, @kbd{M-x list-tags} and | ||
| 3366 | @kbd{M-x dired-default-directory-on-left} should now reproduce the frame | ||
| 3367 | layout sketched above. | ||
| 3368 | |||
| 3369 | |||
| 3071 | @node Window Point | 3370 | @node Window Point |
| 3072 | @section Windows and Point | 3371 | @section Windows and Point |
| 3073 | @cindex window position | 3372 | @cindex window position |
| @@ -4242,6 +4541,25 @@ is @code{safe}, this means windows can get as small as one line | |||
| 4242 | and/or two columns. | 4541 | and/or two columns. |
| 4243 | @end defun | 4542 | @end defun |
| 4244 | 4543 | ||
| 4544 | The functions @code{window-state-get} and @code{window-state-put} also | ||
| 4545 | allow to exchange the contents of two live windows. The following | ||
| 4546 | function does precisely that: | ||
| 4547 | |||
| 4548 | @deffn Command window-swap-states &optional window-1 window-2 size | ||
| 4549 | This command swaps the states of the two live windows @var{window-1} and | ||
| 4550 | @var{window-2}. @var{window-1} must specify a live window and defaults | ||
| 4551 | to the selected one. @var{window-2} must specify a live window and | ||
| 4552 | defaults to the window following @var{window-1} in the cyclic ordering | ||
| 4553 | of windows, excluding minibuffer windows and including live windows on | ||
| 4554 | all visible frames. | ||
| 4555 | |||
| 4556 | Optional argument @var{size} non-@code{nil} means to try swapping the | ||
| 4557 | sizes of @var{window-1} and @var{window-2} as well. A value of | ||
| 4558 | @code{height} means to swap heights only, a value of @code{width} | ||
| 4559 | means to swap widths only, while @code{t} means to swap both widths | ||
| 4560 | and heights, if possible. Frames are not resized by this function. | ||
| 4561 | @end deffn | ||
| 4562 | |||
| 4245 | 4563 | ||
| 4246 | @node Window Parameters | 4564 | @node Window Parameters |
| 4247 | @section Window Parameters | 4565 | @section Window Parameters |
| @@ -4279,6 +4597,7 @@ earlier by @code{window-state-get}, all cloned windows have their | |||
| 4279 | parameters reset to @code{nil}. The following variable allows you to | 4597 | parameters reset to @code{nil}. The following variable allows you to |
| 4280 | override the standard behavior: | 4598 | override the standard behavior: |
| 4281 | 4599 | ||
| 4600 | @cindex persistent window parameters | ||
| 4282 | @defvar window-persistent-parameters | 4601 | @defvar window-persistent-parameters |
| 4283 | This variable is an alist specifying which parameters get saved by | 4602 | This variable is an alist specifying which parameters get saved by |
| 4284 | @code{current-window-configuration} and @code{window-state-get}, and | 4603 | @code{current-window-configuration} and @code{window-state-get}, and |
| @@ -4308,10 +4627,10 @@ may fail with an @code{invalid-read-syntax} error. | |||
| 4308 | @end defvar | 4627 | @end defvar |
| 4309 | 4628 | ||
| 4310 | Some functions (notably @code{delete-window}, | 4629 | Some functions (notably @code{delete-window}, |
| 4311 | @code{delete-other-windows} and @code{split-window}), may behave specially | 4630 | @code{delete-other-windows} and @code{split-window}), may behave |
| 4312 | when their @var{window} argument has a parameter set. You can override | 4631 | specially when the window specified by their @var{window} argument has |
| 4313 | such special behavior by binding the following variable to a | 4632 | the homonymous parameter set. You can override such special behavior by |
| 4314 | non-@code{nil} value: | 4633 | binding the following variable to a non-@code{nil} value: |
| 4315 | 4634 | ||
| 4316 | @defvar ignore-window-parameters | 4635 | @defvar ignore-window-parameters |
| 4317 | If this variable is non-@code{nil}, some standard functions do not | 4636 | If this variable is non-@code{nil}, some standard functions do not |
| @@ -4337,6 +4656,10 @@ This parameter affects the execution of @code{delete-window} | |||
| 4337 | This parameter affects the execution of @code{delete-other-windows} | 4656 | This parameter affects the execution of @code{delete-other-windows} |
| 4338 | (@pxref{Deleting Windows}). | 4657 | (@pxref{Deleting Windows}). |
| 4339 | 4658 | ||
| 4659 | @item @code{no-delete-other-window} | ||
| 4660 | This parameter marks the window as not deletable by | ||
| 4661 | @code{delete-other-windows} (@pxref{Deleting Windows}). | ||
| 4662 | |||
| 4340 | @item @code{split-window} | 4663 | @item @code{split-window} |
| 4341 | This parameter affects the execution of @code{split-window} | 4664 | This parameter affects the execution of @code{split-window} |
| 4342 | (@pxref{Splitting Windows}). | 4665 | (@pxref{Splitting Windows}). |
| @@ -4387,6 +4710,10 @@ The fourth element is the buffer whose display caused the creation of | |||
| 4387 | this parameter. @code{quit-restore-window} deletes the specified window | 4710 | this parameter. @code{quit-restore-window} deletes the specified window |
| 4388 | only if it still shows that buffer. | 4711 | only if it still shows that buffer. |
| 4389 | 4712 | ||
| 4713 | @item @code{window-side} @code{window-slot} | ||
| 4714 | These parameters are used for implementing side windows (@pxref{Side | ||
| 4715 | Windows}). | ||
| 4716 | |||
| 4390 | @item @code{min-margins} | 4717 | @item @code{min-margins} |
| 4391 | The value of this parameter is a cons cell whose @sc{car} and @sc{cdr}, | 4718 | The value of this parameter is a cons cell whose @sc{car} and @sc{cdr}, |
| 4392 | if non-@code{nil}, specify the minimum values (in columns) for the left | 4719 | if non-@code{nil}, specify the minimum values (in columns) for the left |
| @@ -4409,8 +4736,7 @@ applications. It might be replaced by an improved solution in future | |||
| 4409 | versions of Emacs. | 4736 | versions of Emacs. |
| 4410 | @end table | 4737 | @end table |
| 4411 | 4738 | ||
| 4412 | There are additional parameters @code{window-atom} and @code{window-side}; | 4739 | The @code{window-atom} parameter is used for implemeting atomic windows. |
| 4413 | these are reserved and should not be used by applications. | ||
| 4414 | 4740 | ||
| 4415 | 4741 | ||
| 4416 | @node Window Hooks | 4742 | @node Window Hooks |