From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bryce Carson Newsgroups: gmane.emacs.devel Subject: Re: Community improvements to the Emacs Widget Library manual? Date: Fri, 14 Jul 2023 00:52:25 -0600 Message-ID: References: <7494e36a-9245-cd4c-5515-5ec26d1889c7@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------tS5vt1uzJNKSpUPhHuu1W2Fw" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19106"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jul 14 08:53:47 2023 Return-path: Envelope-to: ged-emacs-devel@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 1qKCgV-0004lP-4U for ged-emacs-devel@m.gmane-mx.org; Fri, 14 Jul 2023 08:53:47 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qKCfX-0004s6-QG; Fri, 14 Jul 2023 02:52:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKCfO-0004rh-LF for emacs-devel@gnu.org; Fri, 14 Jul 2023 02:52:38 -0400 Original-Received: from seout10.web-dns1.com ([68.168.119.164]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKCfM-00015g-O8 for emacs-devel@gnu.org; Fri, 14 Jul 2023 02:52:38 -0400 Original-Received: from beaudry.whc.ca ([72.10.170.194]) by se3.web-dns1.com with esmtps (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1qKCfK-0005sI-1G for emacs-devel@gnu.org; Fri, 14 Jul 2023 02:52:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=cyberscientist.ca; s=default; h=In-Reply-To:From:References:To:Subject: MIME-Version:Date:Message-ID:Content-Type:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FTq177NjO+faATQCS/Lw8A1JJfdg0CXLYkPCj0rcUUM=; b=IgLjY4TGzcrVhNcovXwnXUrw4E 5nA+D8AILj0fz/sPRygE4y2M8BJ0opvXm7e3zrkT93ogKat8jMk3qR8WIVQyqReQ96KnVeAnqXWz7 cTKm7mZHQujwyVjiR8c5zktLge1PnL2uD3t7A11q23H2PxamqUzIxxfesVgpGmjI2FLvODPja9V0I MMXVPSlqNN0ri8oA4WqokmMbWthjUdGiy7pEkG6kFxFwry2kwR1BZea90U9xbzh3V6tpHbORN3tja xo0/hppGII0ChsWOvGDL2Ddqqk4fEC83y8wI1By5rGdsbY2UZoL4+gc85TqyNKp/bx15gaKhE/TZJ Za4DtVeg==; Original-Received: from [174.0.57.221] (port=56350 helo=[10.0.0.120]) by beaudry.whc.ca with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1qKCfC-0003aO-0a for emacs-devel@gnu.org; Fri, 14 Jul 2023 02:52:33 -0400 Content-Language: en-US In-Reply-To: X-Originating-IP: 72.10.170.194 X-SpamExperts-Domain: out.beaudry.whc.ca X-SpamExperts-Username: 72.10.170.194 Authentication-Results: web-dns1.com; auth=pass smtp.auth=72.10.170.194@out.beaudry.whc.ca X-SpamExperts-Outgoing-Class: unsure X-SpamExperts-Outgoing-Evidence: Combined (0.31) X-Recommended-Action: accept X-Filter-ID: Pt3MvcO5N4iKaDQ5O6lkdGlMVN6RH8bjRMzItlySaT/zA2s1MHHrL/o1MDyqk1ViPUtbdvnXkggZ 3YnVId/Y5jcf0yeVQAvfjHznO7+bT5yIihPVXVFAYa+LPll+F2R2qA/pdxL9H6My4aKblWy1s/Ow agf2V5pmh/wKkAm/V0Jaa40DxZPJuLUk3zkVKd8pdqDuc9lS3Nx+9iKFZ9qooJJVRKyFCRrxWkR6 oZhlSr1PyJCkrfCv5qYfIiHO9mkciFKfD1jKgYfH+6S5qDVYoDFgY9NSkYzvwZKlNZIeZZVkrQQy Z/c/nQCN/+0hfTQWLZTNkxviS5foPl4ROYZS5Rypt3L7tZhLu6Os9ceqGjHQelPdLZIWapW8lSgO kuDXt8NAP2tNgqlZSPO6AG7dtO9lTc/lh7l2vZq/KN1i/pryipC/TlrIHWPdDiuNdtg82tBEUiGC M39V9+6XN2yNndnjGmKA6S0KnpdzPXa1+MU93SsS4aMXJmiJ2G0eb5ahJnNhPA2hnnDjk/qYEn+w eZSHVcVCpZ7zg9Yz3coy8pWNLtSRWKGmohoil/1AiKo+tkgXyuidojvEg3qjfiiAf/vg7iEFLP+S SY+Av5+AiC4kqdZ7bWdX60j6o4Cj7ho8cQH0THFmRlzN15Lhb2t4Ne5Uf7q9cFXweH4lUNpYhKUP fwtEBPOEy16l9tvGv41KJOhrIL0ub5y9ZLX7s9BqfXaN8D06VAQ2mBAXFY6xKi0RFZ4oobg8BBg3 Jq+ntzj0dD4E6uqWowcMNBPxYwVNc/rw58roIPDP31IvJzkauKnknLsiWZ8kaPaxkkTQCApwd+2i LLpLn3HxJHaHPzkKPA+uo7/8wFSRb X-Report-Abuse-To: spam@se1.web-dns1.com Received-SPF: pass client-ip=68.168.119.164; envelope-from=bovine@cyberscientist.ca; helo=seout10.web-dns1.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:307850 Archived-At: This is a multi-part message in MIME format. --------------tS5vt1uzJNKSpUPhHuu1W2Fw Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Further, I can't seem to get these functions to work /as documented/ or expected. Without these defined when I'm creating a widget with the following code, I do get a button but the internal value is displayed in the clickable button. I'd like the external value to be displayed in the button %v, just as the menu-tag is is "externally facing". <>= (define-widget 'project-widget 'list :tag (let ((s "\n\tProject")) (put-text-property 0 (length s) 'face 'bold s) s) :format "%t\n%v " :offset 0 :indent 0 :convert-widget 'widget-types-convert-widget :args '((menu-choice :tag "EmacSQL-supported backend" :format "%[%t%]: %[%v%]" :value "sqlite" :value-to-external <> :value-to-internal <> (choice-item :menu-tag "MySQL" :value "mysql") (choice-item :menu-tag "PostgreSQL" :value "postgresql") (choice-item :menu-tag "SQLite" :value "sqlite")))) <>= (lambda (widget internal-value) "Converts lowercase, internal values to the casing of trademarks." (pcase internal-value ("mysql" "MySQL") ("sqlite" "SQLite") ("postgresql" "PostgreSQL"))) <>= (lambda (widget external-value) "Converts the casing of trademarked names to lowercase, internal values." (pcase external-value ("MySQL" "mysql") ("SQLite" "sqlite") On 7/14/23 00:32, Bryce Carson wrote: > > In the section /Defining New Widgets/, the following quotation reveals > a bug, I believe. I added emphasis for the last sentence of each > description of the keywords. I believe that for the :value-to-external > function, the last sentence is not supposed to be present. > > :value-to-internal > Function to convert the value to the internal format. The function takes two > arguments, a widget and an external value, and returns the internal value./The function is called on the present :value when the widget is > created, and on any value set later with widget-value-set./ > :value-to-external > Function to convert the value to the external format. The function takes two > arguments, a widget and an internal value, and returns the external value./The function is called on the present :value when the widget is > created, and on any value set later with widget-value-set./ > > It looks like the author or editor of the descriptions coped them, > which is fine. It doesn't make sense that :value-to-external would be > called when the widget is created, nor when new values are set with > widget-value-set. > > Other places in the manual state that the value of the :value keyword, > when creating or defining widget, should be in the external form, more > evidence that the last sentence is a bug. > -- "It's a GNU system, I don't know this!" ||--- Mirror universe Lex Murphy, in Cenozoic Zoo --------------tS5vt1uzJNKSpUPhHuu1W2Fw Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Further, I can't seem to get these functions to work as documented or expected.

Without these defined when I'm creating a widget with the following code, I do get a button but the internal value is displayed in the clickable button. I'd like the external value to be displayed in the button %v, just as the menu-tag is is "externally facing".

<<widget>>=
(define-widget 'project-widget 'list
  :tag (let ((s "\n\tProject"))
         (put-text-property 0 (length s) 'face 'bold s) s)
  :format "%t\n%v "
  :offset 0
  :indent 0
  :convert-widget 'widget-types-convert-widget
  :args '((menu-choice
           :tag "EmacSQL-supported backend"
           :format "%[%t%]: %[%v%]"
           :value "sqlite"
           :value-to-external <<menu-choice internal value to external lambda>>
           :value-to-internal <<menu-choice external value to internal lambda>>
           (choice-item :menu-tag "MySQL" :value "mysql")
           (choice-item :menu-tag "PostgreSQL" :value "postgresql")
           (choice-item :menu-tag "SQLite" :value "sqlite"))))
<<menu-choice internal value to external lambda>>=
(lambda (widget internal-value)
  "Converts lowercase, internal values to the casing of trademarks."
  (pcase internal-value
    ("mysql" "MySQL")
    ("sqlite" "SQLite")
    ("postgresql" "PostgreSQL")))
<<menu-choice external value to internal lambda>>=
(lambda (widget external-value)
  "Converts the casing of trademarked names to lowercase, internal values."
  (pcase external-value
    ("MySQL" "mysql")
    ("SQLite" "sqlite")

On 7/14/23 00:32, Bryce Carson wrote:

In the section Defining New Widgets, the following quotation reveals a bug, I believe. I added emphasis for the last sentence of each description of the keywords. I believe that for the :value-to-external function, the last sentence is not supposed to be present.

:value-to-internal
	Function to convert the value to the internal format. The function takes two
	arguments, a widget and an external value, and returns the internal value. The
	function is called on the present :value when the widget is created, and on any
	value set later with widget-value-set.
:value-to-external
	Function to convert the value to the external format. The function takes two
	arguments, a widget and an internal value, and returns the external value. The
	function is called on the present :value when the widget is created, and on any
	value set later with widget-value-set.

It looks like the author or editor of the descriptions coped them, which is fine. It doesn't make sense that :value-to-external would be called when the widget is created, nor when new values are set with widget-value-set.

Other places in the manual state that the value of the :value keyword, when creating or defining widget, should be in the external form, more evidence that the last sentence is a bug.

--
It's a GNU system, I don't know this!
    --- Mirror universe Lex Murphy, in Cenozoic Zoo
--------------tS5vt1uzJNKSpUPhHuu1W2Fw--