all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mauro Aranda <maurooaranda@gmail.com>
To: Drew Adams <drew.adams@oracle.com>
Cc: 59937@debbugs.gnu.org
Subject: bug#59937: 28.2; Bad defcustom behavior
Date: Sat, 10 Dec 2022 07:05:11 -0300	[thread overview]
Message-ID: <d4103635-337b-639a-4ecf-e1e6dffefa4c@gmail.com> (raw)
In-Reply-To: <SJ0PR10MB54882BEA866AC19E799D51FBF31F9@SJ0PR10MB5488.namprd10.prod.outlook.com>

Drew Adams <drew.adams@oracle.com> 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.






  reply	other threads:[~2022-12-10 10:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-10  5:06 bug#59937: 28.2; Bad defcustom behavior Drew Adams
2022-12-10 10:05 ` Mauro Aranda [this message]
2022-12-10 22:05   ` Drew Adams
2022-12-11 11:08     ` Mauro Aranda
2022-12-13 22:10       ` Drew Adams
2022-12-13 22:50         ` Mauro Aranda
2022-12-14  1:51           ` Drew Adams
2022-12-14 12:40             ` Mauro Aranda
2022-12-14 18:53               ` Drew Adams
2022-12-14 22:20                 ` Mauro Aranda
2022-12-14 22:42                   ` Drew Adams
2023-01-04 16:07                   ` Drew Adams
2023-01-04 22:31                     ` Mauro Aranda
2023-01-04 22:47                       ` Drew Adams
2023-07-16 23:00                         ` Mauro Aranda
2023-07-17 15:30                           ` Drew Adams
2023-07-17 16:21                             ` Mauro Aranda
2023-07-22 12:56                           ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d4103635-337b-639a-4ecf-e1e6dffefa4c@gmail.com \
    --to=maurooaranda@gmail.com \
    --cc=59937@debbugs.gnu.org \
    --cc=drew.adams@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.