[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: editable-list widgets: how to create one child automatically
From: |
Mauro Aranda |
Subject: |
Re: editable-list widgets: how to create one child automatically |
Date: |
Thu, 14 Mar 2024 08:19:47 -0300 |
User-agent: |
Mozilla Thunderbird |
On 13/3/24 22:58, Michael Heerdegen via Users list for the GNU Emacs
text editor wrote:
> Mauro Aranda <maurooaranda@gmail.com> writes:
>
>> (widget-create 'editable-list
>> :value (list my-first-default)
>> ;; Change according to the child type.
>> '(editable-field))
>>
>> Does that not do what you want?
>
> I think I can't use this: I don't create an ad-hoc widget, I need an
> `define-widget' expression to define the widget to behave accordingly
> when created.
OK, but still the :value should be respected when given inside a
define-widget.
> And the widget this is about is a part of a group widget definition so
> there will never be an explicit `widget-create' call by me, the widget
> will always be created implicitly by the parent.
>
> And in this definition a :value spec is more or less ignored - in my
> tests that child widget will always be created with a nil widget value.
This shouldn't happen. But what I think is happening is that when
you're creating the find widget, I guess when funcalling this:
(defvar find-cmd-widget-default-start-fun
(lambda ()
(setq-local find-cmd-widget-main-widget (widget-create 'find))))
The find widget gets created with a nil value, which, when trying to
match against its children values, won't match when the editable-list
has a different value, like (list default-directory)
Because of that, the code understands that it should override the :value
property of the editable-list to a nil value, hence the empty
editable-list.
So I think a better way is to provide a matching value for the find
widget that will allow it to create its children with their default
values.