emacs-devel
[Top][All Lists]
Advanced

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

Re: custom: how do I augment an option?


From: Stefan Monnier
Subject: Re: custom: how do I augment an option?
Date: Fri, 26 Oct 2012 14:21:56 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

> If I want to _modify_ a custom variable, I have to resort to something like
> --8<---------------cut here---------------start------------->8---
> (custom-set-variables
>  '(message-syntax-checks
>    (cl-adjoin '(long-lines . disabled)
>     (eval (car (get 'message-syntax-checks 'standard-value)))
>     :test 'equal)))
> --8<---------------cut here---------------end--------------->8---
> which uses a CL function _and_ also eval.

While `adjoin' is frowned upon, using `cl-adjoin' is accepted.

> How about changing `custom-set-variables' to accept
> (SYMBOL EXP [NOW [REQUEST [COMMENT [SETTER]]]])
> instead of
> (SYMBOL EXP [NOW [REQUEST [COMMENT]]])
> where SETTER would be a function acceptable as the :set argument to
> defcustom.

That doesn't sound good to me.  A `setter' is the function that takes
the value of EXP and "puts it at the right place" (possibly changing it
to another representation along the way).  That sounds quite different
from what you want.

> Also, semi-independently, I propose a function
> (defun custom-standard-value (symbol)
>   "Return the standard value of the customizable option."
>   (eval (car (get symbol 'standard-value))))

That sounds OK.  Tho, since Custom also manages faces, it would make
sense to give it a name that includes "variable".  Sadly,
custom-variable-standard-value is already taken for "the same thing but
without `eval' and `car'".
OTOH, there's only one use of custom-variable-standard-value currently,
and we can hope that it's not used outside, so it might be OK to
change that use and hijack the name for your above function (post 24.3,
obviously).


        Stefan



reply via email to

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