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-hookdeactivate-mark-hook-
See The Mark.
after-change-functionsbefore-change-functionsfirst-change-hook-
See Change Hooks.
after-change-major-mode-hookchange-major-mode-after-body-hook-
See Mode Hooks.
after-init-hookbefore-init-hookemacs-startup-hookwindow-setup-hook-
See Init File.
after-insert-file-functionswrite-region-annotate-functionswrite-region-post-annotation-function-
See Format Conversion.
after-make-frame-functionsbefore-make-frame-hookserver-after-make-frame-hook-
See Creating Frames.
after-save-hookbefore-save-hookwrite-contents-functionswrite-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-hookhack-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-hookcomint-password-function-
This abnormal hook permits a derived mode to supply a password for the underlying command interpreter without prompting the user.
command-line-functionsdelayed-warnings-hook-
The command loop runs this soon after
post-command-hook(q.v.). focus-in-hookfocus-out-hook-
See Input Focus.
delete-frame-functionsafter-delete-frame-functions-
See Deleting Frames.
delete-terminal-functions-
See Multiple Terminals.
pop-up-frame-functionsplit-window-preferred-functionecho-area-clear-hookfind-file-hookfind-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-functionfont-lock-fontify-region-functionfont-lock-mark-block-functionfont-lock-unfontify-buffer-functionfont-lock-unfontify-region-functionfontification-functionsframe-auto-hide-function-
See Quitting Windows.
quit-window-hook-
See Quitting Windows.
kill-buffer-hookkill-buffer-query-functions-
See Killing Buffers.
kill-emacs-hookkill-emacs-query-functions-
See Killing Emacs.
menu-bar-update-hook-
See Menu Bar.
minibuffer-setup-hookminibuffer-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
nilif 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-hookpre-command-hook-
See Command Overview.
post-gc-hook-
See Garbage Collection.
post-self-insert-hooksuspend-hooksuspend-resume-hooksuspend-tty-functionsresume-tty-functions-
See Suspending Emacs.
syntax-begin-functionsyntax-propertize-extend-region-functionssyntax-propertize-functionfont-lock-syntactic-face-function-
See Syntactic Font Lock. See Syntax Properties.
temp-buffer-setup-hooktemp-buffer-show-functiontemp-buffer-show-hook-
See Temporary Displays.
tty-setup-hook-
See Terminal-Specific.
window-configuration-change-hookwindow-scroll-functionswindow-size-change-functionsSee Window Hooks.
Copyright © 1990-1996, 1998-2021 Free Software Foundation, Inc.
Licensed under the GNU GPL license.
https://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-Hooks.html