I want to run some code after loading my custom file, but I want to do it in a generic fashion. The easy way would be to just have a list of functions that I append to and then execute each function in a list afterwards, but I wanted to see if I could do it as a hook. Something like:
(run-hooks 'bw-after-custom-load-hook)
and do this each time I want to add to it:
(add-hook 'bw-after-custom-load-hook (lambda () 'something))
Is this basically how hooks work? All documentation I can find only seems to add stuff to existing hooks provided by modes.
I worked it out (should have tried before posting):
;; add my custom hook
(defvar bw-after-custom-load-hook nil
"Hook called after the custom file is loaded")
then in another file:
;; but load it after custom has loaded, so it's marked safe
(add-hook 'bw-after-custom-load-hook
(lambda ()
(load-theme 'solarized-dark)))
then we load custom and call the hook:
;; Load custom file last
(setq custom-file (concat dotfiles-dir "custom.el"))
(load custom-file 'noerror)
;; load my custom hooks
(run-hooks 'bw-after-custom-load-hook)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With