aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2021-05-03 10:45:30 +0200
committerLars Ingebrigtsen2021-05-03 10:45:30 +0200
commiteddb00c5bf9ed51bd0b6ea4ff1613f8af6e3cbdd (patch)
treeb9c8b08741aa30a861011d30ca73928c0accbdf8
parent81fc95bf22cadc09178e7ccfc13eba531660ddcd (diff)
downloademacs-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.el12
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
1815buffer-local value. That acts as a flag to run the hook 1815buffer-local value. That acts as a flag to run the hook
1816functions of the global value as well as in the local value. 1816functions of the global value as well as in the local value.
1817 1817
1818HOOK should be a symbol, and FUNCTION may be any valid function. If 1818HOOK should be a symbol. If HOOK is void, it is first set to
1819HOOK is void, it is first set to nil. If HOOK's value is a single 1819nil. If HOOK's value is a single function, it is changed to a
1820function, it is changed to a list of functions." 1820list of functions.
1821
1822FUNCTION may be any valid function, but it's recommended to use a
1823function symbol and not a lambda form. Using a symbol will
1824ensure that the function is not re-added if the function is
1825edited, and using lambda forms may also have a negative
1826performance 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)))