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
(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, then
twhen that form is evaluated and the message will be added to
kill-emacs-hookregardless of what you do with the variable afterwards. So if your package is loaded (via autoload or otherwise) prior to the
setq, you'll always get the message.
init.el, then it will be evaluated afterwards in the package?
if. The only way to do that is to have the
defcustomin the package, and the
ifin your init file. A better way is to put the
ifin the form that gets added to
kill-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.