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#23975: 25.0.94: defcustom error message is wrong when :type field has a :match attribute Date: Fri, 4 Sep 2020 08:28:03 -0300 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000002f359705ae7b2ac9" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21757"; mail-complaints-to="usenet@ciao.gmane.io" Cc: rswgnu@gmail.com, 23975@debbugs.gnu.org, Robert Weiner To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 04 13:29:10 2020 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 1kE9u2-0005WM-7r for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 04 Sep 2020 13:29:10 +0200 Original-Received: from localhost ([::1]:53766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kE9u1-0004rH-BC for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 04 Sep 2020 07:29:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kE9tu-0004r5-9W for bug-gnu-emacs@gnu.org; Fri, 04 Sep 2020 07:29:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54298) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kE9tt-0003TM-P2 for bug-gnu-emacs@gnu.org; Fri, 04 Sep 2020 07:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kE9tt-0004Ew-LM for bug-gnu-emacs@gnu.org; Fri, 04 Sep 2020 07:29:01 -0400 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: Fri, 04 Sep 2020 11:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23975 X-GNU-PR-Package: emacs Original-Received: via spool by 23975-submit@debbugs.gnu.org id=B23975.159921890316251 (code B ref 23975); Fri, 04 Sep 2020 11:29:01 +0000 Original-Received: (at 23975) by debbugs.gnu.org; 4 Sep 2020 11:28:23 +0000 Original-Received: from localhost ([127.0.0.1]:37611 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kE9tH-0004E0-H9 for submit@debbugs.gnu.org; Fri, 04 Sep 2020 07:28:23 -0400 Original-Received: from mail-wm1-f50.google.com ([209.85.128.50]:52600) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kE9tF-0004Dn-Ds for 23975@debbugs.gnu.org; Fri, 04 Sep 2020 07:28:21 -0400 Original-Received: by mail-wm1-f50.google.com with SMTP id q9so5747778wmj.2 for <23975@debbugs.gnu.org>; Fri, 04 Sep 2020 04:28:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=1c2xtjj4sZE4SqVjeUOsC9DBkv8enz0WdJ8LJAO4A1E=; b=OTtj0QjgK5OKSWRd4Q8PmBiml9gLHENnKjAFOgFJfs/ljH4zDlrhrDZ9/DxRHD1IDv zQwF59Yz4OEjipduV2gUiYkA33vdlvi0/3MFZKJ/lqZ10xD1mQQoxSJou3GirrJamr6L eEmXrxAea015QOn6TlAEWSH6+IP4o2AY2WpuMcfsbvfmp5/y+K89Tv0aTysiEY1weAH2 jEKZhP1IiYXsDkikWVNR8SEDbxn1vRi2wLCZHEHVPBbFjiRTuu0LFQV6DCOjIWrb2/D8 Jodt1gCQby9kV0cCg51btOzsmhQxvpQfE2EBq9SGj04A/x62dn1bGm5+NoQmrMOhsIzh WGjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=1c2xtjj4sZE4SqVjeUOsC9DBkv8enz0WdJ8LJAO4A1E=; b=d2ZwXKdWnNhPUidM6L0aQ3FFvyCwy6zOC3VnfDeuNQ8ttTVC5s/5PbNVIo5ATxaSRh WO1WrzroMixZ28Dk6kHPjCrGbijpr5bjQT/DLET6Js/vAnPCWc5rqAavctNs7mRveYIg a8gB+eFywetCPpTPx60ESIZkFhYEhvEb4zlWyu0Lg+mahBhhLrKq4+R1MeMx52n602v8 yfX9pClCv9BqxsxpPuolbdZyluk1Dev9hd8kc5RnV2q/IukSG1AUTzCe/mb5LXXHuWgN V5t2ws+637PK9woEYBitqvohNynnzQqOSHnw6gUU6YdZ0hEnbxNcs792HjW6Oj47Z/38 fiuQ== X-Gm-Message-State: AOAM532sTlCtl7l1wJa579e4n0Gnyb1D/G7Ko6mp7EtG+jS8Nx5VII/C VUqICd5OdhdJJY2VcqkVWGV8ZDJCgeDeQ2Kwjv8= X-Google-Smtp-Source: ABdhPJwt5E0c6x5AMWWuKUP80E097qbzHJyuEYE4SAoSxoQo37k1t/oSL/Gwef4zcVQByfF/nWY9vuDeAlOu0i/rWjY= X-Received: by 2002:a1c:a9c2:: with SMTP id s185mr7365004wme.100.1599218895499; Fri, 04 Sep 2020 04:28:15 -0700 (PDT) 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" Xref: news.gmane.io gmane.emacs.bugs:187103 Archived-At: --0000000000002f359705ae7b2ac9 Content-Type: text/plain; charset="UTF-8" Lars Ingebrigtsen writes: > As for the error message, we can't really fix that trivially either, > because you may have said :match widget-restricted-sexp-match or the > like, and then the error message is correct. It sounds unlikely, > though, and we could add a hack that says that if :match is > widget-restricted-sexp-match, then we don't output the standard error > message but instead what's actually in :match, but that's... hacky? > > But possible. Anybody have an opinion? I wonder if we could just document the :type-error property. So anybody that uses a custom :match function with additional checks can put there the information they like to show the user when something goes wrong. So the defcustom posted would be something like: (defcustom bounded-num 999 "Positive, bounded number" :type '(integer :match (lambda (widget value) (and (integerp value) (> value 0) (< value 1000))) :type-error "Value should be an integer between 0 and 1000")) That's easy, and would solve the main problem here. WDYT? --0000000000002f359705ae7b2ac9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Lars Ingebrigtsen <la= rsi@gnus.org> writes:

> As for the error message, we can&#= 39;t really fix that trivially either,
> because you may have said :m= atch widget-restricted-sexp-match or the
> like, and then the error m= essage is correct.=C2=A0 It sounds unlikely,
> though, and we could a= dd a hack that says that if :match is
> widget-restricted-sexp-match,= then we don't output the standard error
> message but instead wh= at's actually in :match, but that's... =C2=A0hacky?
>
>= But possible.=C2=A0 Anybody have an opinion?

I wonder if we could j= ust document the :type-error property.=C2=A0 So
anybody that uses a cust= om :match function with additional checks can
put there the information = they like to show the user when something goes
wrong.=C2=A0 So the = defcustom posted would be something like:

(defcust= om bounded-num 999
=C2=A0 "Positive, bounded number"
=C2=A0= :type '(integer :match (lambda (widget value) (and (integerp value)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (> value 0)=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 (&= lt; value 1000)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :type-error "Value should be an intege= r between 0 and 1000"))

That's easy, and w= ould solve the main problem here.=C2=A0 WDYT?
--0000000000002f359705ae7b2ac9--