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

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

Make a defcustom dependent on another variable


From: Joost Kremers
Subject: Make a defcustom dependent on another variable
Date: 19 Mar 2014 23:05:21 GMT
User-agent: slrn/pre1.0.0-18 (Linux)

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)


reply via email to

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