all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Per Abrahamsen <abraham@dina.kvl.dk>
Subject: Re: defcustom: changing from defvar - order of execution
Date: Tue, 10 May 2005 18:14:59 +0200	[thread overview]
Message-ID: <rjwtq79hx8.fsf@sheridan.dina.kvl.dk> (raw)
In-Reply-To: mailman.3763.1115399076.2819.help-gnu-emacs@gnu.org

"Drew Adams" <drew.adams@oracle.com> writes:

>   (defcustom align-load-hook nil
>     "*Hook that gets run after the aligner has been loaded."
>     :type 'hook
>     :group 'align)
>
>   (run-hooks 'align-load-hook)

Load hooks are rather special, and shouldn't be declared with
defcustom.  Anyone using a load hook should be comfortable with Emacs
Lisp.

> Here's another example:
>
>   (defcustom apropos-symbol-face 'bold
>     "*Face for symbol name in Apropos output, or nil for none."
>     :group 'apropos
>     :type 'face)
>
>   (define-button-type 'apropos-symbol
>     'face apropos-symbol-face
>     'help-echo "mouse-2, RET: Display more help on this symbol"
>     'follow-link t
>     'action #'apropos-symbol-button-display-help
>     'skip t)

Problematic in any case, since changing apropos-symbol-face from
customize will have no immidiate effect.  It would be better to have
apropos-symbol-face being an actual face, inheriting from bold.  But
because face inheritance wasn't in Emacs 19.0, Emacs is very
incosistent about when to use faces, and when to use variables
containing faces.  Also in new code, since bad habbits don't die
easily. 

>   (defcustom mouse-avoidance-mode nil...)
>   (if mouse-avoidance-mode
>       (mouse-avoidance-mode mouse-avoidance-mode))

Is there a :set in the defcustom?  Global minor mode variables should
have one, so changing the variable from customize will turn the minor
mode on or off.  This will also solve the initialization order problem
(with the risk of doing some unnecessary work).

> Here's another example:
>
>   (defcustom calculator-use-menu t ...)
>   (or calculator-mode-map
>       ...
>       (if (and calculator-use-menu ...

calculator-use-menu should be a global minor mode, see above.

> These examples are taken from just the first few standard Elisp libraries,
> sorted alphabetically. I could go on, but you get the idea.

As you see, the answer depends on the example.  But a common answer is
that if you need to depend on a user variable in the initialization,
the user variable should have a :set that undo the effect if the user
change it.

> How is the user's customization (via Customize) taken into account in such
> cases, if the custom-set-variables form is inserted at the _end_ of his
> .emacs or custom-file? It looks to me like the _library_ (default) values of
> such variables, not the user's customized values, will be used in the
> library.

The location in the .emacs file is just exposing the problem to more,
in all cases the problem would show up if the library was loaded from
the site initialization file, or even dumped with Emacs.

  parent reply	other threads:[~2005-05-10 16:14 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.3763.1115399076.2819.help-gnu-emacs@gnu.org>
2005-05-06 17:38 ` defcustom: changing from defvar - order of execution Stefan Monnier
2005-05-06 18:19   ` Drew Adams
2005-05-10 16:14 ` Per Abrahamsen [this message]
2005-05-10 18:32   ` Drew Adams
2005-05-11 15:08     ` customization; std vs. personal libraries ken
     [not found]     ` <mailman.4670.1115825568.2819.help-gnu-emacs@gnu.org>
2005-05-11 23:12       ` Thien-Thi Nguyen
2005-05-19 15:22       ` Per Abrahamsen
2005-05-19 17:55         ` Kevin Rodgers
     [not found] <mailman.4674.1115829901.2819.help-gnu-emacs@gnu.org>
2005-05-11 18:32 ` defcustom: changing from defvar - order of execution Stefan Monnier
     [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.3782.1115404280.2819.help-gnu-emacs@gnu.org>
2005-05-07 15:56 ` Stefan Monnier
     [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
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>
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

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

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

  git send-email \
    --in-reply-to=rjwtq79hx8.fsf@sheridan.dina.kvl.dk \
    --to=abraham@dina.kvl.dk \
    /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.
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.