aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Stallman2020-02-06 18:28:49 -0500
committerRichard Stallman2020-02-06 18:28:49 -0500
commit53f0de5d7719b43f184ce1a910f14882aedc50bc (patch)
tree256bb37eca3346f8e27eebc0532533bed911bc54
parent12d004d6eee2d136825df92eca33eaa6b705030b (diff)
downloademacs-53f0de5d7719b43f184ce1a910f14882aedc50bc.tar.gz
emacs-53f0de5d7719b43f184ce1a910f14882aedc50bc.zip
Lispref: Explain avoiding lambdas on hooks.
(lispref/modes.texi): Explain avoiding lambdas on hooks.
-rw-r--r--doc/lispref/modes.texi17
1 files changed, 15 insertions, 2 deletions
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 7354eb1b9f8..b52871ef70b 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -135,13 +135,26 @@ non-@code{nil} value, it returns that value; otherwise it returns
135@node Setting Hooks 135@node Setting Hooks
136@subsection Setting Hooks 136@subsection Setting Hooks
137 137
138 Here's an example that uses a mode hook to turn on Auto Fill mode when 138 Here's an example that adds a funtion to a mode hook to turn
139in Lisp Interaction mode: 139on Auto Fill mode when in Lisp Interaction mode:
140 140
141@example 141@example
142(add-hook 'lisp-interaction-mode-hook 'auto-fill-mode) 142(add-hook 'lisp-interaction-mode-hook 'auto-fill-mode)
143@end example 143@end example
144 144
145 The value of a hook variable should be a list of functions. You can
146manipulate that list using the normal Lisp facilities, but the modular
147way is to use the functions @code{add-hook} and @code{remove-hook},
148defined below. They take care to handle some unusual situations and
149avoid problems.
150
151 It works to put a @code{lambda}-expression function on a hook, but
152we recommend avoiding this because it can lead to confusion. If you
153add the same @code{lambda}-expression a second time but write it
154slightly differently, you will get two equivalent but distinct
155functions on the hook. If you then remove one of them, the other will
156still be on it.
157
145@defun add-hook hook function &optional depth local 158@defun add-hook hook function &optional depth local
146This function is the handy way to add function @var{function} to hook 159This function is the handy way to add function @var{function} to hook
147variable @var{hook}. You can use it for abnormal hooks as well as for 160variable @var{hook}. You can use it for abnormal hooks as well as for