all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Pascal J. Bourguignon" <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to customize an option to a dynamic value (computed by lisp form)
Date: Wed, 24 Aug 2016 19:50:00 +0200	[thread overview]
Message-ID: <87k2f69hvb.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: CAJR3QncuRLcqhk0Ga_0YxeES=-K_01QZV3-zGHambvPQO+vpjA@mail.gmail.com

Jorge <jorge13515@gmail.com> writes:

> Hi.  I set three options to a dynamic value, using the value of the option
> `org-directory'.  Now my custom-set-variables call in init.el includes the
> following:
>
>    '(org-agenda-files
>      (list
>       (concat org-directory "/agenda/")
>       "~/Dropbox/wanessa_e_jorge/administração_clínica/derma-prime.org"))
>    [...]
>    '(org-icalendar-combined-agenda-file (concat org-directory "/org.ics"))
>    [...]
>    '(org-mobile-inbox-for-pull (concat org-directory "/agenda/from-mobile.org"))
>
> The problem is that when I try to customize one of these three options, the
> customize buffer does not know that the value was computed dynamically.  For
> example, the customize buffer for org-mobile-inbox-for-pull shows the value as
> simply "~/org/agenda/from-mobile.org".  This means that if I edit the value to
> "~/org/agenda/from-mobile42.org" and save the customization, it will be written
> to init.el as a string literal, no longer respecting org-directory.  Then if I
> later change org-directory I will have problems.
>
> Previously I worked around this problem by setting these options manually
> (editing org-init.el, which is called by init.el), but I think the ideal would
> be to use customize, so I decided to ask here.  I have already searched Google
> and the list archives.
>
> Thank you for your attention.


Since the customization system updates the source form
customize-variables in your init file (actually, in the file indicated by
the custom-file customization variable), and when it saves this source
form, it saves the values of the variables, not the dynamic expressions
you would use to compute them, you won't have much choice if you want to
keep it simple.

Just set the customization variables to your expressions after the
customize-variables form.


Of course, you can alway extend the customization system to take an optional
expression (to be evaluated in what environment?) for each customization
variable, and to generate the customize-variables form using those
expressions instead of the customization variables values.

Is it worth the trouble?
Customization variables are designed for people who can't type a lisp
expression.
As a lisper it's easier to just set the variables yourself.

-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk




  reply	other threads:[~2016-08-24 17:50 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 [this message]
2016-08-25 17:55   ` Jorge
2016-08-25 20:54     ` Drew Adams
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=87k2f69hvb.fsf@kuiper.lan.informatimago.com \
    --to=pjb@informatimago.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.