我在学习hook
#+BEGIN_SRC elisp
;; 定义一个自定义 hook 变量
(defvar my-custom-hook nil
"Custom hook for demonstration purposes.")
;; 定义一个函数,将其添加到 my-custom-hook
(defun my-custom-function1 ()
"Function 1 to run when the custom hook is triggered."
(message "Custom function 1 is triggered!"))
;; 将函数添加到 my-custom-hook
(add-hook 'my-custom-hook 'my-custom-function1)
(defun some-useful-function ()
(run-hooks 'my-custom-hook)
(message "do something else"))
(some-useful-function)
#+END_SRC
#+RESULTS:
: do something else
上面的代码是不是hook的原理? 但是为什么没有打印出 Custom function 1 is triggered!
呢?