Skip to main content
deleted 38 characters in body
Source Link
Drew
  • 79.1k
  • 10
  • 123
  • 257

Any help is appreciated. Thanks :-)

Any help is appreciated. Thanks :-)

Restored the flavour of the first post & the title
Source Link
PRouleau
  • 841
  • 5
  • 10

How to properly specify defcustom default list of heterogeneousnon-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.

  • 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 :-)

How to properly specify defcustom default list of heterogeneous types?

How to properly write the default value for a non-trivial defcustom form for something like I have below: a list of 3-element lists, with choices of the types?

The following defcustom works fine as long as:

  • 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 as soon as the default is a list of heterogeneous types (e.g. one element is from the second or third choice).

#1: My defcustom form: (with a nil default, it works fine)

If, instead of nil as the default I write 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 explicit default that works fine: a list of elements of the first choice:

(defcustom pel-key-chords 
'((global   "<>"  ("<>\C-b"))
  (global   "[]"  ("[]\C-b"))
  (c++-mode "{}"  ("{\n\n}\C-p")))
"..."
...

#3: 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 1 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 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 customize buffer!

This is a copy/paste of the content of the relevant portion of my custom-set-variables form after manually adding the last list element (global ".;" pel-search-word-from-top) 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 read it back without any mismatch. If I try to put this inside the default I get the mismatch warning...

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.

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):

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 :-)

deleted 7 characters in body
Source Link
PRouleau
  • 841
  • 5
  • 10

If, instead of nil as the default I write a list with just one entryseveral items of different types, the customization menu fails with a mismatch and does not to properly show the widgets to enter new entries. For example if the first lines ofIf the above code are replaced bylist contains elements of the followingfirst type, I'm not able to enter new values:it's fine.

If, instead of nil as the default I write a list with just one entry, the customization menu fails to properly show the widgets to enter new entries. For example if the first lines of the above code are replaced by the following, I'm not able to enter new values:

If, instead of nil as the default I write 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.

added 1358 characters in body
Source Link
PRouleau
  • 841
  • 5
  • 10
Loading
added 401 characters in body; edited title
Source Link
PRouleau
  • 841
  • 5
  • 10
Loading
deleted 26 characters in body
Source Link
Drew
  • 79.1k
  • 10
  • 123
  • 257
Loading
Source Link
PRouleau
  • 841
  • 5
  • 10
Loading