all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

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.