Mercurial > emacs
comparison lispref/modes.texi @ 62343:4a68f3c340ab
(Hooks): Most minor modes run mode hooks too.
`add-hook' can handle void hooks or hooks whose value is a single function.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Sat, 14 May 2005 15:25:38 +0000 |
parents | 37b336c94e15 |
children | 5a29669290ac |
comparison
equal
deleted
inserted
replaced
62342:32b9b0540e8a | 62343:4a68f3c340ab |
---|---|
2834 a uniform way. | 2834 a uniform way. |
2835 | 2835 |
2836 Every major mode function is supposed to run a normal hook called the | 2836 Every major mode function is supposed to run a normal hook called the |
2837 @dfn{mode hook} as the last step of initialization. This makes it easy | 2837 @dfn{mode hook} as the last step of initialization. This makes it easy |
2838 for a user to customize the behavior of the mode, by overriding the | 2838 for a user to customize the behavior of the mode, by overriding the |
2839 buffer-local variable assignments already made by the mode. But hooks | 2839 buffer-local variable assignments already made by the mode. Most |
2840 are used in other contexts too. For example, the hook | 2840 minor modes also run a mode hook at their end. But hooks are used in |
2841 @code{suspend-hook} runs just before Emacs suspends itself | 2841 other contexts too. For example, the hook @code{suspend-hook} runs |
2842 (@pxref{Suspending Emacs}). | 2842 just before Emacs suspends itself (@pxref{Suspending Emacs}). |
2843 | 2843 |
2844 The recommended way to add a hook function to a normal hook is by | 2844 The recommended way to add a hook function to a normal hook is by |
2845 calling @code{add-hook} (see below). The hook functions may be any of | 2845 calling @code{add-hook} (see below). The hook functions may be any of |
2846 the valid kinds of functions that @code{funcall} accepts (@pxref{What | 2846 the valid kinds of functions that @code{funcall} accepts (@pxref{What |
2847 Is a Function}). Most normal hook variables are initially void; | 2847 Is a Function}). Most normal hook variables are initially void; |
2935 @var{function} goes at the front of the hook list, so it will be | 2935 @var{function} goes at the front of the hook list, so it will be |
2936 executed first (barring another @code{add-hook} call). If the optional | 2936 executed first (barring another @code{add-hook} call). If the optional |
2937 argument @var{append} is non-@code{nil}, the new hook function goes at | 2937 argument @var{append} is non-@code{nil}, the new hook function goes at |
2938 the end of the hook list and will be executed last. | 2938 the end of the hook list and will be executed last. |
2939 | 2939 |
2940 @code{add-hook} can handle the cases where @var{hook} is void or its | |
2941 value is a single function; it sets or changes the value to a list of | |
2942 functions. | |
2943 | |
2940 If @var{local} is non-@code{nil}, that says to add @var{function} to | 2944 If @var{local} is non-@code{nil}, that says to add @var{function} to |
2941 the buffer-local hook list instead of to the global hook list. If | 2945 the buffer-local hook list instead of to the global hook list. If |
2942 needed, this makes the hook buffer-local and adds @code{t} to the | 2946 needed, this makes the hook buffer-local and adds @code{t} to the |
2943 buffer-local value. The latter acts as a flag to run the hook | 2947 buffer-local value. The latter acts as a flag to run the hook |
2944 functions in the default value as well as in the local value. | 2948 functions in the default value as well as in the local value. |