bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25152: 25.1; Customize: errors for `restricted-sexp' in `repeat'


From: Mauro Aranda
Subject: bug#25152: 25.1; Customize: errors for `restricted-sexp' in `repeat'
Date: Fri, 23 Oct 2020 09:59:45 -0300

Mauro Aranda <maurooaranda@gmail.com> writes:

> Drew Adams <drew.adams@oracle.com> writes:
>
>>> To sum it up, the prompt is an unfortunate mistake, and maybe we could
>>> protect against that, but I think the real problem comes from the
>>> defcustom, which fails to provide a valid default value.
>>
>> Thanks for this explanation.  Makes sense.
>>
>> Can we somehow help users by raising an error when they
>> do this?  Seems like a simple mistake to make.
>
> I think it makes sense, but I'm not sure where would be the right place
> to do it.

Coming back to this, perhaps a good place to warn about a bad default
value is where we find it for the first time.  So I attach a patch that
makes the restricted-sexp widget warn (but not error out) if the
internal value is not a string.

So, for the defcustom in the recipe:
(defcustom bar
  `(ignore)
  "..."
  :type
  '(repeat (restricted-sexp :match-alternatives (functionp)))
  :group 'emacs)

When the user clicks the INS button, the following warning pops up:
Warning (widget-bad-default-value):
A widget of type restricted-sexp has a bad default value.
value: nil
match function: widget-restricted-sexp-match
match-alternatives: (functionp)

which I hope conveys good enough information to fix the mistake.

I made it just a warning, because this mistake doesn't always result in
a messed up buffer.  But it can be changed to an error, of course.

Attachment: 0001-Warn-about-a-bad-default-value-in-restricted-sexp-wi.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]