From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mauro Aranda Newsgroups: gmane.emacs.bugs Subject: bug#60712: 28.2; customize-set-variable won't let you change the type of a choice Date: Sun, 16 Jul 2023 09:18:54 -0300 Message-ID: <8d7ea0a1-0847-3643-fa8e-7bfe1e066706@gmail.com> References: <87zgaq2sy5.fsf@penguin> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3457"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: 60712@debbugs.gnu.org To: Omar =?UTF-8?Q?Antol=C3=ADn?= Camarena Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 16 14:20:17 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qL0jZ-0000lV-3L for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Jul 2023 14:20:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qL0jL-0004iC-WA; Sun, 16 Jul 2023 08:20:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qL0jK-0004hl-58 for bug-gnu-emacs@gnu.org; Sun, 16 Jul 2023 08:20:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qL0jJ-0001Iv-Rr for bug-gnu-emacs@gnu.org; Sun, 16 Jul 2023 08:20:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qL0jJ-0000qX-NA for bug-gnu-emacs@gnu.org; Sun, 16 Jul 2023 08:20:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87zgaq2sy5.fsf@penguin> Resent-From: Mauro Aranda Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 Jul 2023 12:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60712 X-GNU-PR-Package: emacs Original-Received: via spool by 60712-submit@debbugs.gnu.org id=B60712.16895099573174 (code B ref 60712); Sun, 16 Jul 2023 12:20:01 +0000 Original-Received: (at 60712) by debbugs.gnu.org; 16 Jul 2023 12:19:17 +0000 Original-Received: from localhost ([127.0.0.1]:47001 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qL0ia-0000p8-VS for submit@debbugs.gnu.org; Sun, 16 Jul 2023 08:19:17 -0400 Original-Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]:54581) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qL0iX-0000oo-Ei for 60712@debbugs.gnu.org; Sun, 16 Jul 2023 08:19:15 -0400 Original-Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3a43cbb4343so1283496b6e.1 for <60712@debbugs.gnu.org>; Sun, 16 Jul 2023 05:19:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689509947; x=1692101947; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=s7ss6U1BiZuZy96C9wclEFZla5Az5Bh6g7i62SJyU7M=; b=Hn4KHDtJb2ao/s8Wp5mvPc4sShQ74KTJAm6rl1nMoYd3DJcsSqlfSrzRQ3Gh5G1RRo w15BU66cGrh2DzgjB0UauUxyZCZrw+C+taTGw39P8JhJrC+Otn4vjdUPcNyeGafT8CUC e+L6xPQdzjkarBBB4p+EdhaB8Gu50wxAnoHE8MTu5Kf7tHiErwcoJ58lcnUyJRdYs3y+ gJsvbKvXR77EkZfQPhiAu1FL+NkBWddXPV2HQR8y8CXhDLmFF9AwysaPWPg2fOhybM5p m8Qh/RNGkl2J7OMqVWdL27CQeF1zuMaaY1UF5A7+RE5N6s/qAit4sn7DMm8qQvwEipHn +WRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689509947; x=1692101947; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=s7ss6U1BiZuZy96C9wclEFZla5Az5Bh6g7i62SJyU7M=; b=E3+aPMdLnJTtvdJmeTy/0LoXO5fDg6q9kG0BEwACt1vSx8qxfjNfnPf5UGnKlvH99M G6zjPNfx4qBdHj66h93SQwvNO8hjOx452onZp4ChaZIQekougHSe3/NEbzhjwIwTJnhR 3KQpwdqHWmd4VOmlRqTS95KzzhEjpYRGphlaHyvFyjQwAs59+k/u8lCvuTLSTsITtmPA MWaSyJqsVbqyolFEBmSPcUsRNPPAKzypBKPLoFBhFbVIXCpGkxbp+5LixnCd2CtpQKn6 7kiVaFOVRYjLSClW1Kk0BZTDNYkIdJbmC2+k2mAqsf9ynpb3F5sLGnTnb8g9ePRXQvdf M4BA== X-Gm-Message-State: ABy/qLZC4MxPeY4e8XnEmtJMIFGVLtM2+9bzAOb7yIGg16TIZVI4vWqP 7Ih+2vXcS6RhV8p1mdP5eI4= X-Google-Smtp-Source: APBJJlGCyqtzWWWSvgNQFOzujtqktYedzwbjQQ4xfLjEAMEpugkSFeJjcraqeTKVqMFfvj4adsSLoA== X-Received: by 2002:a54:4d93:0:b0:3a3:33e9:9a34 with SMTP id y19-20020a544d93000000b003a333e99a34mr7341901oix.55.1689509947406; Sun, 16 Jul 2023 05:19:07 -0700 (PDT) Original-Received: from [192.168.0.234] ([186.127.128.249]) by smtp.gmail.com with ESMTPSA id m25-20020a9d7e99000000b006b89596bc61sm5597070otp.61.2023.07.16.05.19.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 16 Jul 2023 05:19:06 -0700 (PDT) Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:265324 Archived-At: Omar Antolín Camarena writes: > If you declare a user option as follows: > > (defcustom bool-or-alist '((a . 4) (b . 7)) >   "A made up option to illustrate a problem." >   :type '(choice boolean (alist :key-type symbol :value-type integer))) > > And then run M-x customize-set-variable to change the value to t the > change fails with the message: > > widget-prompt-value: Value does not match alist type I didn't manage to reproduce it with this recipe.  What I had to do was, after emacs -Q: (defcustom bool-or-alist '((a . 4) (b . 7))   "A made up option to illustrate a problem."   :type '(choice boolean (alist :key-type symbol :value-type integer))) M-x customize-set-variable RET bool-or-alist I get a prompt: [boolean] [choice] Set customized value for bool-or-ailst to true: If I answer y or n, there's no problem, bool-or-alist will be t or nil. M-x customize-set-variable RET bool-or-alist New prompt: [alist] [choice] Set customized value for bool-or-alist to: Here if you answer t, you get the message: widget-prompt-value: Value does not match alist type Which is not surprising, since t is not an alist and the prompt says its expecting an alist. What's surprising is that the prompt is choosing one of the two options beforehand.  I mean, going back to the original definition and re-evaluating, say that I want to use customize-set-variable to change the alist.  I can't do that right away: I have to set it to t or nil, and then execute customize-set-variable again to set it to an alist. Not good. > I think the problem is that widget-choice-prompt-value figures which > branch of the choice the variable currenty has and then expects the new > type to be the same. > If you tag everything, then customize-set-variable works just fine: > > (defcustom bool-or-alist '((a . 4) (b . 7)) >   "A made up option to illustrate a problem." >   :type '(choice (const :tag "Yes" t) >                  (const :tag "No" nil) >                  (alist :tag "An alist" >                         :key-type symbol :value-type integer))) > Yes, but it's not because of the tags.  It's just that previously the choice widget had two choice, and now it has three, and since there's at least two options to pick (excluding the current), widget-choice-prompt-value won't choose for you one of the options beforehand. 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.