GNU bug report logs - #8717
23.3; widget match functions should be passed internal representation?

Previous Next

Package: emacs;

Reported by: Dave Abrahams <dave <at> boostpro.com>

Date: Sun, 22 May 2011 19:35:02 UTC

Severity: normal

Tags: fixed

Found in version 23.3

Done: Mauro Aranda <maurooaranda <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 8717 <at> debbugs.gnu.org (full text, mbox):

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: Dave Abrahams <dave <at> boostpro.com>
Cc: 8717 <at> debbugs.gnu.org
Subject: Re: bug#8717: 23.3;
 widget match functions should be passed internal representation?
Date: Mon, 2 Nov 2020 09:45:29 -0300
[Message part 1 (text/plain, inline)]
Dave Abrahams <dave <at> boostpro.com> writes:

> Please consider this widget definition:
>
>   (defun el-get-repeat-value-to-internal (widget list-or-element)
>     (if (listp list-or-element) list-or-element (list list-or-element)))
>
>   (defun el-get-repeat-match (widget value)
>     (widget-editable-list-match widget (el-get-repeat-value-to-internal
widget value)))
>
>   (define-widget 'el-get-repeat 'repeat
>     "A variable length list of non-lists that can also be represented as
a single element"
>     :value-to-internal 'el-get-repeat-value-to-internal
>     :match 'el-get-repeat-match)
>
> I found it surprising that the :match field was required (if you don't
> include it, a value of "foo" does not match an (el-get-repeat string)
> widget.

It took me more than one read to understand this bug report, because the
title asks one thing, but the code presented doesn't do that, and maybe
that goes to show how confusing this stuff can be.

The :match function should be passed a value in the external format.
That is, the value as seen by the rest of Emacs.  A value matches the
repeat widget if the value is a list, and all the members match the type
specified by the repeat widget.  So, "foo" can't match a repeat widget
or a widget that derives from the repeat widget, unless the derived
widget overrides the :match function.

el-get-repeat-value-to-internal is not converting a value to an
"internal format", it is just adapting the value to an "external format"
that the repeat widget can represent.  Of course, if for the widget that
way of representing a value is useful, it can represent it that way,
but that doesn't mean that the :match function takes the value in the
internal format.

> I'm not sure what the proper remedy is; the documentation does
> not distinguish between where the system will operate on the "internal"
> and "external" values.  So, at least clarification in the docs is needed
> regardless, IMO.

The manual doesn't even say what an "external value" and an
"internal value" is.  And surely it needs more work in this and other
concepts, but would be it OK to install something along the lines of the
attached patch, to clarify this?
[Message part 2 (text/html, inline)]
[0001-Document-that-the-match-function-for-a-widget-takes-.patch (text/x-patch, attachment)]

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

Previous Next


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