From c44d2ceda94f66937c938dd35311aa3a8c7b7ae0 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Tue, 20 Sep 1994 01:05:37 +0000 Subject: [PATCH] *** empty log message *** --- lispref/modes.texi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lispref/modes.texi b/lispref/modes.texi index fb71606f925..36c20ce8764 100644 --- a/lispref/modes.texi +++ b/lispref/modes.texi @@ -1381,3 +1381,21 @@ function goes at the end of the hook list and will be executed last. @defun remove-hook hook function This function removes @var{function} from the hook variable @var{hook}. @end defun + +If you make a hook variable buffer-local, copy its value before you use +@code{add-hook} or @code{remove-hook} to change it. For example, + +@example +(defun my-major-mode () + @dots{} + (make-local-variable 'foo-hook) + (if (boundp 'foo-hook) + (setq foo-hook (copy-sequence foo-hook))) + (add-hook 'foo-hook 'my-foo-function)" + @dots{} + ) +@end example + +Otherwise you may accidentally alter the list structure that forms part +of the global value of the hook variable. + -- 2.39.5