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

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 19 Aug 2023 08:35:02 +0000

Your bug report

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

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
63290: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63290
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#63290: 30.0.50; Customize UI shows extra fields for (choice (const ...) (alist ...))
From: Eli Zaretskii <[email-masked]>
To: Mauro Aranda <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Sat, 19 Aug 2023 11:34:24 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Cc: [email-masked]
> Date: Tue, 15 Aug 2023 19:46:35 -0300
> From: Mauro Aranda <[email-masked]>
> 
> So, in case the :value is missing for the alist widget, we want to
> compute the default-value with the :options, and without including the
> editable-list.
> 
> Hopefully the attached patch is 100% correct now.  I did try it with
> excorporate-configuration and I think it works OK, but please give it
> yourself a try.  And thank you for your patience.

Thanks, I've now installed this on the master branch, and I'm closing
the bug.

Subject: 30.0.50; Customize UI shows extra fields for (choice (const ...) (alist ...))
From: Thomas Fitzsimmons <[email-masked]>
To: [email-masked]
Date: Fri, 05 May 2023 02:02:53 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

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.

I noticed this on excorporate-configuration, which has:

(defcustom test-custom nil "" :type
  '(choice (const :tag "auto" nil)
           (alist
	    :key-type (string :tag "key")
	    :value-type (string :tag "value"))))

but where the alist is a large nested structure.  If the user
customizes, test-custom, selects the alist, and saves, the structure has
degenerate ("" . ""), or (nil . nil) entries in it.  To avoid this, the
user would have to hit "DEL" on the empty key/value entries, which is
not ideal.

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.

Thomas