How to properly write the default value for a non-trivial defcustom
form in standard
for something like I have below: a list of 3-element lists, with choices of the types?
The defcustom
form is: defcustom option standard doc [keyword value]...
The following defcustom
works fine as long as: it's default is nil.
- it's default is nil
- it's a list of one or several elements of the first type
It fails with a "mismatch" warning in the customize buffer asAs soon as the default isI add a non-empty list of heterogeneous typesvalues in (e.g. one element is fromstandard
for the second or third choicedefault value, Emacs *Customize*
buffer UI fails (see below).
#1: My defcustom form: (with a nil
value for the default, itEmacs *Customize*
buffer UI works fine):
If, instead of nil
as the defaultThe problem occurs when I writespecify a list with several items of different types, the customization menu fails with a mismatch and does not to properly show the widgets to enter new entries. If the list contains elements of the first type, it's fine.
#2: My defcustom form: (same code, but with an explicitor just one for default that works fine: a list of elements of the first choice, as shown below:
(defcustom pel-key-chords
'((global "<>" ("<>\C-b"))
(global "[]" ("[]\C-b"))
(c++-mode "{}" ("{\n\n}\C-p")))
"..."
...
#3#2: My defcustom form: (same code, but with an explicit default that fails with a mismatch: a list of 3 elements of the first choice, then 1one element of the second choice):
(defcustom pel-key-chords
'((global "<>" ("<>\C-b"))
(global "[]" ("[]\C-b"))
(c++-mode "{}" ("{\n\n}\C-p"))
(global ".;" pel-search-word-from-top))
"..."
...
Interesting note: Additions of second and/or third type elements via the customize buffer while With the default has accepted data (as in #2 above), are accepted, saved to the custom-set-variables form properly and restored properly back in the customizeEmacs *Customize*
buffer!
This is a copy/paste of the content of the relevant portion of my custom-set-variables form after manually adding UI fails: the last list element (global ".;" pel-search-word-from-top)INS
via the customize buffer and then saved it gives:
'(pel-key-chords
(quote
((global "<>"
("<>^B"))
(global "[]"
("[]^B"))
(c-mode "{}"
("{
}^P"))
(c++-mode "{}"
("{
}^P"))
(global ".;" pel-search-word-from-top))))
I can then readDEL
buttons are not available and it back without any mismatch. If I tryis impossible to put this inside the default I get the mismatch warning..add or delete elements.
I read Emacs Lisp Customization Settings section and some code like the dump-jump.el
code that defines some complex data with initialization. I assume I must identify some keywords in my declaration of the default, but for some reason I can't find the proper syntax for initializing the data I defined above.
Any help is appreciated. Thanks :-)