unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Mauro Aranda <maurooaranda@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 23975@debbugs.gnu.org, rswgnu@gmail.com,
	Mauro Aranda <maurooaranda@gmail.com>,
	Robert Weiner <rsw@gnu.org>
Subject: bug#23975: 25.0.94: defcustom error message is wrong when :type field has a :match attribute
Date: Fri, 4 Sep 2020 09:48:01 -0300	[thread overview]
Message-ID: <CABczVwfrT1YpDo9RNoki+bLKMqrrrnSQTUGa2cpeghmSZDnsPg@mail.gmail.com> (raw)
In-Reply-To: <CA+OMD9hP+uAc-YJnf7VqX=Bu+FwGD-88-uEB8OxGpjfFxLvbWg@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 782 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Mauro Aranda <maurooaranda@gmail.com> writes:
>
>> 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?
>
> I think that's a very good idea.

Great! Here's my attempt:

[-- Attachment #1.2: Type: text/html, Size: 1343 bytes --]

[-- Attachment #2: 0001-Document-type-error-property-for-customization-types.patch --]
[-- Type: text/x-patch, Size: 1276 bytes --]

From 84ee1868febb22ee8e43792dbb042def6e2023c7 Mon Sep 17 00:00:00 2001
From: Mauro Aranda <maurooaranda@gmail.com>
Date: Wed, 2 Sep 2020 08:44:01 -0300
Subject: [PATCH] Document :type-error property for customization types

* doc/lispref/customize.texi (Type Keywords): Document :type-error, so
Lisp programs can display a more correct message when the value of a
user option doesn't match its type.  (Bug#23975)
---
 doc/lispref/customize.texi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/doc/lispref/customize.texi b/doc/lispref/customize.texi
index b9c9130a92..c35444f581 100644
--- a/doc/lispref/customize.texi
+++ b/doc/lispref/customize.texi
@@ -1197,6 +1197,13 @@ Type Keywords
 the widget containing the invalid data, and set that widget's
 @code{:error} property to a string explaining the error.
 
+@item :type-error @var{string}
+@kindex type-error@r{, customization keyword}
+@var{string} should be a string that describes why a value doesn't
+match the type, as determined by the @code{:match} function.  When the
+@code{:match} function returns @code{nil}, the widget's @code{:error}
+property will be set to @var{string}.
+
 @ignore
 @item :indent @var{columns}
 Indent this item by @var{columns} columns.  The indentation is used for
-- 
2.28.0


  parent reply	other threads:[~2020-09-04 12:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-13 20:03 bug#23975: 25.0.94: defcustom error message is wrong when :type field has a :match attribute Robert Weiner
2019-07-28 11:12 ` Lars Ingebrigtsen
2019-07-28 11:49   ` Andreas Schwab
2020-09-04 11:28 ` Mauro Aranda
2020-09-04 12:12   ` Lars Ingebrigtsen
2020-09-04 12:48 ` Mauro Aranda [this message]
2020-09-04 12:51   ` Lars Ingebrigtsen

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=CABczVwfrT1YpDo9RNoki+bLKMqrrrnSQTUGa2cpeghmSZDnsPg@mail.gmail.com \
    --to=maurooaranda@gmail.com \
    --cc=23975@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=rsw@gnu.org \
    --cc=rswgnu@gmail.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).