0

I would like to have a variable, say my-info that would have an alist attached to it. In normal programming it would look like this:

(setq my-info '((my-name . "Giuseppe Sextus-Packus") (my-email . "joep@packllc.com") (my-phone . "39.06.4434.0147")))

However, I want to populate my-info in a customization buffer, i.e., callable with customize-variable my-info. Furthermore, I would like each key to be presented with a blank field to fill in the value. I know I have to declare this variable as a defcustom but the details of offering all three keys for the user to complete with values is beyond my understanding. Are there templates out there for how to declare such a defcustom? How could I do this?

2

Something like this?

(defcustom foo-alist
  '((key-a "value-a1" "value-a2")
    (key-b "value-b1" "value-b2"))
  "Each element is a list comprising (KEY \"VALUE1\" \"VALUE2\") ..."
  :type '(alist :key-type (symbol :tag "Key")
                :value-type (list (string :tag "Value 1")
                                  (string :tag "Value 2")))
  :group 'foo)

Or in this particular case:

(defcustom my-info-alist
  '((my-name . "Giuseppe Sextus-Packus")
    (my-email . "joep@packllc.com")
    (my-phone . "39.06.4434.0147"))
  "Each element is a cons cell (KEY . \"VALUE1\") ..."
  :type '(alist :key-type (symbol :tag "Key")
                :value-type (string :tag "Value"))
  :group 'my-info)
  • I guess the second example would create the alist my-info-alist already populated with values for the keys. But is there a way to create the customization group my-info where the values were left to be filled in by the individual user? – 147pm Apr 21 at 14:27
  • You can just use empty strings as the default values, no? – phils Apr 21 at 22:44
  • Of course. Excellent. – 147pm Apr 22 at 0:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.