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

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

RE: How to customize an option to a dynamic value (computed by lisp form


From: Drew Adams
Subject: RE: How to customize an option to a dynamic value (computed by lisp form)
Date: Thu, 25 Aug 2016 13:54:58 -0700 (PDT)

> There remain two problems:

> 1.  customize-set-variable does not do type checking.  I have just
> tested it by setting org-agenda-files to 42 (an integer).

This seems like a bug.  Even if it is by design, it seems like
something that should be improved (aka fixed).

But if you mean only interactively, then it _does_ do type-checking.

> set-variable does type checking, but does not respect any custom-set
> property.

`set-variable' does _not_ do type-checking either.

Perhaps you are thinking of the fact that _when used
interactively_ it checks the type.  (set-variable foo 42) does not.

I filed a bug long ago to make `set-variable' respect :set etc.
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6578

(The bug report never even got a reply, and was classed as "wishlist")

> How can I elegantly combine both?  And shouldn't elisp
> provide a convenient command for this?

Try to specify the behavior you want (more clearly).  Presumably
you are looking for a way, using Lisp (non-interactively), to set
an option value and get all of the behavior that you get when you
set it using the Customize UI (:set, :type, etc. control).

> 2.  If I forget that these options are changed manually (Emacs does
> not warn), and configure them via customize, then the new value will
> be added to the custom-set-variables form with static values.  This
> has two problems:
>       1. It will have static values.
>       2. Since org-init.el is called after the custom-set-variables
>          form, the values set in the form will be overwritten.

Again, please specify clearly the behavior you want and the behavior
you see instead.

A variable value is always "static", by definition of the word "value".
It's not clear (to me) just what you are looking for.

BTW, you can easily check whether an option has been changed outside
Customize, i.e., using something like `setq' and not something like
`customize-set-variable', by invoking code such as this (taken from
`customize-rogue', which lets you open Customize for all such options):

(defun rogue-option-p (symbol)
  (let ((cval  (or (get symbol 'customized-value)
                   (get symbol 'saved-value)
                   (get symbol 'standard-value))))
    (and cval                           ;Declared with defcustom.
         (default-boundp symbol)        ;Has a value.
         (not (equal (eval (car cval))
                     ;; Which does not match customize.
                     (default-value symbol))))))



reply via email to

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