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β
window-setup-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β
server-after-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 (see Buffer List).
buffer-quit-functionβ
Function to call to quit the current buffer.
change-major-mode-hookβ
comint-password-functionβ
This abnormal hook permits a derived mode to supply a password for the underlying command interpreter without prompting the user.
command-line-functionsβ
delayed-warnings-hookβ
The command loop runs this soon after post-command-hook (q.v.).
focus-in-hookβ
focus-out-hookβ
See Input Focus.
delete-frame-functionsβ
after-delete-frame-functionsβ
See Deleting Frames.
delete-terminal-functionsβ
See Multiple Terminals.
pop-up-frame-functionβ
split-window-preferred-functionβ
echo-area-clear-hookβ
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.
quit-window-hookβ
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.
prefix-command-echo-keystrokes-functionsβ
An abnormal hook run by prefix commands (such as C-u) which should return a string describing the current prefix state. For example, C-u produces βC-u-β and βC-u 1 2 3-β. Each hook function is called with no arguments and should return a string describing the current prefix state, or nil if thereβs no prefix state. See Prefix Command Arguments.
prefix-command-preserve-state-hookβ
Hook run when a prefix command needs to preserve the prefix by passing the current prefix command state to the next command. For example, C-u needs to pass the state to the next command when the user types C-u - or follows C-u with a digit.
pre-redisplay-functionsβ
Hook run in each window just before redisplaying it. See Forcing Redisplay.
post-command-hookβ
pre-command-hookβ
See Command Overview.
post-gc-hookβ
See Garbage Collection.
post-self-insert-hookβ
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.
tty-setup-hookβ
See Terminal-Specific.
window-configuration-change-hookβ
window-scroll-functionsβ
window-size-change-functionsβ
See Window Hooks.