Skip to main content
6 of 7
Restored the flavour of the first post & the title
PRouleau
  • 841
  • 5
  • 10

How to properly specify defcustom default list of non-trivial data types?

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.

As soon as I add a non-empty list of values in standard for the default value, Emacs *Customize* buffer UI fails (see below).

#1: My defcustom form: (with a nil value for the default, Emacs *Customize* buffer UI works fine):

(defcustom pel-key-chords nil
"..."
:group 'pel-pkg-for-key-chord
  :type '(repeat
          (choice
           (list
            :tag "expansion-keys"
            (symbol       :tag "mode           " :value global)
            (string       :tag "the 2 keys     ")
            (repeat
             (key-sequence :tag "key")))
           (list
            :tag "command"
            (symbol       :tag "mode           " :value global)
            (string       :tag "the 2 keys     ")
            (function     :tag "command        "))
           (list
            :tag "lambda"
            (symbol       :tag "mode           " :value global)
            (string       :tag "the 2 keys     ")
            (function     :tag "elisp code     "
                          :value (lambda () (interactive) <YOUR CODE HERE>))))))

The problem occurs when I specify a list of elements, or just one for default, as shown below:

#2: My defcustom form: (same code, but with an explicit default of one element):

(defcustom pel-key-chords
'((global   "<>"  "<>\C-b"))
"..."
...

With the default, Emacs *Customize* buffer UI fails: the INS and DEL buttons are not available and it is impossible to 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 :-)

PRouleau
  • 841
  • 5
  • 10