From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mauro Aranda Newsgroups: gmane.emacs.bugs Subject: bug#8717: 23.3; widget match functions should be passed internal representation? Date: Mon, 2 Nov 2020 09:45:29 -0300 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="000000000000ba2e9c05b31f1f84" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35008"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 8717@debbugs.gnu.org To: Dave Abrahams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 02 13:46:17 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kZZE0-0008wh-KH for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 02 Nov 2020 13:46:16 +0100 Original-Received: from localhost ([::1]:46590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZZDz-0007Hk-3D for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 02 Nov 2020 07:46:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZZDm-0007Hd-Pa for bug-gnu-emacs@gnu.org; Mon, 02 Nov 2020 07:46:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kZZDm-00042y-Fh for bug-gnu-emacs@gnu.org; Mon, 02 Nov 2020 07:46:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kZZDm-0002Ss-E5 for bug-gnu-emacs@gnu.org; Mon, 02 Nov 2020 07:46:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Mauro Aranda Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 02 Nov 2020 12:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8717 X-GNU-PR-Package: emacs Original-Received: via spool by 8717-submit@debbugs.gnu.org id=B8717.16043211509446 (code B ref 8717); Mon, 02 Nov 2020 12:46:02 +0000 Original-Received: (at 8717) by debbugs.gnu.org; 2 Nov 2020 12:45:50 +0000 Original-Received: from localhost ([127.0.0.1]:40050 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZZDZ-0002SI-Ew for submit@debbugs.gnu.org; Mon, 02 Nov 2020 07:45:49 -0500 Original-Received: from mail-wr1-f46.google.com ([209.85.221.46]:34717) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZZDX-0002S4-3X for 8717@debbugs.gnu.org; Mon, 02 Nov 2020 07:45:47 -0500 Original-Received: by mail-wr1-f46.google.com with SMTP id i16so9021696wrv.1 for <8717@debbugs.gnu.org>; Mon, 02 Nov 2020 04:45:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=rYQEPD6pQqoHJ2TYardDwUKtqnV8qVHqVlNDpAFx9e8=; b=TvfbS3JG4e6xGlpkQ0C5x3/nE5Fi7Z/fL62QP7P0wP3IzRoA5oXI8eza1WrAzjsCXg 5SJjEZMVewYf9fzKqBE9p8yIuiJnkrlnm3LYnJrQG3abCmRxXXsaztep0xb/ABEEc2mQ BsHyB6rhwZd3BGJtgwgHxlaPE2oownnq+CWGFowv0rDw0iKp+oIeULSunfQ7Uqj5h0t/ NcbypZQo7LQnwFrzgQLnx5/yFhcaQPym/dFL/k8qaOokH+A5rGH+8Jn1OTQC7cMaNaOf 74VVOwLRNYAZaXvVB2za32arXHjunx5HP0Jexx+uJVTaTcfJ1QjNZfIph33sysQMA391 5mPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=rYQEPD6pQqoHJ2TYardDwUKtqnV8qVHqVlNDpAFx9e8=; b=HX3gv0cQWgdAWwZT18Ulkdz7vkGlOnGcR3QWq73qsqS7NB+Zx5m6X2WKF6oog2OSi8 Fr3E0LNKMeXRqL3kMTvhzCBizboTOnRIc8JL37RJQX5+saifii6ajSU552NElzyWCkkR McASF4Fe3FTO7hIgxZYpdI2GUBzFvLVyVn/LHQoFp4DgEX84AHVf7vK26gPYtd2x+1Wm AyEZeW92JwvTEWg246dmhKQ59Oc4SDRQYTq7YW8Vm17nU2HKXiJbJSxpCVSuZQKI8ECD DrGdDM4ByMwOSFwa0JEJ+04oqfJXoFBJuWsfDU6OPqF2M71ce+BFD5bsTBZHpBSGtBrf aw/g== X-Gm-Message-State: AOAM530xk1srJStNdXa2Jv38xoWE5rT2p9Bz8XBXYUACDuzRbHCoTVdL IkwFQw0fE73YaIcXaOTMKe5HS3tR6Lmzf9ER2LI= X-Google-Smtp-Source: ABdhPJwS5QVYIGb+GIITqHN+9Jxt7n76WS0PKYxoglO0CAQHm7NZL58Ru33ajtvcAPTEqjAabZ85Mg0k+rMU9a2r++8= X-Received: by 2002:a5d:56d0:: with SMTP id m16mr19560878wrw.120.1604321141197; Mon, 02 Nov 2020 04:45:41 -0800 (PST) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:192511 Archived-At: --000000000000ba2e9c05b31f1f84 Content-Type: multipart/alternative; boundary="000000000000ba2e9a05b31f1f82" --000000000000ba2e9a05b31f1f82 Content-Type: text/plain; charset="UTF-8" Dave Abrahams 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? --000000000000ba2e9a05b31f1f82 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Dave Abrahams <dav= e@boostpro.com> writes:

> Please consider this widget defi= nition:
>
> =C2=A0 (defun el-get-repeat-value-to-internal (widg= et list-or-element)
> =C2=A0 =C2=A0 (if (listp list-or-element) list-= or-element (list list-or-element)))
>
> =C2=A0 (defun el-get-re= peat-match (widget value)
> =C2=A0 =C2=A0 (widget-editable-list-match= widget (el-get-repeat-value-to-internal widget value)))
>
> = =C2=A0 (define-widget 'el-get-repeat 'repeat
> =C2=A0 =C2=A0 = "A variable length list of non-lists that can also be represented as a= single element"
> =C2=A0 =C2=A0 :value-to-internal 'el-get-= repeat-value-to-internal
> =C2=A0 =C2=A0 :match 'el-get-repeat-ma= tch)
>
> I found it surprising that the :match field was requir= ed (if you don't
> include it, a value of "foo" does no= t match an (el-get-repeat string)
> widget.

It took me more th= an one read to understand this bug report, because the
title asks one th= ing, 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.=C2=A0 A value matches the
repeat widget if the value is = a list, and all the members match the type
specified by the repeat widge= t.=C2=A0 So, "foo" can't match a repeat widget
or a widget= that derives from the repeat widget, unless the derived
widget ove= rrides the :match function.

el-get-repeat-value-to-inte= rnal is not converting a value to an
"internal format", it is = just adapting the value to an "external format"
that the repea= t widget can represent.=C2=A0 Of course, if for the widget that
way of r= epresenting a value is useful, it can represent it that way,
but that do= esn't mean that the :match function takes the value in the
internal = format.

> I'm not sure what the proper remedy is; the documen= tation does
> not distinguish between where the system will operate o= n the "internal"
> and "external" values.=C2=A0 S= o, 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.=C2=A0 And surely it needs more work i= n this and other
concepts, but would be it OK to install something along= the lines of the
attached patch, to clarify this?
--000000000000ba2e9a05b31f1f82-- --000000000000ba2e9c05b31f1f84 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Document-that-the-match-function-for-a-widget-takes-.patch" Content-Disposition: attachment; filename="0001-Document-that-the-match-function-for-a-widget-takes-.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kh0j9csn0 RnJvbSAzZDNiMjgwYjY0ZTkyZGE2NWJ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