* bug#75171: 30.0.50; Checklist widget inside a group does not initialize correctly
@ 2024-12-29 8:33 Al Haji-Ali
2025-01-02 13:56 ` Mauro Aranda
0 siblings, 1 reply; 4+ messages in thread
From: Al Haji-Ali @ 2024-12-29 8:33 UTC (permalink / raw)
To: 75171
The following function creates four widgets (two radio button lists and two checklists) inside a group. All lists have an initial value, while the group has a nil value. Strangely, the radio buttons get initialized correctly (selecting the correct button based on their value), but the checkboxes do not (all boxes are unchecked regardless of the value). Removing the group results in correct initialization.
--8<---------------cut here---------------start------------->8---
(defun widget-test ()
(let ((items '((item :format "%[One%] " :value 1)
(item :format "%[Two%] " :value 2)
(item :format "%[Three%] " :value 3))))
(widget-create
'group
(append '(radio-button-choice
:inline t
:format "Inline radio:\n%v\n"
:value 2)
items)
(append '(radio-button-choice
:format "Not inline radio:\n%v\n"
:value 2)
items)
(append '(checklist
:inline t
:format "Inline checks:\n%v\n"
:value (1 2))
items)
(append '(checklist
:format "Not inline checks:\n%v\n"
:value (1 2))
items)))
(widget-setup))
--8<---------------cut here---------------end--------------->8---
If this is unintended behaviour, I managed to fix the inline version of the checklists with this advice
--8<---------------cut here---------------start------------->8---
(advice-add 'widget-checklist-match-inline
:around
(lambda (old-fn wid val)
(when val
(funcall old-fn wid val))))
--8<---------------cut here---------------end--------------->8---
The non-inline version probably requires a fix in `widget-checklist-match`, but I can't make out the logic in this function (it seems to return non-nil when not matching?!).
If it is intended behaviour, how can I correctly set the value of a checklist? and why is there a discrepancy between radio buttons and check lists?
-- Al
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#75171: 30.0.50; Checklist widget inside a group does not initialize correctly
2024-12-29 8:33 bug#75171: 30.0.50; Checklist widget inside a group does not initialize correctly Al Haji-Ali
@ 2025-01-02 13:56 ` Mauro Aranda
2025-01-02 22:04 ` Al Haji-Ali
0 siblings, 1 reply; 4+ messages in thread
From: Mauro Aranda @ 2025-01-02 13:56 UTC (permalink / raw)
To: 75171
Al Haji-Ali <abdo.haji.ali@gmail.com> writes:
> The following function creates four widgets (two radio button lists
> and two checklists) inside a group. All lists have an initial value,
> while the group has a nil value. Strangely, the radio buttons get
> initialized correctly (selecting the correct button based on their
> value), but the checkboxes do not (all boxes are unchecked regardless
> of the value). Removing the group results in correct initialization.
>
> (defun widget-test ()
> (let ((items '((item :format "%[One%] " :value 1)
> (item :format "%[Two%] " :value 2)
> (item :format "%[Three%] " :value 3))))
> (widget-create
> 'group
> (append '(radio-button-choice
> :inline t
> :format "Inline radio:\n%v\n"
> :value 2)
> items)
> (append '(radio-button-choice
> :format "Not inline radio:\n%v\n"
> :value 2)
> items)
> (append '(checklist
> :inline t
> :format "Inline checks:\n%v\n"
> :value (1 2))
> items)
> (append '(checklist
> :format "Not inline checks:\n%v\n"
> :value (1 2))
> items)))
> (widget-setup))
>
There's no explicit :value for the group widget, so its value is nil,
and then the Widget library tries to create all four children with a nil
value. The radio-button-choice widget differs from the checklist widget
in that the former tries to be created with a selected choice, and tries
harder than the checklist widget, which is fine with a value of nil.
That way, you see that the specified value is obeyed in
radio-button-choice but not in the checklist widget.
FTR, I'm not saying this is 100% correct. I'm just trying to explain
how it works now.
> If this is unintended behaviour, I managed to fix the inline version
> of the checklists with this advice
This is intended behavior, AFAIU. The parent can override values for
the children, and that way we can recreate widgets with new values just
by changing the values of the parent.
> If it is intended behaviour, how can I correctly set the value of a
> checklist? and why is there a discrepancy between radio buttons and
> check lists?
I'm not sure if you want them inline or not, but here's a modification
to your recipe that works:
(defun widget-test ()
(let ((items '((item :format "%[One%] " :value 1)
(item :format "%[Two%] " :value 2)
(item :format "%[Three%] " :value 3))))
(widget-create
'group
:value '(2 (1 2))
(append '(radio-button-choice
:format "Not inline radio:\n%v\n"
:value 2)
items)
(append '(checklist
:format "Not inline checks:\n%v\n"
:value (1 2))
items)))
(widget-setup))
As you can see, it's a matter of giving the correct value to the group
widget.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#75171: 30.0.50; Checklist widget inside a group does not initialize correctly
2025-01-02 13:56 ` Mauro Aranda
@ 2025-01-02 22:04 ` Al Haji-Ali
2025-01-03 13:05 ` Mauro Aranda
0 siblings, 1 reply; 4+ messages in thread
From: Al Haji-Ali @ 2025-01-02 22:04 UTC (permalink / raw)
To: Mauro Aranda, 75171
On 02/01/2025, Mauro Aranda wrote:
> Al Haji-Ali <abdo.haji.ali@gmail.com> writes:
> There's no explicit :value for the group widget, so its value is nil,
> and then the Widget library tries to create all four children with a nil
> value. The radio-button-choice widget differs from the checklist widget
> in that the former tries to be created with a selected choice, and tries
> harder than the checklist widget, which is fine with a value of nil.
>
> That way, you see that the specified value is obeyed in
> radio-button-choice but not in the checklist widget.
>
> FTR, I'm not saying this is 100% correct. I'm just trying to explain
> how it works now.
Thanks, this makes sense. Did I miss an explanation of this issue somewhere in the docs?
> This is intended behavior, AFAIU. The parent can override values for
> the children, and that way we can recreate widgets with new values just
> by changing the values of the parent.
I was aware of this behaviour for the group, but I didn't twig the consequence on a checklist.
I have to say that I find it a bit counter-intuitive. Also the fact that there is no way to set the value of a checklist without repeating it in the group is somewhat awkward (certainly it will complicate my implementation) and a bit inconsistent since setting the value of the checklist after the group creation would override the value of the group. A fix, or a some way, that would prevents the group from overriding the values of the children would be useful, IMO.
With that being said, this issue should probably be closed as "not a bug".
Thanks,
-- Al
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#75171: 30.0.50; Checklist widget inside a group does not initialize correctly
2025-01-02 22:04 ` Al Haji-Ali
@ 2025-01-03 13:05 ` Mauro Aranda
0 siblings, 0 replies; 4+ messages in thread
From: Mauro Aranda @ 2025-01-03 13:05 UTC (permalink / raw)
To: Al Haji-Ali, 75171
Al Haji-Ali <abdo.haji.ali@gmail.com> writes:
> On 02/01/2025, Mauro Aranda wrote:
>
>> Al Haji-Ali <abdo.haji.ali@gmail.com> writes:
>> There's no explicit :value for the group widget, so its value is nil,
>> and then the Widget library tries to create all four children with a nil
>> value. The radio-button-choice widget differs from the checklist widget
>> in that the former tries to be created with a selected choice, and tries
>> harder than the checklist widget, which is fine with a value of nil.
>>
>> That way, you see that the specified value is obeyed in
>> radio-button-choice but not in the checklist widget.
>>
>> FTR, I'm not saying this is 100% correct. I'm just trying to explain
>> how it works now.
>
> Thanks, this makes sense. Did I miss an explanation of this issue
> somewhere in the docs?
I don't think so. The manual is still missing good explanations.
>> This is intended behavior, AFAIU. The parent can override values for
>> the children, and that way we can recreate widgets with new values just
>> by changing the values of the parent.
>
> I was aware of this behaviour for the group, but I didn't twig the
> consequence on a checklist.
>
> I have to say that I find it a bit counter-intuitive. Also the fact
> that there is no way to set the value of a checklist without repeating
> it in the group is somewhat awkward (certainly it will complicate my
> implementation)
Note that you don't necessarily need to repeat it in the checklist
widget. In my example, you only need to pass the :value in group:
(defun widget-test ()
(let ((items '((item :format "%[One%] " :value 1)
(item :format "%[Two%] " :value 2)
(item :format "%[Three%] " :value 3))))
(widget-create
'group
:value '(2 (1 2))
(append '(radio-button-choice
:format "Not inline radio:\n%v\n")
items)
(append '(checklist
:format "Not inline checks:\n%v\n")
items)))
(widget-setup))
When created, radio-button-choice will get its :value set to 2 and
checklist will get it set to (1 2).
> and a bit inconsistent since setting the value of the
> checklist after the group creation would override the value of the
> group. A fix, or a some way, that would prevents the group from
> overriding the values of the children would be useful, IMO.
> With that being said, this issue should probably be closed as "not a
bug".
I'd like to take some time to study this and see if there's a way to
improve the situation.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-03 13:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-29 8:33 bug#75171: 30.0.50; Checklist widget inside a group does not initialize correctly Al Haji-Ali
2025-01-02 13:56 ` Mauro Aranda
2025-01-02 22:04 ` Al Haji-Ali
2025-01-03 13:05 ` Mauro Aranda
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.