Subject: Re: bug#63290: 30.0.50; Customize UI shows extra fields for (choice (const ...) (alist ...))

From: Mauro Aranda <[email-masked]>
Date: Sun, 16 Jul 2023 10:15:26 -0300

Thomas Fitzsimmons <[email-masked]> writes:

 > This test case shows the issue:
 >
 > (defcustom test-custom nil "" :type
 >   '(choice (alist
 >         :key-type (string :tag "key")
 >         :value-type (string :tag "value"))
 >            (const :tag "auto" nil)))
 > (customize-variable 'test-custom)
 >
 > The UI first shows:
 >
 > Hide Test Custom: Choice: Value Menu Alist:
 > INS
 >     State : STANDARD.
 >
 > Then if I choose "Value Menu", and option 1 to choose the "auto" const
 > value, I get:
 >
 > Hide Test Custom: Choice: Value Menu auto
 >     State : EDITED, shown value does not take effect until you set or 
save it.
 >
 > which is fine.  Then if I choose "Value Menu" again and choose 0 for the
 > Alist, I get:
 >
 > Hide Test Custom: Choice: Value Menu Alist:
 > INS DEL key:
 >             value:
 > INS
 >     State : EDITED, shown value does not take effect until you set or 
save it.
 >
 > I wasn't expecting:
 >
 > INS DEL key:
 >             value:
 >
 > If I then save the customization, test-custom is ("" . "").  I think it
 > should instead be nil.
 >

Thanks for the bug report.

 >
 > It seems like after a const is shown, Customize considers the variable
 > "edited".  I don't know why it is adding those extra INS/DEL key/value
 > UI boxes though.

The code currently ignores the value if it's present but nil. That's
not good, obviously.  But it might be tricky to fix it because other
widgets depend on the code ignoring it...

I think it might be good to have a different property specify a default
value (defaulting to :value upon creation, if not provided), and let
:value be treated as of today, like the current value holder.