GNU bug report logs -
#63838
28.2; 'wid-edit.el' problems with 'integer' (and 'sexp') widgets.
Previous Next
Reported by: Marco Antoniotti <marcoxa <at> gmail.com>
Date: Fri, 2 Jun 2023 11:13:01 UTC
Severity: normal
Tags: patch
Found in version 28.2
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Marco Antoniotti <marcoxa <at> gmail.com> writes:
> Hi
Thanks for the bug report!
> The issue is with the following code that tries to use the Widget
> library. The slots of the widget are actually not necessary to see the
> problem.
>
> (widget-create 'integer
> :help-echo "Enter an integer..."
> :notify (lambda (w1 &rest ws)
> (ignore ws)
> (message "WIFT: IF: %s"
> (widget-value w1)
> ))
> :size 4
> )
The :notify value is kind of necessary, right? I mean, the bug doesn't
manifest as long as code doesn't try to access the value of a
restricted-sexp widget while its empty.
> Specializing the widget with a hack like the function below fixes the
> problem, but a
> good solution may need some more work to get all the corner cases.
> Note that setting a "widget buffer" in overwrite mode goes a long way to
> mitigate these problems: maybe having widget-setup switch to it would
> be another good thing to do.
I don't think we want to do that.
> :value-to-external
> (lambda (widget value)
> ;; Lifted, and fixed, from `:value-to-external' in
> ;; `restricted-sexp'.
>
> (unless (stringp value)
> (display-warning
> 'widget-bad-default-value
> (format-message
> "\nA widget of type %S has a bad default value.
> value: %S
> match function: %S
> match-alternatives: %S"
> (widget-type widget)
> value
> (widget-get widget :match)
> (widget-get widget :match-alternatives))
> :warning))
> (if (and (stringp value) (string-equal "" value))
> ;; Oooops, we cannot just `read'.
> (widget-get widget :default-value)
> (read value))
> )
I don't think this is a good place to do this. And there's no
:default-value property in the widget library, just :value.
I think it'd be much better if we specialize the :value-get function for
the restricted-sexp widget, defaulting to return :value when the widget
is empty.
This bug report was last modified 1 year and 253 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.