I'm trying to make this little convenience function work:
(defun my-make-hook (when procedure)
(let ((hook-symbol (intern (concat
(substring (symbol-name when) 1)
"-"
(symbol-name procedure)
"-hook"))))
(unless (boundp hook-symbol)
(set hook-symbol nil)
(advice-add procedure when (lambda (&rest _) (run-hooks hook-symbol)))
hook-symbol)))
But I'm getting an error that the interned symbol is void, and I believe I may actually be somehow setting the value of the symbol hook-symbol
itself, rather than the symbol that hook-symbol
evaluates to.
EDIT: I'm calling it with, e.g., (my-make-hook :after 'load-theme).
my-make-hook
? – Tyler Feb 27 '17 at 17:43around-load-theme-hook
s. – politza Feb 27 '17 at 21:28hook-symbol
in the lambda with the newly created symbol (say,after-load-theme-hook
) instead of making the lambda refer to the lexical variablehook-symbol
? – Keith Feb 27 '17 at 21:52:before
and:after
. I haven't used any abnormal hooks. My original code threw an error ifwhen
wasn't:before
or:after
, but I omitted that to make the procedure more clear. – Keith Feb 27 '17 at 21:55