Is it possible to run code when setting an option defined by defcustom?
For example, I would like (setq my-package-option t) to install a hook.
While defcustom has a :set keyword, it's documented only to run in the user interface.
This is close to working, it has an error about a recursive function call.
(defcustom my-boolean-example nil "Docs." :set #'(lambda (var value) (if (set-default var value) (turn-thing-on) (turn-thing-off))) :initialize 'custom-initialize-changed :type 'boolean)
:initialize: gnu.org/software/emacs/manual/html_node/elisp/…(setq pkg-var <foo>)is considered a bad idea. If the user wants to allow pkg's author to do that, they should usecustomize-set-variableinsterad ofsetq.setqing the variable).