emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Community improvements to the Emacs Widget Library manual?


From: Bryce Carson
Subject: Re: Community improvements to the Emacs Widget Library manual?
Date: Fri, 14 Jul 2023 00:52:25 -0600
User-agent: Mozilla Thunderbird

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]