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

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Fri, 9 Dec 2016 20:41:03 UTC

Severity: normal

Tags: confirmed, fixed

Merged with 15689

Found in versions 24.3.50, 24.5, 25.0.94, 25.1

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 25152 <at> debbugs.gnu.org
Subject: bug#25152: 25.1; Customize: errors for `restricted-sexp' in `repeat'
Date: Fri, 23 Oct 2020 09:59:45 -0300
[Message part 1 (text/plain, inline)]
Mauro Aranda <maurooaranda <at> gmail.com> writes:

> Drew Adams <drew.adams <at> 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.
[Message part 2 (text/html, inline)]
[0001-Warn-about-a-bad-default-value-in-restricted-sexp-wi.patch (text/x-patch, attachment)]

This bug report was last modified 4 years and 211 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.