Next: , Previous: Standard Keymaps, Up: Top

Appendix H Standard Hooks

The following is a list of some hook variables that let you provide functions to be called from within Emacs on suitable occasions.

Most of these variables have names ending with ‘-hook’. They are normal hooks, run by means of run-hooks. The value of such a hook is a list of functions; the functions are called with no arguments and their values are completely ignored. The recommended way to put a new function on such a hook is to call add-hook. See Hooks, for more information about using hooks.

The variables whose names end in ‘-functions’ are usually abnormal hooks (some old code may also use the deprecated ‘-hooks’ suffix); their values are lists of functions, but these functions are called in a special way (they are passed arguments, or their return values are used). The variables whose names end in ‘-function’ have single functions as their values.

This is not an exhaustive list, it only covers the more general hooks. For example, every major mode defines a hook named ‘modename-mode-hook’. The major mode command runs this normal hook with run-mode-hooks as the very last thing it does. See Mode Hooks. Most minor modes have mode hooks too.

A special feature allows you to specify expressions to evaluate if and when a file is loaded (see Hooks for Loading). That feature is not exactly a hook, but does a similar job.

activate-mark-hook
deactivate-mark-hook
See The Mark.
after-change-functions
before-change-functions
first-change-hook
See Change Hooks.
after-change-major-mode-hook
change-major-mode-after-body-hook
See Mode Hooks.
after-init-hook
before-init-hook
emacs-startup-hook
See Init File.
after-insert-file-functions
write-region-annotate-functions
write-region-post-annotation-function
See Format Conversion.
after-make-frame-functions
before-make-frame-hook
See Creating Frames.
after-save-hook
before-save-hook
write-contents-functions
write-file-functions
See Saving Buffers.
after-setting-font-hook
Hook run after a frame's font changes.
auto-save-hook
See Auto-Saving.
before-hack-local-variables-hook
hack-local-variables-hook
See File Local Variables.
buffer-access-fontify-functions
See Lazy Properties.
buffer-list-update-hook
Hook run when the buffer list changes.
buffer-quit-function
Function to call to “quit” the current buffer.
change-major-mode-hook
See Creating Buffer-Local.
command-line-functions
See Command-Line Arguments.
delayed-warnings-hook
The command loop runs this soon after post-command-hook (q.v.).
delete-frame-functions
See Deleting Frames.
delete-terminal-functions
See Multiple Terminals.
pop-up-frame-function
split-window-preferred-function
See Choosing Window Options.
echo-area-clear-hook
See Echo Area Customization.
find-file-hook
find-file-not-found-functions
See Visiting Functions.
font-lock-extend-after-change-region-function
See Region to Refontify.
font-lock-extend-region-functions
See Multiline Font Lock.
font-lock-fontify-buffer-function
font-lock-fontify-region-function
font-lock-mark-block-function
font-lock-unfontify-buffer-function
font-lock-unfontify-region-function
See Other Font Lock Variables.
fontification-functions
See Automatic Face Assignment.
frame-auto-hide-function
See Quitting Windows.
kill-buffer-hook
kill-buffer-query-functions
See Killing Buffers.
kill-emacs-hook
kill-emacs-query-functions
See Killing Emacs.
menu-bar-update-hook
See Menu Bar.
minibuffer-setup-hook
minibuffer-exit-hook
See Minibuffer Misc.
mouse-leave-buffer-hook
Hook run when about to switch windows with a mouse command.
mouse-position-function
See Mouse Position.
post-command-hook
pre-command-hook
See Command Overview.
post-gc-hook
See Garbage Collection.
post-self-insert-hook
See Keymaps and Minor Modes.
suspend-hook
suspend-resume-hook
suspend-tty-functions
resume-tty-functions
See Suspending Emacs.
syntax-begin-function
syntax-propertize-extend-region-functions
syntax-propertize-function
font-lock-syntactic-face-function
See Syntactic Font Lock. See Syntax Properties.
temp-buffer-setup-hook
temp-buffer-show-function
temp-buffer-show-hook
See Temporary Displays.
term-setup-hook
See Terminal-Specific.
window-configuration-change-hook
window-scroll-functions
window-size-change-functions
See Window Hooks.
window-setup-hook
See Window Systems.
window-text-change-functions
Functions to call in redisplay when text in the window might change.