From: Drew Adams <drew.adams@oracle.com>
To: phillip.lord@newcastle.ac.uk
Cc: Rusi <rustompmody@gmail.com>, help-gnu-emacs@gnu.org
Subject: RE: In defense of Customize [was: Trying to right-align my window on startup]
Date: Thu, 16 Jan 2014 07:33:46 -0800 (PST) [thread overview]
Message-ID: <042f4c2c-d110-480f-aaa5-2a317855e189@default> (raw)
In-Reply-To: <87lhyg5jgy.fsf@newcastle.ac.uk>
> >> I would like to have a "custom-setq" which set a var, checked to see
> >> whether the types were correct wrt customize, then crashed if not. It
> >> would be nice to use the knowledge of customize from lisp.
> >
> > See commands `customize-set-variable' and `customize-set-value'.
>
> These don't do quite what I want.
See below - you might change your mind about that.
> As a random example,
It would be better to choose an example from the distributed vanilla
Emacs code. Emacs Dev is more likely (but far from guaranteed) to
use :type wisely and write accurate doc strings than is a random
3rd-party library developer.
> consider this:
> (defcustom pulse-flag (pulse-available-p)
> "...
> If the value is nil, ...
> If the value is `never', ...
> Any other value means ...."
> :group 'pulse :type 'boolean)
OK, the doc does not match the :type spec. So let's see what
the story is.
There are a couple of possibilities.
1. It could be that the intention was that the value really must
be as the doc describes it, and any other value should raise an
error. In which case, code that uses the option can and even
perhaps should depend on that. In that case, the :type is
incorrect.
Perhaps the programmer was lazy wrt specifying :type. See my
earlier post about that - users of defcustom should get to know
:type and do their best to use it to advantage.
2. It could be that the :type spec is correct and the doc string
is inaccurate. Seems unlikely in this case, but could be checked
by looking at how it is used in the library that defines it.
It is checked only by `eq'uality with symbol `never' and with nil.
One might conclude that the programmer in this case was lazy or
ignorant wrt :type, or just didn't care. It's also possible,
however, that this was the intention: a disconnect between the
actual possible values and the values users can set using
Customize. A programmer *can* intend such a disconnect (though
in that case it might be appropriate to document that, either
in the program doc or code comments).
The code itself never sets a value of `never', so it seems
unlikely that this is intended as an internal value (especially
since it is advertised in the doc string). Rather, it is likely
intended as a value that users can use.
Is it intentional that users *cannot* set the value to `never'
using Customize? Dunno.
My guess in this case would be that this is yet another case of
a programmer being lazy or not sufficiently :type-savvy. That
is all too common - in part perhaps because some tend to give
Customize a back seat, thinking it is only for wimps. (Akin to
a certain lack of respect for users, in my book.)
My guess is that what was meant was something like this:
:type '(choice
(const :tag "Do not color" never)
(const :tag "Color without pulsing" nil)
(sexp :tag "Color with pulsing" t))
That lets both `M-x customize-option' and `customize-set-variable'
DTRT. They both let you choose one of the same three "values" -
the :tags, actually. `customize-set-variable' lets you use
completion to do that. If you choose `Color with pulsing' then
you are prompted for a sexp that will be the value.
But hey! That's still not good enough. No doubt the sexp here
should not be either `nil' or `never'. To guard against that,
the :type should use `restricted-sexp' with an appropriate
predicate, instead of just `sexp'. You can see that things can
get complicated if the logic and use of an optin is complicated.
Whether that kind of treatment is really needed here, or whether
the last `choice' possibility could (and should) be just
(const :tag "Color with pulsing" t), would depend on what the
intention is, and thus what the code does with it.
> In this case, the ability to set an "illegal" value is actually
> useful, because the :type is wrong,
Yes. (Or so it seems - something is wrong, at least.)
> as legal values are t, nil or 'never (according to the
> documentation) not just 'boolean.
Yes.
> Why has this never been discovered? I would suggest two
> possibilities: a) the developers have never, ever set
> 'pulse-flag or b) they just used setq in their .emacs.
See above. Even if they use only setq, the code and doc do
not match. The likely answer in this case (based on a quick
check of how the variable is used) is that the developers were
either lazy wrt :type or ignorant wrt :type or did not really
care.
> If the latter is true, having a way of only setting legal
> values according to customize would have been helpful,
> because this would have crashed, and they would have fixed it.
See above.
next prev parent reply other threads:[~2014-01-16 15:33 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <<B67C92F68785104E8816FEEE2B44C9346F33C8FD@TEMCAS01.peinet.peinc.com>
[not found] ` <<83r48idw6z.fsf@gnu.org>
[not found] ` <<B67C92F68785104E8816FEEE2B44C9346F33C978@TEMCAS01.peinet.peinc.com>
[not found] ` <<83mwj5ekrs.fsf@gnu.org>
[not found] ` <<B67C92F68785104E8816FEEE2B44C9346F33D269@TEMCAS01.peinet.peinc.com>
[not found] ` <<28ab7799-fdc5-47c4-9ac0-f7db66771e7e@default>
[not found] ` <<83iotsdh9n.fsf@gnu.org>
2014-01-09 21:02 ` Trying to right-align my window on startup Drew Adams
2014-01-11 14:45 ` Juanma Barranquero
2014-01-11 17:35 ` poor Customize [was: Trying to right-align my window on startup] Drew Adams
[not found] ` <mailman.11630.1389461775.10748.help-gnu-emacs@gnu.org>
2014-01-13 15:11 ` jack-mac
2014-01-13 17:06 ` Drew Adams
[not found] ` <mailman.11626.1389451551.10748.help-gnu-emacs@gnu.org>
2014-01-14 9:24 ` Trying to right-align my window on startup Rusi
2014-01-14 17:37 ` In defense of Customize [was: Trying to right-align my window on startup] Drew Adams
2014-01-14 19:32 ` session.* files (was: In defense of Customize) gottlieb
2014-01-14 19:52 ` Peter Dyballa
2014-01-15 10:29 ` In defense of Customize [was: Trying to right-align my window on startup] Phillip Lord
2014-01-15 17:28 ` Drew Adams
2014-01-16 10:06 ` Phillip Lord
2014-01-16 15:33 ` Drew Adams [this message]
2014-01-14 17:53 ` Trying to right-align my window on startup Emanuel Berg
2014-01-14 17:57 ` Marcin Borkowski
[not found] ` <mailman.11925.1389722262.10748.help-gnu-emacs@gnu.org>
2014-01-14 18:15 ` Rusi
2014-01-14 18:19 ` Emanuel Berg
2014-01-15 4:44 ` Rusi
[not found] ` <mailman.11921.1389721075.10748.help-gnu-emacs@gnu.org>
2014-01-18 2:59 ` In defense of Customize [was: Trying to right-align my window on startup] Rusi
2014-01-18 4:42 ` Emanuel Berg
2014-01-18 15:31 ` Rusi
2014-01-28 15:17 ` Christoph Wedler
2014-01-28 18:35 ` Emanuel Berg
2014-01-29 10:57 ` Phillip Lord
2014-01-29 13:23 ` Stefan Monnier
2014-01-29 16:54 ` Phillip Lord
2014-01-29 18:26 ` Stefan Monnier
2014-01-30 9:59 ` Phillip Lord
[not found] ` <mailman.13090.1390993048.10748.help-gnu-emacs@gnu.org>
2014-01-29 16:52 ` Emanuel Berg
2014-01-29 17:19 ` Phillip Lord
[not found] ` <mailman.13107.1391015968.10748.help-gnu-emacs@gnu.org>
2014-01-29 18:21 ` Emanuel Berg
2014-01-29 0:47 ` Drew Adams
[not found] ` <mailman.13068.1390956492.10748.help-gnu-emacs@gnu.org>
2014-01-30 10:14 ` Christoph Wedler
2014-01-30 13:23 ` Stefan Monnier
2014-01-30 16:06 ` Drew Adams
[not found] ` <mailman.13194.1391088219.10748.help-gnu-emacs@gnu.org>
2014-01-30 16:15 ` Rusi
2014-01-30 18:44 ` Emanuel Berg
2014-01-31 9:56 ` Phillip Lord
[not found] ` <mailman.13338.1391162177.10748.help-gnu-emacs@gnu.org>
2014-01-31 12:08 ` Rusi
2014-01-31 20:41 ` Emanuel Berg
2014-01-31 20:39 ` Emanuel Berg
[not found] ` <mailman.13229.1391098001.10748.help-gnu-emacs@gnu.org>
2014-01-31 6:54 ` Rusi
2014-01-31 17:50 ` Christoph Wedler
2014-01-08 20:11 Trying to right-align my window on startup Mickey Ferguson
2014-01-08 21:01 ` Eli Zaretskii
[not found] ` <B67C92F68785104E8816FEEE2B44C9346F33C978@TEMCAS01.peinet.peinc.com>
2014-01-09 6:23 ` Eli Zaretskii
2014-01-09 20:16 ` Mickey Ferguson
2014-01-09 20:30 ` Eli Zaretskii
2014-01-09 20:32 ` Drew Adams
2014-01-09 20:36 ` Eli Zaretskii
2014-01-09 20:41 ` Marcin Borkowski
2014-01-09 21:04 ` Drew Adams
[not found] ` <mailman.11466.1389300108.10748.help-gnu-emacs@gnu.org>
2014-01-09 21:43 ` Sebastien Vauban
2014-01-09 22:23 ` Drew Adams
2014-01-10 22:31 ` Mickey Ferguson
2014-01-10 23:09 ` Drew Adams
2014-01-11 1:17 ` Mickey Ferguson
2014-01-11 3:07 ` Drew Adams
2014-01-13 23:14 ` Mickey Ferguson
2014-01-14 4:55 ` Eli Zaretskii
[not found] ` <<83k3e8dhj9.fsf@gnu.org>
2014-01-09 21:02 ` 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
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=042f4c2c-d110-480f-aaa5-2a317855e189@default \
--to=drew.adams@oracle.com \
--cc=help-gnu-emacs@gnu.org \
--cc=phillip.lord@newcastle.ac.uk \
--cc=rustompmody@gmail.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).