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.