help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: In defense of Customize [was: Trying to right-align my window on sta


From: Phillip Lord
Subject: Re: In defense of Customize [was: Trying to right-align my window on startup]
Date: Thu, 16 Jan 2014 10:06:37 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

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

>> 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'.
>
> (IMHO, `set-variable', which is also for setting a user variable,
> should behave similarly, but it does not.)
>

These don't do quite what I want. As a random example, consider this:


(defcustom pulse-flag (pulse-available-p)
  "Whether to use pulsing for momentary highlighting.
Pulsing involves a bright highlight that slowly shifts to the
background color.

If the value is nil, highlight with an unchanging color until a
key is pressed.
If the value is `never', do no coloring at all.
Any other value means to do the default pulsing behavior.

If `pulse-flag' is non-nil, but `pulse-available-p' is nil, then
this flag is ignored."
  :group 'pulse
  :type 'boolean)


Now, this is type boolean. So we can do this..


(customize-set-value 'pulse-flag nil)

and all is good. We can also do this...

(customize-set-value 'pulse-flag "wrong")

Now we have pulse-flag set to an illegal value. Of course, in this case,
it won't matter because "wrong" will be interpreted as t. But it means I
can set the variable to something which the GUI will not. I want this to
throw an error.

In this case, the ability to set an "illegal" value is actually useful,
because the :type is wrong, as legal values are t, nil or 'never
(according to the documentation) not just 'boolean. 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. 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.

Phil



reply via email to

[Prev in Thread] Current Thread [Next in Thread]