summaryrefslogtreecommitdiff
path: root/devdocs/elisp/standard-hooks.html
blob: 5bd1f999988c76e4047744e605ef9ae4b9bc4fca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 <h2 class="appendix"> Standard Hooks</h2>   <p>The following is a list of some hook variables that let you provide functions to be called from within Emacs on suitable occasions. </p> <p>Most of these variables have names ending with ‘<samp>-hook</samp>’. They are <em>normal hooks</em>, run by means of <code>run-hooks</code>. 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 <code>add-hook</code>. See <a href="hooks">Hooks</a>, for more information about using hooks. </p> <p>The variables whose names end in ‘<samp>-functions</samp>’ are usually <em>abnormal hooks</em> (some old code may also use the deprecated ‘<samp>-hooks</samp>’ suffix). Their values are lists of functions, but these functions are called in a special way: they are either passed arguments, or their return values are used in some way. The variables whose names end in ‘<samp>-function</samp>’ have single functions as their values. </p> <p>This is not an exhaustive list, it only covers the more general hooks. For example, every major mode defines a hook named ‘<samp><var>modename</var>-mode-hook</samp>’. The major mode command runs this normal hook with <code>run-mode-hooks</code> as the very last thing it does. See <a href="mode-hooks">Mode Hooks</a>. Most minor modes have mode hooks too. </p> <p>A special feature allows you to specify expressions to evaluate if and when a file is loaded (see <a href="hooks-for-loading">Hooks for Loading</a>). That feature is not exactly a hook, but does a similar job. </p> <dl compact> <dt><code>activate-mark-hook</code></dt> <dt><code>deactivate-mark-hook</code></dt> <dd>
<p>See <a href="the-mark">The Mark</a>. </p> </dd> <dt><code>after-change-functions</code></dt> <dt><code>before-change-functions</code></dt> <dt><code>first-change-hook</code></dt> <dd>
<p>See <a href="change-hooks">Change Hooks</a>. </p> </dd> <dt><code>after-change-major-mode-hook</code></dt> <dt><code>change-major-mode-after-body-hook</code></dt> <dd>
<p>See <a href="mode-hooks">Mode Hooks</a>. </p> </dd> <dt><code>after-init-hook</code></dt> <dt><code>before-init-hook</code></dt> <dt><code>emacs-startup-hook</code></dt> <dt><code>window-setup-hook</code></dt> <dd>
<p>See <a href="init-file">Init File</a>. </p> </dd> <dt><code>after-insert-file-functions</code></dt> <dt><code>write-region-annotate-functions</code></dt> <dt><code>write-region-post-annotation-function</code></dt> <dd>
<p>See <a href="format-conversion">Format Conversion</a>. </p> </dd> <dt><code>after-make-frame-functions</code></dt> <dt><code>before-make-frame-hook</code></dt> <dt><code>server-after-make-frame-hook</code></dt> <dd>
<p>See <a href="creating-frames">Creating Frames</a>. </p> </dd> <dt><code>after-save-hook</code></dt> <dt><code>before-save-hook</code></dt> <dt><code>write-contents-functions</code></dt> <dt><code>write-file-functions</code></dt> <dd>
<p>See <a href="saving-buffers">Saving Buffers</a>. </p> </dd> <dt><code>after-setting-font-hook</code></dt> <dd>
 <p>Hook run after a frame’s font changes. </p> </dd> <dt><code>auto-save-hook</code></dt> <dd>
<p>See <a href="auto_002dsaving">Auto-Saving</a>. </p> </dd> <dt><code>before-hack-local-variables-hook</code></dt> <dt><code>hack-local-variables-hook</code></dt> <dd>
<p>See <a href="file-local-variables">File Local Variables</a>. </p> </dd> <dt><code>buffer-access-fontify-functions</code></dt> <dd>
<p>See <a href="lazy-properties">Lazy Properties</a>. </p> </dd> <dt><code>buffer-list-update-hook</code></dt> <dd>
 <p>Hook run when the buffer list changes (see <a href="buffer-list">Buffer List</a>). </p> </dd> <dt><code>buffer-quit-function</code></dt> <dd>
 <p>Function to call to quit the current buffer. </p> </dd> <dt><code>change-major-mode-hook</code></dt> <dd>
<p>See <a href="creating-buffer_002dlocal">Creating Buffer-Local</a>. </p> </dd> <dt><code>comint-password-function</code></dt> <dd>
<p>This abnormal hook permits a derived mode to supply a password for the underlying command interpreter without prompting the user. </p> </dd> <dt><code>command-line-functions</code></dt> <dd>
<p>See <a href="command_002dline-arguments">Command-Line Arguments</a>. </p> </dd> <dt><code>delayed-warnings-hook</code></dt> <dd>
 <p>The command loop runs this soon after <code>post-command-hook</code> (q.v.). </p> </dd> <dt><code>focus-in-hook</code></dt>  <dt><code>focus-out-hook</code></dt> <dd>
 <p>See <a href="input-focus">Input Focus</a>. </p> </dd> <dt><code>delete-frame-functions</code></dt> <dt><code>after-delete-frame-functions</code></dt> <dd>
<p>See <a href="deleting-frames">Deleting Frames</a>. </p> </dd> <dt><code>delete-terminal-functions</code></dt> <dd>
<p>See <a href="multiple-terminals">Multiple Terminals</a>. </p> </dd> <dt><code>pop-up-frame-function</code></dt> <dt><code>split-window-preferred-function</code></dt> <dd>
<p>See <a href="choosing-window-options">Choosing Window Options</a>. </p> </dd> <dt><code>echo-area-clear-hook</code></dt> <dd>
<p>See <a href="echo-area-customization">Echo Area Customization</a>. </p> </dd> <dt><code>find-file-hook</code></dt> <dt><code>find-file-not-found-functions</code></dt> <dd>
<p>See <a href="visiting-functions">Visiting Functions</a>. </p> </dd> <dt><code>font-lock-extend-after-change-region-function</code></dt> <dd>
<p>See <a href="region-to-refontify">Region to Refontify</a>. </p> </dd> <dt><code>font-lock-extend-region-functions</code></dt> <dd>
<p>See <a href="multiline-font-lock">Multiline Font Lock</a>. </p> </dd> <dt><code>font-lock-fontify-buffer-function</code></dt> <dt><code>font-lock-fontify-region-function</code></dt> <dt><code>font-lock-mark-block-function</code></dt> <dt><code>font-lock-unfontify-buffer-function</code></dt> <dt><code>font-lock-unfontify-region-function</code></dt> <dd>
<p>See <a href="other-font-lock-variables">Other Font Lock Variables</a>. </p> </dd> <dt><code>fontification-functions</code></dt> <dd>
<p>See <a href="auto-faces">Automatic Face Assignment</a>. </p> </dd> <dt><code>frame-auto-hide-function</code></dt> <dd>
<p>See <a href="quitting-windows">Quitting Windows</a>. </p> </dd> <dt><code>quit-window-hook</code></dt> <dd>
<p>See <a href="quitting-windows">Quitting Windows</a>. </p> </dd> <dt><code>kill-buffer-hook</code></dt> <dt><code>kill-buffer-query-functions</code></dt> <dd>
<p>See <a href="killing-buffers">Killing Buffers</a>. </p> </dd> <dt><code>kill-emacs-hook</code></dt> <dt><code>kill-emacs-query-functions</code></dt> <dd>
<p>See <a href="killing-emacs">Killing Emacs</a>. </p> </dd> <dt><code>menu-bar-update-hook</code></dt> <dd>
<p>See <a href="menu-bar">Menu Bar</a>. </p> </dd> <dt><code>minibuffer-setup-hook</code></dt> <dt><code>minibuffer-exit-hook</code></dt> <dd>
<p>See <a href="minibuffer-misc">Minibuffer Misc</a>. </p> </dd> <dt><code>mouse-leave-buffer-hook</code></dt> <dd>
 <p>Hook run when the user mouse-clicks in a window. </p> </dd> <dt><code>mouse-position-function</code></dt> <dd>
<p>See <a href="mouse-position">Mouse Position</a>. </p> </dd> <dt><code>prefix-command-echo-keystrokes-functions</code></dt> <dd>
 <p>An abnormal hook run by prefix commands (such as <kbd>C-u</kbd>) which should return a string describing the current prefix state. For example, <kbd>C-u</kbd> produces ‘<samp>C-u-</samp>’ and ‘<samp>C-u 1 2 3-</samp>’. Each hook function is called with no arguments and should return a string describing the current prefix state, or <code>nil</code> if there’s no prefix state. See <a href="prefix-command-arguments">Prefix Command Arguments</a>. </p> </dd> <dt><code>prefix-command-preserve-state-hook</code></dt> <dd>
 <p>Hook run when a prefix command needs to preserve the prefix by passing the current prefix command state to the next command. For example, <kbd>C-u</kbd> needs to pass the state to the next command when the user types <kbd>C-u -</kbd> or follows <kbd>C-u</kbd> with a digit. </p> </dd> <dt><code>pre-redisplay-functions</code></dt> <dd>
<p>Hook run in each window just before redisplaying it. See <a href="forcing-redisplay">Forcing Redisplay</a>. </p> </dd> <dt><code>post-command-hook</code></dt> <dt><code>pre-command-hook</code></dt> <dd>
<p>See <a href="command-overview">Command Overview</a>. </p> </dd> <dt><code>post-gc-hook</code></dt> <dd>
<p>See <a href="garbage-collection">Garbage Collection</a>. </p> </dd> <dt><code>post-self-insert-hook</code></dt> <dd>
<p>See <a href="keymaps-and-minor-modes">Keymaps and Minor Modes</a>. </p> </dd> <dt><code>suspend-hook</code></dt> <dt><code>suspend-resume-hook</code></dt> <dt><code>suspend-tty-functions</code></dt> <dt><code>resume-tty-functions</code></dt> <dd>
<p>See <a href="suspending-emacs">Suspending Emacs</a>. </p> </dd> <dt><code>syntax-begin-function</code></dt> <dt><code>syntax-propertize-extend-region-functions</code></dt> <dt><code>syntax-propertize-function</code></dt> <dt><code>font-lock-syntactic-face-function</code></dt> <dd>
<p>See <a href="syntactic-font-lock">Syntactic Font Lock</a>. See <a href="syntax-properties">Syntax Properties</a>. </p> </dd> <dt><code>temp-buffer-setup-hook</code></dt> <dt><code>temp-buffer-show-function</code></dt> <dt><code>temp-buffer-show-hook</code></dt> <dd>
<p>See <a href="temporary-displays">Temporary Displays</a>. </p> </dd> <dt><code>tty-setup-hook</code></dt> <dd>
<p>See <a href="terminal_002dspecific">Terminal-Specific</a>. </p> </dd> <dt><code>window-configuration-change-hook</code></dt> <dt><code>window-scroll-functions</code></dt> <dt><code>window-size-change-functions</code></dt> <dd><p>See <a href="window-hooks">Window Hooks</a>. </p></dd> </dl><div class="_attribution">
  <p class="_attribution-p">
    Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
    <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-Hooks.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Standard-Hooks.html</a>
  </p>
</div>