来自 C-h f add-hook :
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.
并从代码中获取:
(defun add-hook (hook function &optional append local)
...
(or (boundp hook) (set hook nil))
(or (default-boundp hook) (set-default hook nil))
...
这有什么好处?我认为它在某种程度上是有用的,否则它就不会存在......我只是想不出它的好用......
答案 0 :(得分:5)
它允许您在加载定义它们的包之前设置钩子变量。