unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
Subject: RE: defcustom: changing from defvar - order of execution
Date: Tue, 3 May 2005 09:13:19 -0700	[thread overview]
Message-ID: <DNEMKBNJBGPAOPIJOOICEEIGCHAA.drew.adams@oracle.com> (raw)
In-Reply-To: <MEEKKIABFKKDFJMPIOEBMELMCKAA.drew.adams@oracle.com>

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.

  reply	other threads:[~2005-05-03 16:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-03 15:50 defcustom: changing from defvar - order of execution Drew Adams
2005-05-03 16:13 ` Drew Adams [this message]
     [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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DNEMKBNJBGPAOPIJOOICEEIGCHAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).