Subject: bug#23975: 25.0.94: defcustom error message is wrong when :type field has a :match attribute

From: Mauro Aranda <[email-masked]>
Date: Fri, 4 Sep 2020 08:28:03 -0300

Lars Ingebrigtsen <[email-masked]> 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?