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