From: Bryce <bovine@cyberscientist.ca>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: emacs-devel@gnu.org
Subject: Re: Community improvements to the Emacs Widget Library manual?
Date: Tue, 11 Jul 2023 17:17:54 -0600 [thread overview]
Message-ID: <87lefmghr1.fsf@cyberscientist.ca> (raw)
In-Reply-To: <87y1joph9u.fsf@web.de> (message from Michael Heerdegen on Mon, 10 Jul 2023 05:38:53 +0200)
Michael Heerdegen <michael_heerdegen@web.de> writes:
> Bryce Carson <bovine@cyberscientist.ca> writes:
>
>> One aspect that is confusing is widget definition with
>> widget-specific argument handling. Built-in widgets handle arguments
>> after the keyword-value pairs in widget-specific ways. How do end
>> users create such behaviour in their own widgets? The answer is a
>> function value for the widget-create keyword, but this is a difficult
>> thing to implement.
>
> What keyword handling do you mean, exactly (example)? I ask because
> AFAIR, `widget-create' works fine for user-defined widget types.
Writing :widget-create functions works, but there are no examples in the
manual. Using a function which specially handles arguments (I do not
mean the :args keyword [though in some cases, this would be what I do
mean (Widget is strange like that)]) is only suggested as possible by
the manual stating some built-in widgets do this. An example is the ITEM
widget, which has the following type definitionf:
ITEM ::= (item [KEYWORD ARGUMENT]... VALUE)
This type definition syntax shows that after all of the
keyword-argument/keyword-value pairs that a VALUE must be supplied, but
that it does not need to be supplied as in the first form in the example
below.
(widget-create 'item "Example item VALUE")
(widget-create 'item :value "Example item :value ARGUMENT")
In the second form, I used ARGUMENT to match the type definition syntax
quoted above. Normally when writing about widgets, I will say
"Keyword-value pairs," because in most cases the :args keyword is simply
the list of arguments supplied to widget-create after the type argument,
like below.
(widget-create 'TYPE ARGUMENTS...)
=> ()
> Then either these are used implicitly (by the widget type you are
> deriving from) - or you can refer to the values using `widget-get' in
> the functions implementing the widget behavior (in `define-widget').
The widget-get function will retrieve values of properties (which are
defined with keyword-argument and value pairs [:keyword-argument
value]). Perhaps I simply did not think long enough about how to write a
function which will access the elements of a list after exhausting any
keyword value pairs. The widget-put function can be used to set the
value of an arbitrary property, which yes, can then be retrieved with
widget-get.
Perhaps a new macro should be introduced into the library which
facilitates accessing the nth argument _past the keyword-argument value
pairs_ in a reproducible way. The function widget-convert loops over the
arguments, assessing if they are keywords and makes them part of the
value of the :args property of the widget being created (if it is using
the default widget-convert functionality).
> What I missed in the documentation most of all was an explanation of
> the meaning of the keywords. There are a lot, and I recall that some
> widget types totally ignore some keywords and one has to use another
> one with a similar name instead, etc. I.e. it would be good to
> document which keywords are meaningful for which builtin widget types.
>
> Michael.
Regards, Michael. Thanks for asking the pointed question, it did guide
my thinking a bit.
next prev parent reply other threads:[~2023-07-11 23:17 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-08 20:18 Community improvements to the Emacs Widget Library manual? 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-13 23:27 ` [External] : " Drew Adams
2023-07-13 23:57 ` Bryce Carson
2023-07-10 3:38 ` Michael Heerdegen
2023-07-11 23:17 ` Bryce [this message]
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
-- 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-12 11:43 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
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
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lefmghr1.fsf@cyberscientist.ca \
--to=bovine@cyberscientist.ca \
--cc=emacs-devel@gnu.org \
--cc=michael_heerdegen@web.de \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).