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#59937: 28.2; Bad defcustom behavior Date: Sat, 10 Dec 2022 07:05:11 -0300 Message-ID: References: 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="12695"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Cc: 59937@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 10 11:06:17 2022 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 1p3wkK-00034M-DU for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 10 Dec 2022 11:06:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p3wk8-00082F-S6; Sat, 10 Dec 2022 05:06:04 -0500 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 1p3wk6-00081w-On for bug-gnu-emacs@gnu.org; Sat, 10 Dec 2022 05:06:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p3wk6-0006qB-3Q for bug-gnu-emacs@gnu.org; Sat, 10 Dec 2022 05:06:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p3wk5-0003Kq-Tp for bug-gnu-emacs@gnu.org; Sat, 10 Dec 2022 05:06:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Mauro Aranda Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Dec 2022 10:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59937 X-GNU-PR-Package: emacs Original-Received: via spool by 59937-submit@debbugs.gnu.org id=B59937.167066672712801 (code B ref 59937); Sat, 10 Dec 2022 10:06:01 +0000 Original-Received: (at 59937) by debbugs.gnu.org; 10 Dec 2022 10:05:27 +0000 Original-Received: from localhost ([127.0.0.1]:41859 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3wjW-0003KP-IY for submit@debbugs.gnu.org; Sat, 10 Dec 2022 05:05:27 -0500 Original-Received: from mail-oa1-f52.google.com ([209.85.160.52]:44664) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3wjU-0003KH-64 for 59937@debbugs.gnu.org; Sat, 10 Dec 2022 05:05:25 -0500 Original-Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-1447c7aa004so2662625fac.11 for <59937@debbugs.gnu.org>; Sat, 10 Dec 2022 02:05:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=iPS2xVZNASXbI7cCnqgcgnBEwx2siSfUfKj2hvC0Se8=; b=mfDe/m+W1CtwB0hZVIPRV/G8Ez2P1PGfRIkub2byRGeBI1aBSVbb4n/1vuX1Xu0RBY aMHrDb4ZzpAzgkNL1/p70nDt4NX6UIrnEN3jqiRT06Rp3vUpBz9T/ZaPhkWva3kJ5y4N Ihr3MB1rghHjXdKjSfLbBrT0JxInkdosZ/3HryMYLEDbPXYhpDO4HaGME1Z/JlfjU8fx Q2L6S4lM7QdmS0jWlI7MFek+gsL1uMvCBqnQtx/abgtR2D+FreEAehRfdduTF15KeMXh IuUIatzJD3a0OjWDaVmXvvMNJjFYPEo+u04yyafXR7lVMqZ4IFdSmn5guaYPsLfw7QEJ OuAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=iPS2xVZNASXbI7cCnqgcgnBEwx2siSfUfKj2hvC0Se8=; b=BPQrXUbl2IOTfmE2tdwE8gYq0m7anB07sxahjcyeNLMNZHWZf/sjg1deNYGNNO0rNB 7xP8c69EmJBXTUMll8Dd+BAFvHVQcc9mdRv0WtsXOnmDIr36O1OfqpEW4mMkJh/ntdbe ZM7FlknkK/5cSOIVSZIKRWV4FT8+gjd7lUZNFOG6sJTgSz4WNnorOLuBW9Ev/YQ4HbIF 6D7HzfU/ixpvSktmUtfKdC39gPapUzW8SgGRN5ujt+//l8nPvAbSvAR+ekJKlEiwJvWD 9rc6Jqg5TAbj9pxW4f83MK2l8md3KyzfYHz8oyyLu8ecz/TZUJCxAyQ+66Aq3fiAJu4+ Zaiw== X-Gm-Message-State: ANoB5pmj7jERLzQUn+mqCXMjK8lJc5hib1MTmMZMreG+Cl9n45gxOPFy OWM80W8PDDRVVvkp+UfWf9mbNF6/ooY= X-Google-Smtp-Source: AA0mqf5kSrTOSopRGR/1QJU5gDbCEL0+zkXGVBS2Cr++/LJ79V3ovExS559wpq6uefus66jneoOiLA== X-Received: by 2002:a05:6870:b08:b0:144:79b0:a2e3 with SMTP id lh8-20020a0568700b0800b0014479b0a2e3mr4727759oab.30.1670666718380; Sat, 10 Dec 2022 02:05:18 -0800 (PST) Original-Received: from [192.168.0.234] ([181.228.28.240]) by smtp.gmail.com with ESMTPSA id q18-20020a4a3012000000b004a382acad85sm1368076oof.15.2022.12.10.02.05.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 10 Dec 2022 02:05:16 -0800 (PST) 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:250500 Archived-At: Drew Adams writes: > These first four defcustoms behave as I expect. > > The first has a default value of nil - empty alist.  The second has a > default value of (("key1" :x ("a" "b") ("q"))).  The third had a default > value of (("key1" :x () :w ("q"))) - one of the plist-entry values is > empty.  The fourth has a default value of (("key1")) - empty plist. > > The option should be an alist with elements that have a string key and a > plist value.  Each plist element has a keyword key and a list of string > values.  The alist can be empty, any plist can be empty, and any > plist-entry value can be empty. > > ;; OK > (defcustom myvar () >   "..." >   :group 'emacs >   :type '(alist :key-type (string :tag "Alist key (string):") >             :value-type >         (plist :key-type symbol >                        :options (:x :y :z) >                        :value-type (repeat string)))) > > ;; OK > (defcustom myvar '(("key1" :x ("a" "b") :w ("q"))) >   "..." >   :group 'emacs >   :type '(alist :key-type (string :tag "Alist key (string):") >             :value-type >         (plist :key-type >                        (restricted-sexp :match-alternatives (keywordp) >                                         :tag "Plist key (keyword)") >                        :options (:x :y :z) >                        :value-type (repeat string)))) > > ;; OK > (defcustom myvar '(("key1" :x () :w ("q"))) >   "..." >   :group 'emacs >   :type '(alist :key-type (string :tag "Alist key (string):") >             :value-type >         (plist :key-type >                        (restricted-sexp :match-alternatives (keywordp) >                                         :tag "Plist key (keyword)") >                        :options (:x :y :z) >                        :value-type (repeat string)))) > > ;; OK > (defcustom myvar '(("key1")) >   "..." >   :group 'emacs >   :type '(alist :key-type (string :tag "Alist key (string):") >             :value-type >         (plist :key-type >                        (restricted-sexp :match-alternatives (keywordp) >                                         :tag "Plist key (keyword)") >                        :options (:x :y :z) >                        :value-type (repeat string)))) > > The first OK example specifies the type of the plist key as just symbol, > not as keywordp.  But I want to constrain it to be a symbol that's a > keyword.  The problem occurs when I try to do that AND I use a default > value of nil (see next). The moment you add a match alternative that won't match the default value of a restricted-sexp widget (which is nil), then you should change the default value for the restricted-sexp widget. > This one is no good - that's the bug: > > ;; When click initial INS get prompted for a Lisp expression, get warnings, > ;; and Customize buffer contents are changed to just INS DEL while prompting. > ;; > (defcustom myvar () >   "..." >   :group 'emacs >   :type '(alist :key-type (string :tag "Alist key (string):") >             :value-type >         (plist :key-type >                        (restricted-sexp :match-alternatives (keywordp) >                                         :tag "Plist key (keyword)") >                        :options (:x :y :z) >                        :value-type (repeat string)))) > > In this case the default value is nil, but the defcustom also specifies > the type of plist values as keywordp.  I think this definition should > work fine. You're looking at a different default value.  The warning comes from Widget, and says that the default value for the restricted-sexp widget is not correct.  It's not talking about the default value for the user option. > But when you click the sole INS button at the outset you're > prompted for a Lisp expression and you simultaneously get a warning that > a plist key is not of the right type.  If you enter a Lisp expression > (e.g. just 42 or whatever) then the Customize buffer appears as it > should.  I think (1) you shouldn't be prompted for anything and (2) you > shouln't get any warning of anything. Examples 2-4 get the same warning once the user clicks the INS button. If you specify a valid default value for the restricted-sexp widget, then the warning is gone. See also bugs #15689, #25152.