Next: Index, Previous: Standard Keymaps, Up: Top
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
after-change-functions
before-change-functions
first-change-hook
after-change-major-mode-hook
change-major-mode-after-body-hook
after-init-hook
before-init-hook
emacs-startup-hook
window-setup-hook
after-insert-file-functions
write-region-annotate-functions
write-region-post-annotation-function
after-make-frame-functions
before-make-frame-hook
after-save-hook
before-save-hook
write-contents-functions
write-file-functions
after-setting-font-hook
auto-save-hook
before-hack-local-variables-hook
hack-local-variables-hook
buffer-access-fontify-functions
buffer-list-update-hook
buffer-quit-function
change-major-mode-hook
command-line-functions
delayed-warnings-hook
post-command-hook
(q.v.).
focus-in-hook
focus-out-hook
delete-frame-functions
delete-terminal-functions
pop-up-frame-function
split-window-preferred-function
echo-area-clear-hook
find-file-hook
find-file-not-found-functions
font-lock-extend-after-change-region-function
font-lock-extend-region-functions
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
fontification-functions
frame-auto-hide-function
kill-buffer-hook
kill-buffer-query-functions
kill-emacs-hook
kill-emacs-query-functions
menu-bar-update-hook
minibuffer-setup-hook
minibuffer-exit-hook
mouse-leave-buffer-hook
mouse-position-function
prefix-command-echo-keystrokes-functions
nil
if there's no
prefix state. See Prefix Command Arguments.
prefix-command-preserve-state-hook
pre-redisplay-functions
post-command-hook
pre-command-hook
post-gc-hook
post-self-insert-hook
suspend-hook
suspend-resume-hook
suspend-tty-functions
resume-tty-functions
syntax-begin-function
syntax-propertize-extend-region-functions
syntax-propertize-function
font-lock-syntactic-face-function
temp-buffer-setup-hook
temp-buffer-show-function
temp-buffer-show-hook
tty-setup-hook
window-configuration-change-hook
window-scroll-functions
window-size-change-functions