diff options
| author | Richard M. Stallman | 1994-09-20 01:05:37 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-09-20 01:05:37 +0000 |
| commit | c44d2ceda94f66937c938dd35311aa3a8c7b7ae0 (patch) | |
| tree | 259a60379eea182c74bbed2f70bdd5a6d27f404c | |
| parent | 2a598462ecee6f6fd7ce5f14b095ff0247f7692d (diff) | |
| download | emacs-c44d2ceda94f66937c938dd35311aa3a8c7b7ae0.tar.gz emacs-c44d2ceda94f66937c938dd35311aa3a8c7b7ae0.zip | |
*** empty log message ***
| -rw-r--r-- | lispref/modes.texi | 18 |
1 files changed, 18 insertions, 0 deletions
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. | |||
| 1381 | @defun remove-hook hook function | 1381 | @defun remove-hook hook function |
| 1382 | This function removes @var{function} from the hook variable @var{hook}. | 1382 | This function removes @var{function} from the hook variable @var{hook}. |
| 1383 | @end defun | 1383 | @end defun |
| 1384 | |||
| 1385 | If you make a hook variable buffer-local, copy its value before you use | ||
| 1386 | @code{add-hook} or @code{remove-hook} to change it. For example, | ||
| 1387 | |||
| 1388 | @example | ||
| 1389 | (defun my-major-mode () | ||
| 1390 | @dots{} | ||
| 1391 | (make-local-variable 'foo-hook) | ||
| 1392 | (if (boundp 'foo-hook) | ||
| 1393 | (setq foo-hook (copy-sequence foo-hook))) | ||
| 1394 | (add-hook 'foo-hook 'my-foo-function)" | ||
| 1395 | @dots{} | ||
| 1396 | ) | ||
| 1397 | @end example | ||
| 1398 | |||
| 1399 | Otherwise you may accidentally alter the list structure that forms part | ||
| 1400 | of the global value of the hook variable. | ||
| 1401 | |||