* defcustom and autoload
@ 2007-06-09 3:01 nobrowser
2007-06-09 12:40 ` Daniel Jensen
2007-06-12 14:14 ` Stefan Monnier
0 siblings, 2 replies; 3+ messages in thread
From: nobrowser @ 2007-06-09 3:01 UTC (permalink / raw)
To: help-gnu-emacs
I am quite confused about autoloading customization definitions.
Until now I have assumed it was a good idea to put ;;;###autoload
thingies before all my defcustom forms and to generate a foo-
autoloads.el file that users could load for "one stop" initialization
of my package. Indeed it almost seemed that *not* doing it was like
forcing the user to experience wrong behaviour from the package first
to get the chance to adjust it.
I have not generated the foo-autoloads until now, because during
development I always load the code in toto from my .emacs. But now I
have tried that, and I found that the settings I have in the custom-
set-variables block in my .emacs get overriden later when I load the
foo-autoloads. This despite the fact that foo-autoloads seems to
contain defvar forms - which should refrain from setting a variable
that is already set. What is special about the variable settings done
by custom-set-variables that makes them "soft" this way?
Then I looked at the Elisp files that come with Emacs. I haven't gone
through all of them, but it seems almost *none* of them specify
autoloading for their defcustoms. What gives? Are users really
expected to load the whole library (and that assumes they know which
one) before being able to customize a variable in it?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: defcustom and autoload
2007-06-09 3:01 defcustom and autoload nobrowser
@ 2007-06-09 12:40 ` Daniel Jensen
2007-06-12 14:14 ` Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Jensen @ 2007-06-09 12:40 UTC (permalink / raw)
To: help-gnu-emacs
nobrowser@gmail.com writes:
> I have not generated the foo-autoloads until now, because during
> development I always load the code in toto from my .emacs. But now I
> have tried that, and I found that the settings I have in the custom-
> set-variables block in my .emacs get overriden later when I load the
> foo-autoloads. This despite the fact that foo-autoloads seems to
> contain defvar forms - which should refrain from setting a variable
> that is already set. What is special about the variable settings done
> by custom-set-variables that makes them "soft" this way?
You are correct in assuming that defvar will not bind variables that
have values. The problem is that the variables were not bound initially.
You have to load the autoloads /before/ you use custom-set-variables,
unless you specify that the variables should be bound immediately:
(custom-set-variables '(foo 42 t)) ; t means set it now
> Then I looked at the Elisp files that come with Emacs. I haven't gone
> through all of them, but it seems almost *none* of them specify
> autoloading for their defcustoms.
Try loaddefs.el.
> What gives? Are users really
> expected to load the whole library (and that assumes they know which
> one) before being able to customize a variable in it?
In Emacs 22, the autoload cookie will automatically generate a
custom-autoload form for defcustom, in addition to the defvar form.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: defcustom and autoload
2007-06-09 3:01 defcustom and autoload nobrowser
2007-06-09 12:40 ` Daniel Jensen
@ 2007-06-12 14:14 ` Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2007-06-12 14:14 UTC (permalink / raw)
To: help-gnu-emacs
> Then I looked at the Elisp files that come with Emacs. I haven't gone
> through all of them, but it seems almost *none* of them specify
> autoloading for their defcustoms.
Yes. It's generally not a good idea to autoload variables.
> What gives? Are users really expected to load the whole library (and that
> assumes they know which one) before being able to customize a variable
> in it?
Yes.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-06-12 14:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-09 3:01 defcustom and autoload nobrowser
2007-06-09 12:40 ` Daniel Jensen
2007-06-12 14:14 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.