aboutsummaryrefslogtreecommitdiffstats
path: root/lispref/modes.texi
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 /lispref/modes.texi
parent4f8aaa7480ecc26189f1a338bd7f45f6d54446bf (diff)
downloademacs-dd73b091cbdfa4a9268fb0de925faab04e5bab44.tar.gz
emacs-dd73b091cbdfa4a9268fb0de925faab04e5bab44.zip
Explain better about abnormal hooks.
Diffstat (limited to 'lispref/modes.texi')
-rw-r--r--lispref/modes.texi43
1 files changed, 25 insertions, 18 deletions
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: