diff options
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/windows.texi | 106 |
1 files changed, 72 insertions, 34 deletions
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 6ac7aa67286..6b716323357 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi | |||
| @@ -6046,8 +6046,8 @@ buffer are (re)fontified because a window was scrolled or its size | |||
| 6046 | changed. @xref{Other Font Lock Variables}. | 6046 | changed. @xref{Other Font Lock Variables}. |
| 6047 | 6047 | ||
| 6048 | @cindex window change functions | 6048 | @cindex window change functions |
| 6049 | The remainder of this section covers five hooks that are called at | 6049 | The remainder of this section covers six hooks that are called |
| 6050 | the end of redisplay provided a significant, non-scrolling change of a | 6050 | during redisplay provided a significant, non-scrolling change of a |
| 6051 | window has been detected. For simplicity, these hooks and the | 6051 | window has been detected. For simplicity, these hooks and the |
| 6052 | functions they call will be collectively referred to as @dfn{window | 6052 | functions they call will be collectively referred to as @dfn{window |
| 6053 | change functions}. | 6053 | change functions}. |
| @@ -6058,9 +6058,9 @@ detected, which means that a window was created, deleted or assigned | |||
| 6058 | another buffer. | 6058 | another buffer. |
| 6059 | 6059 | ||
| 6060 | @defvar window-buffer-change-functions | 6060 | @defvar window-buffer-change-functions |
| 6061 | This variable specifies functions called at the end of redisplay when | 6061 | This variable specifies functions called during redisplay when window |
| 6062 | window buffers have changed. The value should be a list of functions | 6062 | buffers have changed. The value should be a list of functions that |
| 6063 | that take one argument. | 6063 | take one argument. |
| 6064 | 6064 | ||
| 6065 | Functions specified buffer-locally are called for any window showing | 6065 | Functions specified buffer-locally are called for any window showing |
| 6066 | the corresponding buffer if that window has been created or assigned | 6066 | the corresponding buffer if that window has been created or assigned |
| @@ -6074,14 +6074,14 @@ In this case the frame is passed as argument. | |||
| 6074 | @end defvar | 6074 | @end defvar |
| 6075 | 6075 | ||
| 6076 | @cindex window size change | 6076 | @cindex window size change |
| 6077 | The second of these hooks is run after a @dfn{window size change} has | 6077 | The second of these hooks is run when a @dfn{window size change} has |
| 6078 | been detected which means that a window was created, assigned another | 6078 | been detected which means that a window was created, assigned another |
| 6079 | buffer, or changed its total size or that of its text area. | 6079 | buffer, or changed its total size or that of its text area. |
| 6080 | 6080 | ||
| 6081 | @defvar window-size-change-functions | 6081 | @defvar window-size-change-functions |
| 6082 | This variable specifies functions called at the end of redisplay when | 6082 | This variable specifies functions called during redisplay when a |
| 6083 | a window size change occurred. The value should be a list of | 6083 | window size change occurred. The value should be a list of functions |
| 6084 | functions that take one argument. | 6084 | that take one argument. |
| 6085 | 6085 | ||
| 6086 | Functions specified buffer-locally are called for any window showing | 6086 | Functions specified buffer-locally are called for any window showing |
| 6087 | the corresponding buffer if that window has been added or assigned | 6087 | the corresponding buffer if that window has been added or assigned |
| @@ -6097,13 +6097,13 @@ argument. | |||
| 6097 | @end defvar | 6097 | @end defvar |
| 6098 | 6098 | ||
| 6099 | @cindex window selection change | 6099 | @cindex window selection change |
| 6100 | The third of these hooks is run after a @dfn{window selection change} | 6100 | The third of these hooks is run when a @dfn{window selection change} |
| 6101 | has selected another window since the last redisplay. | 6101 | has selected another window since the last redisplay. |
| 6102 | 6102 | ||
| 6103 | @defvar window-selection-change-functions | 6103 | @defvar window-selection-change-functions |
| 6104 | This variable specifies functions called at the end of redisplay when | 6104 | This variable specifies functions called during redisplay when the |
| 6105 | the selected window or a frame's selected window has changed. The | 6105 | selected window or a frame's selected window has changed. The value |
| 6106 | value should be a list of functions that take one argument. | 6106 | should be a list of functions that take one argument. |
| 6107 | 6107 | ||
| 6108 | Functions specified buffer-locally are called for any window showing | 6108 | Functions specified buffer-locally are called for any window showing |
| 6109 | the corresponding buffer if that window has been selected or | 6109 | the corresponding buffer if that window has been selected or |
| @@ -6118,13 +6118,13 @@ run. In this case the frame is passed as argument. | |||
| 6118 | @end defvar | 6118 | @end defvar |
| 6119 | 6119 | ||
| 6120 | @cindex window state change | 6120 | @cindex window state change |
| 6121 | The fourth of these hooks is run after a @dfn{window state change} has | 6121 | The fourth of these hooks is run when a @dfn{window state change} has |
| 6122 | been detected, which means that at least one of the three preceding | 6122 | been detected, which means that at least one of the three preceding |
| 6123 | window changes has occurred. | 6123 | window changes has occurred. |
| 6124 | 6124 | ||
| 6125 | @defvar window-state-change-functions | 6125 | @defvar window-state-change-functions |
| 6126 | This variable specifies functions called at the end of redisplay when | 6126 | This variable specifies functions called during redisplay when a |
| 6127 | a window buffer or size change occurred or the selected window or a | 6127 | window buffer or size change occurred or the selected window or a |
| 6128 | frame's selected window has changed. The value should be a list of | 6128 | frame's selected window has changed. The value should be a list of |
| 6129 | functions that take one argument. | 6129 | functions that take one argument. |
| 6130 | 6130 | ||
| @@ -6141,6 +6141,10 @@ another buffer, changed its total or body size or that frame has been | |||
| 6141 | selected or deselected or the frame's selected window has changed | 6141 | selected or deselected or the frame's selected window has changed |
| 6142 | since the last time window change functions were run. In this case | 6142 | since the last time window change functions were run. In this case |
| 6143 | the frame is passed as argument. | 6143 | the frame is passed as argument. |
| 6144 | |||
| 6145 | Functions specified by the default value are also run for a frame when | ||
| 6146 | that frame's window state change flag (see below) has been set since | ||
| 6147 | last redisplay. | ||
| 6144 | @end defvar | 6148 | @end defvar |
| 6145 | 6149 | ||
| 6146 | @cindex window configuration change | 6150 | @cindex window configuration change |
| @@ -6150,9 +6154,9 @@ size of a window changed. It differs from the four preceding hooks in | |||
| 6150 | the way it is run. | 6154 | the way it is run. |
| 6151 | 6155 | ||
| 6152 | @defvar window-configuration-change-hook | 6156 | @defvar window-configuration-change-hook |
| 6153 | This variable specifies functions called at the end of redisplay when | 6157 | This variable specifies functions called during redisplay when either |
| 6154 | either the buffer or the size of a window has changed. The value | 6158 | the buffer or the size of a window has changed. The value should be a |
| 6155 | should be a list of functions that take no argument. | 6159 | list of functions that take no argument. |
| 6156 | 6160 | ||
| 6157 | Functions specified buffer-locally are called for any window showing | 6161 | Functions specified buffer-locally are called for any window showing |
| 6158 | the corresponding buffer if at least one window on that frame has been | 6162 | the corresponding buffer if at least one window on that frame has been |
| @@ -6168,14 +6172,29 @@ window change functions were run. Each call is performed with the | |||
| 6168 | frame temporarily selected and the selected window's buffer current. | 6172 | frame temporarily selected and the selected window's buffer current. |
| 6169 | @end defvar | 6173 | @end defvar |
| 6170 | 6174 | ||
| 6171 | Window change functions are called at the end of redisplay for each | 6175 | Finally, Emacs runs a normal hook that generalizes the behavior of |
| 6172 | frame as follows: First, any buffer-local window buffer change | 6176 | @code{window-state-change-functions}. |
| 6173 | function, window size change function, selected window change and | 6177 | |
| 6174 | window state change functions are called in this order. Next, the | 6178 | @defvar window-state-change-hook |
| 6175 | default values for these functions are called in the same order. Then | 6179 | The default value of this variable specifies functions called during |
| 6176 | any buffer-local window configuration change functions are called | 6180 | redisplay when a window state change has been detected or the window |
| 6177 | followed by functions specified by the default value of those | 6181 | state change flag has been set on at least one frame. The value |
| 6178 | functions. | 6182 | should be a list of functions that take no argument. |
| 6183 | |||
| 6184 | Applications should put a function on this hook only if they want to | ||
| 6185 | react to changes that happened on (or have been signaled for) two or | ||
| 6186 | more frames since last redisplay. In every other case, putting the | ||
| 6187 | function on @code{window-state-change-functions} should be preferred. | ||
| 6188 | @end defvar | ||
| 6189 | |||
| 6190 | Window change functions are called during redisplay for each frame as | ||
| 6191 | follows: First, any buffer-local window buffer change function, window | ||
| 6192 | size change function, selected window change and window state change | ||
| 6193 | functions are called in this order. Next, the default values for | ||
| 6194 | these functions are called in the same order. Then any buffer-local | ||
| 6195 | window configuration change functions are called followed by functions | ||
| 6196 | specified by the default value of those functions. Finally, functions | ||
| 6197 | on @code{window-state-change-hook} are run. | ||
| 6179 | 6198 | ||
| 6180 | Window change functions are run for a specific frame only if a | 6199 | Window change functions are run for a specific frame only if a |
| 6181 | corresponding change was registered for that frame earlier. Such | 6200 | corresponding change was registered for that frame earlier. Such |
| @@ -6189,6 +6208,27 @@ only if that excursion still persists at the time change functions are | |||
| 6189 | run. If it is exited earlier, hooks will be run only if registered by | 6208 | run. If it is exited earlier, hooks will be run only if registered by |
| 6190 | a change outside the scope of that excursion. | 6209 | a change outside the scope of that excursion. |
| 6191 | 6210 | ||
| 6211 | @cindex window state change flag | ||
| 6212 | The @dfn{window state change flag} of a frame, if set, will cause | ||
| 6213 | the default values of @code{window-state-change-functions} (for that | ||
| 6214 | frame) and @code{window-state-change-hook} to be run during next | ||
| 6215 | redisplay regardless of whether a window state change actually | ||
| 6216 | occurred for that frame or not. After running any functions on these | ||
| 6217 | hooks, the flag is reset for each frame. Applications can set that | ||
| 6218 | flag and inspect its value using the following functions. | ||
| 6219 | |||
| 6220 | @defun set-frame-window-state-change &optional frame arg | ||
| 6221 | This function sets @var{frame}'s window state change flag if @var{arg} | ||
| 6222 | is non-@code{nil} and resets it otherwise. @var{frame} must be a live | ||
| 6223 | frame and defaults to the selected one. | ||
| 6224 | @end defun | ||
| 6225 | |||
| 6226 | @defun frame-window-state-change &optional frame | ||
| 6227 | This functions returns @code{t} if @var{frame}'s window state change | ||
| 6228 | flag is set and @code{nil} otherwise. @var{frame} must be a live | ||
| 6229 | frame and defaults to the selected one. | ||
| 6230 | @end defun | ||
| 6231 | |||
| 6192 | While window change functions are run, the functions described next | 6232 | While window change functions are run, the functions described next |
| 6193 | can be called to get more insight into what has changed for a specific | 6233 | can be called to get more insight into what has changed for a specific |
| 6194 | window or frame since the last redisplay. All these functions take a | 6234 | window or frame since the last redisplay. All these functions take a |
| @@ -6250,12 +6290,10 @@ change functions were run. | |||
| 6250 | 6290 | ||
| 6251 | Note that window change functions provide no information about which | 6291 | Note that window change functions provide no information about which |
| 6252 | windows have been deleted since the last time they were run. If | 6292 | windows have been deleted since the last time they were run. If |
| 6253 | necessary, an application should remember any window showing a | 6293 | necessary, applications should remember any window showing a specific |
| 6254 | specific buffer in a local variable of that buffer and update it in a | 6294 | buffer in a local variable of that buffer and update it in a function |
| 6255 | function run by the default value of | 6295 | run by the default values of any of the hooks that are run when a |
| 6256 | @code{window-buffer-change-functions} or | 6296 | window buffer change was detected. |
| 6257 | @code{window-configuration-change-hook} (the only hooks triggered by | ||
| 6258 | the deletion of windows). | ||
| 6259 | 6297 | ||
| 6260 | The following caveats should be considered when adding a function | 6298 | The following caveats should be considered when adding a function |
| 6261 | to window change functions: | 6299 | to window change functions: |
| @@ -6272,7 +6310,7 @@ the buffer, size or selection status of any window because there is no | |||
| 6272 | guarantee that the information about such a change will be propagated | 6310 | guarantee that the information about such a change will be propagated |
| 6273 | to other window change functions. If at all, any such change should | 6311 | to other window change functions. If at all, any such change should |
| 6274 | be executed only by the last function listed by the default value of | 6312 | be executed only by the last function listed by the default value of |
| 6275 | @code{window-configuration-change-hook}. | 6313 | @code{window-state-change-hook}. |
| 6276 | 6314 | ||
| 6277 | @item | 6315 | @item |
| 6278 | Macros like @code{save-window-excursion}, @code{with-selected-window} | 6316 | Macros like @code{save-window-excursion}, @code{with-selected-window} |