From: Richard M. Stallman Date: Tue, 20 Sep 1994 01:05:37 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: emacs-19.34~6925 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c44d2ceda94f66937c938dd35311aa3a8c7b7ae0;p=emacs.git *** empty log message *** --- 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. +