From: Drew Adams <drew.adams@oracle.com>
To: Alan Schmitt <alan.schmitt@polytechnique.org>
Cc: help-gnu-emacs@gnu.org
Subject: RE: which one to use: custom-set-variables, customize-set-variable, or customize-set-value?
Date: Mon, 30 Nov 2015 07:20:27 -0800 (PST) [thread overview]
Message-ID: <99f3716d-513e-42b5-b43b-fafca9c81f5a@default> (raw)
In-Reply-To: <m2610j27k2.fsf@polytechnique.org>
Hi Alan,
> Thank you for the explanation. For the moment I'm sticking with
> `customize-set-variable'
Good choice.
> and I'll see if I get in trouble.
I don't think you can get in trouble that way.
> > I agree that the doc is not very clear. Recently I forgot
> > that `customize-set-value' does not use the defcustom's :set
> > function, and I was bitten by the fact that it does not.
>
> I'm curious about this: what is the scenario where this can be
> a problem?
Situations where setting the variable is more complex than just
changing its value, that is, where other changes to the state
of Emacs need to be associated with the change in the variable
value.
If you look at the doc (Elisp manual, node Variable Definitions),
have a look at not only :set but also :initialize, to get an
idea of what can be involved. You will see, for example, that
there are multiple initialization functions that are predefined,
and they act differently with respect to :set and setting the
value during initialization. This might give you an idea of
different :set scenarios.
Here is one example of a :set function (from character-fold+.el)
that does something more than just change the value:
(defcustom char-fold-symmetric nil
"Non-nil means char-fold searching treats equivalent chars the same.
That is, use of any of a set of char-fold equivalent chars in a search
string finds any of them in the text being searched.
If nil then only the \"base\" or \"canonical\" char of the set matches
any of them. The others match only themselves, even when char-folding
is turned on."
:set (lambda (sym defs)
(custom-set-default sym defs)
(update-char-fold-table))
:type 'boolean :group 'isearch)
Standard function `custom-set-default' is the usual way to change
the variable's (default) value, so this :set function firt calls
that. Then it calls a function that changes some other state,
taking the new variable value into account.
HTH.
next prev parent reply other threads:[~2015-11-30 15:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-29 18:47 which one to use: custom-set-variables, customize-set-variable, or customize-set-value? Alan Schmitt
2015-11-29 19:19 ` Drew Adams
2015-11-30 8:52 ` Alan Schmitt
2015-11-30 15:20 ` Drew Adams [this message]
2015-11-30 15:44 ` Alan Schmitt
2015-12-11 18:23 ` Lele Gaifax
2015-12-11 18:53 ` Drew Adams
2015-12-12 8:31 ` Lele Gaifax
2015-12-12 12:09 ` tomas
2015-12-12 13:31 ` Lele Gaifax
2015-12-12 16:11 ` Drew Adams
2015-12-13 8:17 ` tomas
2015-12-13 17:32 ` Drew Adams
2015-12-14 2:44 ` B.V. Raghav
2015-12-14 8:28 ` Lele Gaifax
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=99f3716d-513e-42b5-b43b-fafca9c81f5a@default \
--to=drew.adams@oracle.com \
--cc=alan.schmitt@polytechnique.org \
--cc=help-gnu-emacs@gnu.org \
/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).