Discussion:
bug#14247: 24.3.50; Autoloaded defcustom in package loses saved setting
(too old to reply)
Stefan Monnier
2013-04-23 19:52:09 UTC
Permalink
This obviously yields the suggestion "don't do that, then", but the
manual doesn't seem to discourage the programmer from using autoload
cookies with defcustom, so I think either the behaviour or the manual
should be changed.
Using autoloads cookies on defvars and defcustom is indeed something
I generally discourage and I'd like to see such uses diminish.

But at the same time, they are sometimes important, so we should
definitely try to make it work right.

Note that "for M-x customize-option to list it" is not a good reason to
autoload a variable. We should teach customize-option to load packages
as needed to really remove this desire to autoload variables.


Stefan
Mauro Aranda
2020-01-05 15:25:25 UTC
Permalink
1. Set HOME to the name of an empty directory and start a fresh Emacs.
;;; foo.el --- test autoloaded defcustom
;;;
;;; Version: 0.1
;;;###autoload
(defcustom foo-setting nil
"A boolean setting."
:type 'boolean)
;;;###autoload
(defun foo-get-setting ()
(interactive)
(message "foo-setting is %s" foo-setting))
(provide 'foo)
;;; foo.el ends here
3. Install foo.el with M-x package-install-file.
4. Type M-x customize-option RET foo-setting RET, set the setting to t,
and "save for future sessions".
5. Exit and restart Emacs, still with the new home directory.
6. Type M-x foo-get-setting. I would expect it to say "foo-setting is
t", but it says "foo-setting is nil".
At this point, M-x customize-option RET foo-setting RET will say that
the variable is "CHANGED outside Customize", and choosing "Revert This
Session's Customization" will set foo-setting to t, i.e. the value saved
through Customize.
I've tried to reproduce this on the emacs-27 branch, but I can't.
I get:
"foo-setting is t", and the STATE in the customize buffer is SAVED and
set.
Mauro Aranda
2020-09-02 20:46:01 UTC
Permalink
Post by Mauro Aranda
1. Set HOME to the name of an empty directory and start a fresh Emacs.
;;; foo.el --- test autoloaded defcustom
;;;
;;; Version: 0.1
;;;###autoload
(defcustom foo-setting nil
"A boolean setting."
:type 'boolean)
;;;###autoload
(defun foo-get-setting ()
(interactive)
(message "foo-setting is %s" foo-setting))
(provide 'foo)
;;; foo.el ends here
3. Install foo.el with M-x package-install-file.
4. Type M-x customize-option RET foo-setting RET, set the setting to t,
and "save for future sessions".
5. Exit and restart Emacs, still with the new home directory.
6. Type M-x foo-get-setting. I would expect it to say "foo-setting is
t", but it says "foo-setting is nil".
At this point, M-x customize-option RET foo-setting RET will say that
the variable is "CHANGED outside Customize", and choosing "Revert This
Session's Customization" will set foo-setting to t, i.e. the value saved
through Customize.
I've tried to reproduce this on the emacs-27 branch, but I can't.
"foo-setting is t", and the STATE in the customize buffer is SAVED and
set.
This was 8 months ago. In the meantime, I was able to reproduce this on
Emacs 24.5, but not with Emacs 25.1 and beyond.

So I'm going to go ahead and close this as fixed. If this is
incorrect, please reopen.

Loading...