all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bryce Carson <bovine@cyberscientist.ca>
To: emacs-devel@gnu.org
Subject: Re: Community improvements to the Emacs Widget Library manual?
Date: Fri, 14 Jul 2023 00:56:52 -0600	[thread overview]
Message-ID: <f57579a8-9606-adbf-144c-04dc506b9039@cyberscientist.ca> (raw)
In-Reply-To: <c03381a7-2801-9e61-6d04-3b86901ba7d0@cyberscientist.ca>


[-- Attachment #1.1: Type: text/plain, Size: 3716 bytes --]

I forgot to attach the screenshot of the in-error appearance in the 
customize buffer when using these lambdas to convert betwixt internal 
and internal values.

In the customize buffer, the button appears as invalid (nil). Perhaps my 
pcase is incorrect, but it's rather simple matching so I don't see why 
it'd be the cause (though it /would/ not match any of the choice-items 
if none of the patterns are matching [nil would be returned]).

On 7/14/23 00:52, Bryce Carson wrote:
>
> 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
-- 
"It's a GNU system, I don't know this!"
||--- Mirror universe Lex Murphy, in Cenozoic Zoo

[-- Attachment #1.2: Type: text/html, Size: 5096 bytes --]

[-- Attachment #2: Screenshot from 2023-07-14 00-45-48.png --]
[-- Type: image/png, Size: 33024 bytes --]

  reply	other threads:[~2023-07-14  6:56 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-12 11:43 Community improvements to the Emacs Widget Library manual? Mauro Aranda
2023-07-12 20:17 ` Bryce
2023-07-14  6:32 ` Bryce Carson
2023-07-14  6:52   ` Bryce Carson
2023-07-14  6:56     ` Bryce Carson [this message]
2023-07-14  6:59       ` Bryce Carson
2023-07-14  7:07         ` Bryce Carson
2023-07-14 14:41     ` Mauro Aranda
2023-07-14 18:50       ` bovine
2023-07-15  0:08         ` Mauro Aranda
2023-07-14 10:48   ` Mauro Aranda
  -- strict thread matches above, loose matches on Subject: below --
2023-07-09 12:17 Mauro Aranda
2023-07-12  4:07 ` Bryce
2023-07-12 11:34   ` Mauro Aranda
2023-07-13  3:30     ` Michael Heerdegen
2023-07-23 23:06   ` Bryce
2023-07-24 11:37     ` Eli Zaretskii
2023-07-08 20:18 Bryce Carson
2023-07-09  5:26 ` Eli Zaretskii
2023-07-09 12:02   ` Mauro Aranda
2023-07-09 12:16     ` Eli Zaretskii
2023-07-11  0:52   ` Bryce
2023-07-12 12:30     ` Eli Zaretskii
2023-07-12 16:42       ` Corwin Brust
2023-07-13 23:05         ` Bryce Carson
2023-07-10  3:38 ` Michael Heerdegen
2023-07-11 23:17   ` Bryce
2023-07-12  5:18     ` Michael Heerdegen
2023-07-12  7:21       ` Bryce
2023-07-13  2:59         ` Michael Heerdegen
2023-07-11 11:04 ` Kjartan Oli Agustsson
2023-07-14  2:02   ` Richard Stallman
2023-07-14  5:28     ` Bryce Carson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f57579a8-9606-adbf-144c-04dc506b9039@cyberscientist.ca \
    --to=bovine@cyberscientist.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.