Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does add-hook allow `hook' to be void?

Tags:

emacs

elisp

From 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.

and from the code:

(defun add-hook (hook function &optional append local)
  ...
  (or (boundp hook) (set hook nil))
  (or (default-boundp hook) (set-default hook nil))
  ...

What is this good for? I assume it's somehow useful or else it wouldn't be there... I just can't think of a good use for it...

like image 682
mgalgs Avatar asked Feb 19 '26 02:02

mgalgs


1 Answers

It allows you to set hook variables before the packages which define them have been loaded.

like image 163
verdammelt Avatar answered Feb 21 '26 17:02

verdammelt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!