all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: emacs-devel@gnu.org
Subject: Re: Community improvements to the Emacs Widget Library manual?
Date: Thu, 13 Jul 2023 05:30:14 +0200	[thread overview]
Message-ID: <87edlcmqt5.fsf@web.de> (raw)
In-Reply-To: 39814a3e-74d6-d573-761a-f5e107a98871@gmail.com

Mauro Aranda <maurooaranda@gmail.com> writes:

> Creation of a widget takes two steps: conversion and creation.
>
> Conversion means to take a specification of the widget to be created
> (type and properties) and convert that specification into another one,
> suitable for creating the widget.  So if you want to handle those extra
> args in a specific way, or to manipulate the widget before creation, you
> need a :convert-widget function, that widget-convert (which is
> undocumented in the manual) will make sure to call.  It will call the
> most specific :convert-widget function first, and then the
> :convert-widget of the parents.

This would be a nice paragraph to add to the manual I think.

> You can see an example of this in the following code:
>
> (defun completion--update-styles-options (widget)
>   "Function to keep updated the options in
> `completion-category-overrides'."
>   (let ((lst (mapcar (lambda (x)
>                        (list 'const (car x)))
>              completion-styles-alist)))
>     (widget-put widget :args (mapcar #'widget-convert lst))
>     widget))
>
> (defconst completion--styles-type
>   `(repeat :tag "insert a new menu to add more styles"
>            (choice :convert-widget completion--update-styles-options)))
>
> Here completion--styles-type holds a type definition for a defcustom,
> and the idea is to make the choices available build dynamically.
> Without a custom :convert-widget function, the :args would've been
> defined in a static way as soon as the type gets defined.  So we use a
> :convert-widget function that builds the choices, and puts them into the
> :args property, as required by the choice widget.  Then, when creating
> it, all the choices in :args show up in the buffer.

And this is a nice example for it!



BTW, one thing I often wondered about (I think it's missing in the
manual): one often sees code using list values like

`(widget-type :keyword1 ,(lambda ...) ...)

What is that?  Already a widget?  A widget definition?  What functions
accept such list values, and how do I create a real widget using such
values?


Michael.




  reply	other threads:[~2023-07-13  3:30 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-09 12:17 Community improvements to the Emacs Widget Library manual? Mauro Aranda
2023-07-09 14:59 ` [External] : " Drew Adams
2023-07-09 23:17   ` Mauro Aranda
2023-07-12  4:07 ` Bryce
2023-07-12 11:34   ` Mauro Aranda
2023-07-13  3:30     ` Michael Heerdegen [this message]
2023-07-23 23:06   ` Bryce
2023-07-24 11:37     ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
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
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=87edlcmqt5.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --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.