2 @c This is part of the GNU Emacs Lisp Reference Manual.
3 @c Copyright (C) 1990-1993, 1998, 2001-2012 Free Software Foundation, Inc.
4 @c See the file elisp.texi for copying conditions.
6 @appendix Standard Hooks
8 @cindex hook variables, list of
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.
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.
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.
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.
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.
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.
42 @item activate-mark-hook
43 @itemx deactivate-mark-hook
46 @item after-change-functions
47 @itemx before-change-functions
48 @itemx first-change-hook
51 @item after-change-major-mode-hook
52 @itemx change-major-mode-after-body-hook
56 @itemx before-init-hook
57 @itemx emacs-startup-hook
60 @item after-insert-file-functions
61 @itemx write-region-annotate-functions
62 @itemx write-region-post-annotation-function
63 @xref{Format Conversion}.
65 @item after-make-frame-functions
66 @itemx before-make-frame-hook
67 @xref{Creating Frames}.
69 @c Not general enough?
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
80 @itemx before-save-hook
81 @itemx write-contents-functions
82 @itemx write-file-functions
83 @xref{Saving Buffers}.
85 @item after-setting-font-hook
86 @vindex after-setting-font-hook
87 Hook run after a frame's font changes.
92 @item before-hack-local-variables-hook
93 @itemx hack-local-variables-hook
94 @xref{File Local Variables}.
96 @item buffer-access-fontify-functions
97 @xref{Lazy Properties}.
99 @item buffer-list-update-hook
100 @vindex buffer-list-update-hook
101 Hook run when the buffer list changes.
103 @item buffer-quit-function
104 @vindex buffer-quit-function
105 Function to call to ``quit'' the current buffer.
107 @item change-major-mode-hook
108 @xref{Creating Buffer-Local}.
110 @item command-line-functions
111 @xref{Command-Line Arguments}.
113 @item delayed-warnings-hook
114 @vindex delayed-warnings-hook
115 The command loop runs this soon after @code{post-command-hook} (q.v.).
117 @item delete-frame-functions
118 @xref{Deleting Frames}.
120 @item delete-terminal-functions
121 @xref{Multiple Terminals}.
123 @itemx pop-up-frame-function
124 @itemx split-window-preferred-function
125 @xref{Choosing Window Options}.
127 @item echo-area-clear-hook
128 @xref{Echo Area Customization}.
131 @itemx find-file-not-found-functions
132 @xref{Visiting Functions}.
134 @item font-lock-extend-after-change-region-function
135 @xref{Region to Refontify}.
137 @item font-lock-extend-region-functions
138 @xref{Multiline Font Lock}.
140 @item font-lock-fontify-buffer-function
141 @itemx font-lock-fontify-region-function
142 @itemx font-lock-mark-block-function
143 @itemx font-lock-unfontify-buffer-function
144 @itemx font-lock-unfontify-region-function
145 @xref{Other Font Lock Variables}.
147 @item fontification-functions
148 @xref{Auto Faces,, Automatic Face Assignment}.
150 @item frame-auto-hide-function
151 @xref{Quitting Windows}.
153 @item kill-buffer-hook
154 @itemx kill-buffer-query-functions
155 @xref{Killing Buffers}.
157 @item kill-emacs-hook
158 @itemx kill-emacs-query-functions
159 @xref{Killing Emacs}.
161 @item menu-bar-update-hook
164 @item minibuffer-setup-hook
165 @itemx minibuffer-exit-hook
166 @xref{Minibuffer Misc}.
168 @item mouse-leave-buffer-hook
169 @vindex mouse-leave-buffer-hook
170 Hook run when about to switch windows with a mouse command.
172 @item mouse-position-function
173 @xref{Mouse Position}.
175 @item post-command-hook
176 @itemx pre-command-hook
177 @xref{Command Overview}.
180 @xref{Garbage Collection}.
182 @item post-self-insert-hook
183 @xref{Keymaps and Minor Modes}.
187 @itemx special-mode-hook
188 @vindex special-mode-hook
189 @xref{Basic Major Modes}.
193 @itemx suspend-resume-hook
194 @itemx suspend-tty-functions
195 @itemx resume-tty-functions
196 @xref{Suspending Emacs}.
198 @item syntax-begin-function
199 @itemx syntax-propertize-extend-region-functions
200 @itemx syntax-propertize-function
201 @itemx font-lock-syntactic-face-function
202 @xref{Syntactic Font Lock}. @xref{Syntax Properties}.
204 @item temp-buffer-setup-hook
205 @itemx temp-buffer-show-function
206 @itemx temp-buffer-show-hook
207 @xref{Temporary Displays}.
209 @item term-setup-hook
210 @xref{Terminal-Specific}.
212 @item window-configuration-change-hook
213 @itemx window-scroll-functions
214 @itemx window-size-change-functions
217 @item window-setup-hook
218 @xref{Window Systems}.
220 @item window-text-change-functions
221 @vindex window-text-change-functions
222 Functions to call in redisplay when text in the window might change.
227 Some -hook, -function, -functions from preloaded Lisp or C files that
228 I thought did not need to be mentioned here:
232 auto-coding-functions
233 choose-completion-string-functions
234 completing-read-function
235 completion-annotate-function
236 completion-at-point-functions
237 completion-in-region-functions
238 completion-list-insert-choice-function
239 deactivate-current-input-method-function
240 describe-current-input-method-function
241 filter-buffer-substring-functions
243 menu-bar-select-buffer-function
244 read-file-name-function
245 replace-re-search-function
246 replace-search-function
250 kbd-macro-termination-hook
254 redisplay-end-trigger-functions
255 x-lost-selection-functions
256 x-sent-selection-functions
259 auto-composition-function
261 command-error-function
262 compose-chars-after-function
263 composition-function-table
264 deferred-action-function
265 input-method-function
267 load-source-file-function
270 select-safe-coding-system-function
271 set-auto-coding-function
274 undo-outer-limit-function