diff options
| author | Lars Ingebrigtsen | 2021-05-03 10:45:30 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-05-03 10:45:30 +0200 |
| commit | eddb00c5bf9ed51bd0b6ea4ff1613f8af6e3cbdd (patch) | |
| tree | b9c8b08741aa30a861011d30ca73928c0accbdf8 | |
| parent | 81fc95bf22cadc09178e7ccfc13eba531660ddcd (diff) | |
| download | emacs-eddb00c5bf9ed51bd0b6ea4ff1613f8af6e3cbdd.tar.gz emacs-eddb00c5bf9ed51bd0b6ea4ff1613f8af6e3cbdd.zip | |
Note that function symbols are preferred in `add-hook'
* lisp/subr.el (add-hook): Note that FUNCTION should preferably be
a symbol (bug#47992).
| -rw-r--r-- | lisp/subr.el | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 964eb8f8ca2..7a055f2ba1e 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -1815,9 +1815,15 @@ This makes the hook buffer-local, and it makes t a member of the | |||
| 1815 | buffer-local value. That acts as a flag to run the hook | 1815 | buffer-local value. That acts as a flag to run the hook |
| 1816 | functions of the global value as well as in the local value. | 1816 | functions of the global value as well as in the local value. |
| 1817 | 1817 | ||
| 1818 | HOOK should be a symbol, and FUNCTION may be any valid function. If | 1818 | HOOK should be a symbol. If HOOK is void, it is first set to |
| 1819 | HOOK is void, it is first set to nil. If HOOK's value is a single | 1819 | nil. If HOOK's value is a single function, it is changed to a |
| 1820 | function, it is changed to a list of functions." | 1820 | list of functions. |
| 1821 | |||
| 1822 | FUNCTION may be any valid function, but it's recommended to use a | ||
| 1823 | function symbol and not a lambda form. Using a symbol will | ||
| 1824 | ensure that the function is not re-added if the function is | ||
| 1825 | edited, and using lambda forms may also have a negative | ||
| 1826 | performance impact when running `add-hook' and `remove-hook'." | ||
| 1821 | (or (boundp hook) (set hook nil)) | 1827 | (or (boundp hook) (set hook nil)) |
| 1822 | (or (default-boundp hook) (set-default hook nil)) | 1828 | (or (default-boundp hook) (set-default hook nil)) |
| 1823 | (unless (numberp depth) (setq depth (if depth 90 0))) | 1829 | (unless (numberp depth) (setq depth (if depth 90 0))) |