all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Jorge <jorge13515@gmail.com>,
	"Pascal J. Bourguignon" <pjb@informatimago.com>
Cc: help-gnu-emacs@gnu.org
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)	[thread overview]
Message-ID: <83832586-765e-4df4-917a-98458247d829@default> (raw)
In-Reply-To: <CAJR3QneOs2digjSU2MQ4-MAwUnCeQRq5AxkCrHvhkCU+DFzkwg@mail.gmail.com>

> 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	other threads:[~2016-08-25 20:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-23 20:26 How to customize an option to a dynamic value (computed by lisp form) Jorge
2016-08-24 17:50 ` Pascal J. Bourguignon
2016-08-25 17:55   ` Jorge
2016-08-25 20:54     ` Drew Adams [this message]
2016-08-26 12:54       ` Jorge
2016-08-26 13:26         ` Jorge
2016-08-26 14:28         ` Drew Adams
2016-08-26 19:02           ` Jorge
2016-08-26 20:18             ` Jorge
2016-08-26 20:59             ` Drew Adams
2016-08-27 11:50               ` tomas
2016-08-30 20:42               ` Jorge

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83832586-765e-4df4-917a-98458247d829@default \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=jorge13515@gmail.com \
    --cc=pjb@informatimago.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.