aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1996-09-01 22:44:57 +0000
committerRichard M. Stallman1996-09-01 22:44:57 +0000
commitdd73b091cbdfa4a9268fb0de925faab04e5bab44 (patch)
tree00b6ec415506b4160f49e5cf28a411855b69e407
parent4f8aaa7480ecc26189f1a338bd7f45f6d54446bf (diff)
downloademacs-dd73b091cbdfa4a9268fb0de925faab04e5bab44.tar.gz
emacs-dd73b091cbdfa4a9268fb0de925faab04e5bab44.zip
Explain better about abnormal hooks.
-rw-r--r--lispref/hooks.texi25
-rw-r--r--lispref/modes.texi43
2 files changed, 39 insertions, 29 deletions
diff --git a/lispref/hooks.texi b/lispref/hooks.texi
index 18f8bcfcad5..046ac7cc5d5 100644
--- a/lispref/hooks.texi
+++ b/lispref/hooks.texi
@@ -11,19 +11,22 @@ functions to be called from within Emacs on suitable occasions.
11 11
12Most of these variables have names ending with @samp{-hook}. They are 12Most of these variables have names ending with @samp{-hook}. They are
13@dfn{normal hooks}, run by means of @code{run-hooks}. The value of such 13@dfn{normal hooks}, run by means of @code{run-hooks}. The value of such
14a hook is a list of functions. The recommended way to put a new 14a hook is a list of functions; the functions are called with no
15function on such a hook is to call @code{add-hook}. @xref{Hooks}, for 15arguments and their values are completely ignored. The recommended way
16more information about using hooks. 16to put a new function on such a hook is to call @code{add-hook}.
17@xref{Hooks}, for more information about using hooks.
17 18
18The variables whose names end in @samp{-function} have single functions 19The variables whose names end in @samp{-hooks} or @samp{-functions} are
19as their values. Usually there is a specific reason why the variable is 20usually @dfn{abnormal hooks}; their values are lists of functions, but
20not a normal hook, such as the need to pass arguments to the function. 21these functions are called in a special way (they are passed arguments,
21(In older Emacs versions, some of these variables had names ending in 22or their values are used). A few of these variables are actually normal
22@samp{-hook} even though they were not normal hooks.) 23hooks which were named before we established the convention that normal
24hooks' names should end in @samp{-hook}.
23 25
24The variables whose names end in @samp{-hooks} or @samp{-functions} have 26The variables whose names end in @samp{-function} have single functions
25lists of functions as their values, but these functions are called in a 27as their values. (In older Emacs versions, some of these variables had
26special way (they are passed arguments, or else their values are used). 28names ending in @samp{-hook} even though they were not normal hooks;
29however, we have renamed all of those.)
27 30
28@c !!! need xref to where each hook is documented or else document it 31@c !!! need xref to where each hook is documented or else document it
29@c by specifying what is expected, and when it is called relative to 32@c by specifying what is expected, and when it is called relative to
diff --git a/lispref/modes.texi b/lispref/modes.texi
index e7b164f3b2c..10c71d00993 100644
--- a/lispref/modes.texi
+++ b/lispref/modes.texi
@@ -1262,10 +1262,17 @@ up in the @file{.emacs} file, but Lisp programs can set them also.
1262@xref{Standard Hooks}, for a list of standard hook variables. 1262@xref{Standard Hooks}, for a list of standard hook variables.
1263 1263
1264 Most of the hooks in Emacs are @dfn{normal hooks}. These variables 1264 Most of the hooks in Emacs are @dfn{normal hooks}. These variables
1265contain lists of functions to be called with no arguments. The reason 1265contain lists of functions to be called with no arguments. When the
1266most hooks are normal hooks is so that you can use them in a uniform 1266hook name ends in @samp{-hook}, that tells you it is normal. We try to
1267way. You can always tell when a hook is a normal hook, because its 1267make all hooks normal, as much as possible, so that you can use them in
1268name ends in @samp{-hook}. 1268a uniform way.
1269
1270 Every major mode function is supposed to run a normal hook called the
1271@dfn{mode hook} as the last step of initialization. This makes it easy
1272for a user to customize the behavior of the mode, by overriding the
1273local variable assignments already made by the mode. But hooks are used
1274in other contexts too. For example, the hook @code{suspend-hook} runs
1275just before Emacs suspends itself (@pxref{Suspending Emacs}).
1269 1276
1270 The recommended way to add a hook function to a normal hook is by 1277 The recommended way to add a hook function to a normal hook is by
1271calling @code{add-hook} (see below). The hook functions may be any of 1278calling @code{add-hook} (see below). The hook functions may be any of
@@ -1273,20 +1280,20 @@ the valid kinds of functions that @code{funcall} accepts (@pxref{What Is
1273a Function}). Most normal hook variables are initially void; 1280a Function}). Most normal hook variables are initially void;
1274@code{add-hook} knows how to deal with this. 1281@code{add-hook} knows how to deal with this.
1275 1282
1276 As for abnormal hooks, those whose names end in @samp{-function} have 1283 If the hook variable's name does not end with @samp{-hook}, that
1277a value that is a single function. Those whose names end in 1284indicates it is probably an abnormal hook; you should look at its
1278@samp{-hooks} have a value that is a list of functions. Any hook that 1285documentation to see how to use the hook properly.
1279is abnormal is abnormal because a normal hook won't do the job; either 1286
1280the functions are called with arguments, or their values are meaningful. 1287 If the variable's name ends in @samp{-functions} or @samp{-hooks},
1281The name shows you that the hook is abnormal and that you should look at 1288then the value is a list of functions, but it is abnormal in that either
1282its documentation string to see how to use it properly. 1289these functions are called with arguments or their values are used in
1283 1290some way. You can use @code{add-hook} to add a function to the list,
1284 Major mode functions are supposed to run a hook called the @dfn{mode 1291but you must take care in writing the function. (A few of these
1285hook} as the last step of initialization. This makes it easy for a user 1292variables are actually normal hooks which were named before we
1286to customize the behavior of the mode, by overriding the local variable 1293established the convention of using @samp{-hook} for them.)
1287assignments already made by the mode. But hooks are used in other 1294
1288contexts too. For example, the hook @code{suspend-hook} runs just 1295 If the variable's name ends in @samp{-function}, then its value
1289before Emacs suspends itself (@pxref{Suspending Emacs}). 1296is just a single function, not a list of functions.
1290 1297
1291 Here's an expression that uses a mode hook to turn on Auto Fill mode 1298 Here's an expression that uses a mode hook to turn on Auto Fill mode
1292when in Lisp Interaction mode: 1299when in Lisp Interaction mode: