emacs - 为什么 add-hook 允许 `hook' 无效?

标签 emacs elisp

来自 C-h f 添加钩子(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))
  ...

这有什么用?我认为它在某种程度上是有用的,否则它不会存在......我只是想不出它有什么好的用途......

最佳答案

它允许您在加载定义它们的包之前设置钩子(Hook)变量。

关于emacs - 为什么 add-hook 允许 `hook' 无效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21104788/

相关文章:

Emacs - 在编辑位置设置标记

emacs - 为 Org-mode 中的每个条目分配 ID

emacs - 使用 key 作为前缀和命令

Emacs:如何绑定(bind)两次点击的键?

emacs中的Shell通过在它们前面显示变量的名称\200\230

Emacs Etags 返回起始缓冲区/位置

lisp - 修改函数;保存到 lisp 中的新函数

emacs - 如何将 Hyperspec 文档连接到 MS Windows 上的 Emacs SLIME

emacs - 如何在 emacs 中标记文本

emacs - 在 Emacs 中显示封闭的 #ifdef block