In my package I have the following:
(defcustom foobar-on-exit t
"Boolean variable, enabled by default."
:type 'boolean
:group 'foobar)
(if foobar-on-exit
(add-hook 'kill-emacs-hook 'some-message))
So I get a message when I close Emacs.
Then in my init.el I set the value of foobar-on-exit on nil.
(setq foobar-on-exit 'nil)
After evaluating or restarting, I still got the message while the variable foobar-on-exit is still false.
So somewhere I went wrong. Any hint?
ifstatement is in your package, thenfoobar-on-exitwill betwhen that form is evaluated and the message will be added tokill-emacs-hookregardless of what you do with the variable afterwards. So if your package is loaded (via autoload or otherwise) prior to thesetq, you'll always get the message.init.el, then it will be evaluated afterwards in the package?defcustom,setq,if. The only way to do that is to have thedefcustomin the package, and thesetqandifin your init file. A better way is to put theifin the form that gets added tokill-emacs-hook, so it will always use the current value at shutdown time.ifinto a function, that will do evaluating, and I added that function to a hook. Thanks for your suggestion, it's appreciated. Wish I could mark your answer as the right one.