unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Make a defcustom dependent on another variable
@ 2014-03-19 23:05 Joost Kremers
  2014-03-20  8:17 ` Thien-Thi Nguyen
  0 siblings, 1 reply; 3+ messages in thread
From: Joost Kremers @ 2014-03-19 23:05 UTC (permalink / raw)
  To: help-gnu-emacs

Hi all,

Defining a custom variable that can have one of (e.g.,) two values is
easy:

(defcustom some-option 'value1
  "Doc string"
  :group 'some-group
  :type '(choice (const value1)
                 (const value2)))

However, what if the possible values `some-option' can take are defined
in another variable? Is it ok to do something like the following:

(defcustom some-option 'value1
  "Doc string"
  :group 'some-group
  :type '(choice ,@(mapcar #'(lambda (x) `(const ,x))
                           some-option-list)))

where `some-option-list' is a variable holding a list of possible values
for `some-option'.

The code seems to work (the resulting customisation option works), but I
was wondering a) if there are any hidden problems I'm not aware of; and
b) if there is a more canonical way of doing this.

TIA

Joost



-- 
Joost Kremers                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-20 12:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-19 23:05 Make a defcustom dependent on another variable Joost Kremers
2014-03-20  8:17 ` Thien-Thi Nguyen
2014-03-20 12:19   ` Stefan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).