unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* defcustom: changing from defvar - order of execution
@ 2005-05-03 15:50 Drew Adams
  2005-05-03 16:13 ` Drew Adams
       [not found] ` <mailman.3227.1115174847.2819.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 17+ messages in thread
From: Drew Adams @ 2005-05-03 15:50 UTC (permalink / raw)


I'm unclear on the recommended way to change Lisp code from using defvar for
user options to using defcustom. I guess I'm also unclear on just how
defcustom and Customize work. I couldn't find an explanation of this in Info
for Emacs or Emacs Lisp.

Initial setup - library foo.el has this:

 (defvar foovar nil)
 (defun foo-fn () foovar)

Initial setup - user has this in .emacs:

 (defvar foovar t)
 (load-library "foo")
 (foo-fn)

When .emacs is loaded, (foo-fn) is executed, foovar is `t', so (foo-fn)
returns `t'.


Second setup - library foo.el has this:

 (defcustom foovar nil)
 (defun foo-fn () foovar)

Second setup - user has this in .emacs, after customizing foovar to `t' with
Customize:

 (load-library "foo")
 (foo-fn)
 ...
 (custom-set-variables '(foovar t)...)

When .emacs is loaded, (foo-fn) is executed, foovar is (has default value)
`nil', so (foo-fn) returns `nil'.

That is, because (custom-set-variables...) is executed after (foo-fn), it
has no effect during foo-fn's execution.

What am I missing/confusing here? What is the proper way for library foo.el
to move from using defvar to using defcustom? Also, what difference does it
make, if any, whether a defcustom is executed at the top level or a lower
level of a file.

Thanks. - Drew

^ permalink raw reply	[flat|nested] 17+ messages in thread
[parent not found: <mailman.3356.1115247555.2819.help-gnu-emacs@gnu.org>]
[parent not found: <mailman.3782.1115404280.2819.help-gnu-emacs@gnu.org>]
[parent not found: <mailman.3763.1115399076.2819.help-gnu-emacs@gnu.org>]
[parent not found: <mailman.4474.1115750087.2819.help-gnu-emacs@gnu.org>]
[parent not found: <mailman.4674.1115829901.2819.help-gnu-emacs@gnu.org>]

end of thread, other threads:[~2005-05-11 18:32 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-03 15:50 defcustom: changing from defvar - order of execution Drew Adams
2005-05-03 16:13 ` Drew Adams
     [not found] ` <mailman.3227.1115174847.2819.help-gnu-emacs@gnu.org>
2005-05-04 15:03   ` Stefan Monnier
2005-05-04 22:49     ` Drew Adams
2005-05-04 15:51   ` rgb
2005-05-04 22:49     ` Drew Adams
     [not found] <mailman.3356.1115247555.2819.help-gnu-emacs@gnu.org>
2005-05-06  3:20 ` Stefan Monnier
2005-05-06 17:00   ` Drew Adams
     [not found] <mailman.3782.1115404280.2819.help-gnu-emacs@gnu.org>
2005-05-07 15:56 ` Stefan Monnier
     [not found] <mailman.3763.1115399076.2819.help-gnu-emacs@gnu.org>
2005-05-06 17:38 ` Stefan Monnier
2005-05-06 18:19   ` Drew Adams
2005-05-10 16:14 ` Per Abrahamsen
2005-05-10 18:32   ` Drew Adams
     [not found] <mailman.4474.1115750087.2819.help-gnu-emacs@gnu.org>
2005-05-11 14:07 ` Stefan Monnier
2005-05-11 16:36   ` Drew Adams
2005-05-11 16:37   ` Drew Adams
     [not found] <mailman.4674.1115829901.2819.help-gnu-emacs@gnu.org>
2005-05-11 18:32 ` Stefan Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).