Update docs for select-window and buffer-list-update-hook.
[bpt/emacs.git] / doc / lispref / hooks.texi
1 @c -*-texinfo-*-
2 @c This is part of the GNU Emacs Lisp Reference Manual.
3 @c Copyright (C) 1990-1993, 1998, 2001-2014 Free Software Foundation, Inc.
4 @c See the file elisp.texi for copying conditions.
5 @node Standard Hooks
6 @appendix Standard Hooks
7 @cindex standard hooks
8 @cindex hook variables, list of
9
10 The following is a list of some hook variables that let you provide
11 functions to be called from within Emacs on suitable occasions.
12
13 Most of these variables have names ending with @samp{-hook}. They are
14 @dfn{normal hooks}, run by means of @code{run-hooks}. The value of such
15 a hook is a list of functions; the functions are called with no
16 arguments and their values are completely ignored. The recommended way
17 to put a new function on such a hook is to call @code{add-hook}.
18 @xref{Hooks}, for more information about using hooks.
19
20 The variables whose names end in @samp{-functions} are usually @dfn{abnormal
21 hooks} (some old code may also use the deprecated @samp{-hooks} suffix); their
22 values are lists of functions, but these functions are called in a special way
23 (they are passed arguments, or their return values are used). The variables
24 whose names end in @samp{-function} have single functions as their values.
25
26 This is not an exhaustive list, it only covers the more general hooks.
27 For example, every major mode defines a hook named
28 @samp{@var{modename}-mode-hook}. The major mode command runs this
29 normal hook with @code{run-mode-hooks} as the very last thing it does.
30 @xref{Mode Hooks}. Most minor modes have mode hooks too.
31
32 A special feature allows you to specify expressions to evaluate if and
33 when a file is loaded (@pxref{Hooks for Loading}). That feature is
34 not exactly a hook, but does a similar job.
35
36 @c We need to xref to where each hook is documented or else document it here.
37 @c Add vindex for anything not indexed elsewhere.
38 @c This list is in alphabetical order, grouped by topic.
39 @c TODO It should probably be more thoroughly ordered by topic.
40
41 @table @code
42 @item activate-mark-hook
43 @itemx deactivate-mark-hook
44 @xref{The Mark}.
45
46 @item after-change-functions
47 @itemx before-change-functions
48 @itemx first-change-hook
49 @xref{Change Hooks}.
50
51 @item after-change-major-mode-hook
52 @itemx change-major-mode-after-body-hook
53 @xref{Mode Hooks}.
54
55 @item after-init-hook
56 @itemx before-init-hook
57 @itemx emacs-startup-hook
58 @xref{Init File}.
59
60 @item after-insert-file-functions
61 @itemx write-region-annotate-functions
62 @itemx write-region-post-annotation-function
63 @xref{Format Conversion}.
64
65 @item after-make-frame-functions
66 @itemx before-make-frame-hook
67 @xref{Creating Frames}.
68
69 @c Not general enough?
70 @ignore
71 @item after-revert-hook
72 @itemx before-revert-hook
73 @itemx buffer-stale-function
74 @itemx revert-buffer-function
75 @itemx revert-buffer-insert-file-contents-function
76 @xref{Reverting}.
77 @end ignore
78
79 @item after-save-hook
80 @itemx before-save-hook
81 @itemx write-contents-functions
82 @itemx write-file-functions
83 @xref{Saving Buffers}.
84
85 @item after-setting-font-hook
86 @vindex after-setting-font-hook
87 Hook run after a frame's font changes.
88
89 @item auto-save-hook
90 @xref{Auto-Saving}.
91
92 @item before-hack-local-variables-hook
93 @itemx hack-local-variables-hook
94 @xref{File Local Variables}.
95
96 @item buffer-access-fontify-functions
97 @xref{Lazy Properties}.
98
99 @item buffer-list-update-hook
100 @vindex buffer-list-update-hook
101 Hook run when the buffer list changes (@pxref{Buffer List}).
102
103 @item buffer-quit-function
104 @vindex buffer-quit-function
105 Function to call to ``quit'' the current buffer.
106
107 @item change-major-mode-hook
108 @xref{Creating Buffer-Local}.
109
110 @item command-line-functions
111 @xref{Command-Line Arguments}.
112
113 @item delayed-warnings-hook
114 @vindex delayed-warnings-hook
115 The command loop runs this soon after @code{post-command-hook} (q.v.).
116
117 @item focus-in-hook
118 @vindex focus-in-hook
119 @itemx focus-out-hook
120 @vindex focus-out-hook
121 @xref{Input Focus}.
122
123 @item delete-frame-functions
124 @xref{Deleting Frames}.
125
126 @item delete-terminal-functions
127 @xref{Multiple Terminals}.
128
129 @item pop-up-frame-function
130 @itemx split-window-preferred-function
131 @xref{Choosing Window Options}.
132
133 @item echo-area-clear-hook
134 @xref{Echo Area Customization}.
135
136 @item find-file-hook
137 @itemx find-file-not-found-functions
138 @xref{Visiting Functions}.
139
140 @item font-lock-extend-after-change-region-function
141 @xref{Region to Refontify}.
142
143 @item font-lock-extend-region-functions
144 @xref{Multiline Font Lock}.
145
146 @item font-lock-fontify-buffer-function
147 @itemx font-lock-fontify-region-function
148 @itemx font-lock-mark-block-function
149 @itemx font-lock-unfontify-buffer-function
150 @itemx font-lock-unfontify-region-function
151 @xref{Other Font Lock Variables}.
152
153 @item fontification-functions
154 @xref{Auto Faces,, Automatic Face Assignment}.
155
156 @item frame-auto-hide-function
157 @xref{Quitting Windows}.
158
159 @item kill-buffer-hook
160 @itemx kill-buffer-query-functions
161 @xref{Killing Buffers}.
162
163 @item kill-emacs-hook
164 @itemx kill-emacs-query-functions
165 @xref{Killing Emacs}.
166
167 @item menu-bar-update-hook
168 @xref{Menu Bar}.
169
170 @item minibuffer-setup-hook
171 @itemx minibuffer-exit-hook
172 @xref{Minibuffer Misc}.
173
174 @item mouse-leave-buffer-hook
175 @vindex mouse-leave-buffer-hook
176 Hook run when about to switch windows with a mouse command.
177
178 @item mouse-position-function
179 @xref{Mouse Position}.
180
181 @item post-command-hook
182 @itemx pre-command-hook
183 @xref{Command Overview}.
184
185 @item post-gc-hook
186 @xref{Garbage Collection}.
187
188 @item post-self-insert-hook
189 @xref{Keymaps and Minor Modes}.
190
191 @ignore
192 @item prog-mode-hook
193 @itemx special-mode-hook
194 @vindex special-mode-hook
195 @xref{Basic Major Modes}.
196 @end ignore
197
198 @item suspend-hook
199 @itemx suspend-resume-hook
200 @itemx suspend-tty-functions
201 @itemx resume-tty-functions
202 @xref{Suspending Emacs}.
203
204 @item syntax-begin-function
205 @itemx syntax-propertize-extend-region-functions
206 @itemx syntax-propertize-function
207 @itemx font-lock-syntactic-face-function
208 @xref{Syntactic Font Lock}. @xref{Syntax Properties}.
209
210 @item temp-buffer-setup-hook
211 @itemx temp-buffer-show-function
212 @itemx temp-buffer-show-hook
213 @xref{Temporary Displays}.
214
215 @item tty-setup-hook
216 @xref{Terminal-Specific}.
217
218 @item window-configuration-change-hook
219 @itemx window-scroll-functions
220 @itemx window-size-change-functions
221 @xref{Window Hooks}.
222
223 @item window-setup-hook
224 @xref{Window Systems}.
225
226 @item window-text-change-functions
227 @vindex window-text-change-functions
228 Functions to call in redisplay when text in the window might change.
229
230 @end table
231
232 @ignore
233 Some -hook, -function, -functions from preloaded Lisp or C files that
234 I thought did not need to be mentioned here:
235
236 Lisp:
237 after-load-functions
238 auto-coding-functions
239 choose-completion-string-functions
240 completing-read-function
241 completion-annotate-function
242 completion-at-point-functions
243 completion-in-region-functions
244 completion-list-insert-choice-function
245 deactivate-current-input-method-function
246 describe-current-input-method-function
247 filter-buffer-substring-functions
248 font-lock-function
249 menu-bar-select-buffer-function
250 read-file-name-function
251 replace-re-search-function
252 replace-search-function
253 yank-undo-function
254
255 C hooks:
256 kbd-macro-termination-hook
257 signal-hook-function
258
259 C functions:
260 redisplay-end-trigger-functions
261 x-lost-selection-functions
262 x-sent-selection-functions
263
264 C function:
265 auto-composition-function
266 auto-fill-function
267 command-error-function
268 compose-chars-after-function
269 composition-function-table
270 deferred-action-function
271 input-method-function
272 load-read-function
273 load-source-file-function
274 read-buffer-function
275 ring-bell-function
276 select-safe-coding-system-function
277 set-auto-coding-function
278 show-help-function
279 signal-hook-function
280 undo-outer-limit-function
281
282 @end ignore