# HG changeset patch # User Richard M. Stallman # Date 780023137 0 # Node ID d7dc9a5b8c700fff6b8d549c1cb014fa089fc5d0 # Parent 0ea4cc4ca33999ed2c55ca85737d99d8bbce91f1 *** empty log message *** diff -r 0ea4cc4ca339 -r d7dc9a5b8c70 lispref/modes.texi --- a/lispref/modes.texi Tue Sep 20 00:59:24 1994 +0000 +++ b/lispref/modes.texi Tue Sep 20 01:05:37 1994 +0000 @@ -1381,3 +1381,21 @@ @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. +