Subject: Re: bug#60712: 28.2; customize-set-variable won't let you change the type of a choice

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

Mauro Aranda <[email-masked]> writes:

 > We have this condition in widget-choice-prompt-value:
 > ((and (= (length args) 2)
 >       (memq old args))
 >  (if (eq old (nth 0 args))
 >      (nth 1 args)
 >    (nth 0 args)))
 >
 > ARGS holds the choices available in the choice widget and OLD has
 > the choice that matches the current value of the choice widget, before
 > the user enters a new one.  This branch has been in the code since like
 > forever, but I can't explain why it's good to have it.

So, we should respect the value of widget-choice-toggle also when
prompting, of course.  I attach a patch to fix it.

From 1c96c56d62d9535d50fab66bb7b917bd56e823a3 Mon Sep 17 00:00:00 2001
From: Mauro Aranda <[email-masked]>
Date: Sun, 16 Jul 2023 09:22:11 -0300
Subject: [PATCH] Don't always toggle a choice when prompting

* lisp/wid-edit.el (widget-choice-prompt-value): Respect the value
of widget-choice-toggle.  (Bug#60712)
---
 lisp/wid-edit.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 234f3d9b74d..96dff69e2df 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -3985,7 +3985,8 @@ widget-choice-prompt-value
 		 nil)
 		((= (length args) 1)
 		 (nth 0 args))
-		((and (= (length args) 2)
+                ((and widget-choice-toggle
+                      (= (length args) 2)
 		      (memq old args))
 		 (if (eq old (nth 0 args))
 		     (nth 1 args)
-- 
2.34.1