[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master eddb00c: Note that function symbols are preferred in `add-hook'
From: |
Lars Ingebrigtsen |
Subject: |
master eddb00c: Note that function symbols are preferred in `add-hook' |
Date: |
Mon, 3 May 2021 04:46:08 -0400 (EDT) |
branch: master
commit eddb00c5bf9ed51bd0b6ea4ff1613f8af6e3cbdd
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Note that function symbols are preferred in `add-hook'
* lisp/subr.el (add-hook): Note that FUNCTION should preferably be
a symbol (bug#47992).
---
lisp/subr.el | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index 964eb8f..7a055f2 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
buffer-local value. That acts as a flag to run the hook
functions of the global value as well as in the local value.
-HOOK should be a symbol, and FUNCTION may be any valid function. If
-HOOK is void, it is first set to nil. If HOOK's value is a single
-function, it is changed to a list of functions."
+HOOK should be a symbol. If HOOK is void, it is first set to
+nil. If HOOK's value is a single function, it is changed to a
+list of functions.
+
+FUNCTION may be any valid function, but it's recommended to use a
+function symbol and not a lambda form. Using a symbol will
+ensure that the function is not re-added if the function is
+edited, and using lambda forms may also have a negative
+performance impact when running `add-hook' and `remove-hook'."
(or (boundp hook) (set hook nil))
(or (default-boundp hook) (set-default hook nil))
(unless (numberp depth) (setq depth (if depth 90 0)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master eddb00c: Note that function symbols are preferred in `add-hook',
Lars Ingebrigtsen <=