[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: defcustom: changing from defvar - order of execution
From: |
Drew Adams |
Subject: |
RE: defcustom: changing from defvar - order of execution |
Date: |
Tue, 3 May 2005 09:13:19 -0700 |
Oops - before someone gripes about users using defvar for variables that are
defined in libraries, let me change the initial user setup from this:
(defvar foovar t)
(load-library "foo")
(foo-fn)
to this:
(setq foovar t)
(load-library "foo")
(foo-fn)
I don't think it changes my overall question, in any case. Thanks. - Drew
-----Original Message-----
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.
- Re: defcustom: changing from defvar - order of execution, Stefan Monnier, 2005/05/04
- Re: defcustom: changing from defvar - order of execution, Stefan Monnier, 2005/05/05
- Re: defcustom: changing from defvar - order of execution, Stefan Monnier, 2005/05/06
- Re: defcustom: changing from defvar - order of execution, Stefan Monnier, 2005/05/07
- Re: defcustom: changing from defvar - order of execution, Per Abrahamsen, 2005/05/10