Subject: Re: bug#77096: 31.0.50; Theme names disappear in customize-themes

From: Mauro Aranda <[email-masked]>
Date: Tue, 18 Mar 2025 07:06:18 -0300

This is a result of my changes in:

commit 85113fcda97970bc2468f409278e27d6570fc76f
Author: Mauro Aranda <[email-masked]>
Date:   Fri Jan 17 17:12:08 2025 -0300

     Prepare markers for insertions inside of a widget

     Recreating child widgets without recreating the parent widget
     may lead to situations where the parent widget doesn't cover its
     children or buttons entirely anymore.  This bug manifests as a
     faulty fontification of children or buttons, for example.
     (Bug#69941)

     * lisp/wid-edit.el (widget--prepare-markers-for-inside-insertion)
     (widget--prepare-markers-for-outside-insertion): New functions.
     (widget-default-create): Use them.

     * test/lisp/wid-edit-tests.el (widget-test-insertion-at-parent-markers)
     (widget-test-insertion-at-parent-markers-2): New tests.

But I don't think there's a bug in the wid-edit.el code, rather it's in
customize-themes.  The layout for a line with a theme is like this:
CHECKBOX BUTTON -- THEME-DESCRIPTION

BUTTON has the theme name as a label, and it disappears after toggling
the checkbox.  The code creates BUTTON as a child of CHECKBOX, so the
code is asking for BUTTON to be contained inside CHECKBOX.  It didn't
happen before because of Bug#69941, but I think that what happens now is
what should happen.  Now, when the checkbox gets recreated, it deletes
its child and never creates it back (the cus-theme.el code should be
responsible of telling it to create it back in that case).

But I don't think BUTTON should be a child of CHECKBOX.  In fact, the
usual thing to do with the Widget library is to make it a sibling.  So I
propose the attached patch.

From a66e5dd49ad9884626516b4d4d51bc72ad132949 Mon Sep 17 00:00:00 2001
From: Mauro Aranda <[email-masked]>
Date: Tue, 18 Mar 2025 07:04:22 -0300
Subject: [PATCH] Fix widget relationship in customize-themes

* lisp/cus-theme.el (customize-themes): The theme button should
be a sibling of the checkbox widget, not a child.  (Bug#77096)
---
 lisp/cus-theme.el | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lisp/cus-theme.el b/lisp/cus-theme.el
index 441270ff63c..41bcc678322 100644
--- a/lisp/cus-theme.el
+++ b/lisp/cus-theme.el
@@ -654,12 +654,13 @@ customize-themes
 				    :help-echo help-echo
                                     :action #'custom-theme-checkbox-toggle))
         (push (cons theme widget) custom--listed-themes)
-        (widget-create-child-and-convert widget 'push-button
-				         :button-face-get 'ignore
-				         :mouse-face-get 'ignore
-				         :value (format " %s" theme)
-                                         :action #'widget-parent-action
-				         :help-echo help-echo)
+        (widget-create 'push-button
+                       :button-face-get 'ignore
+                       :mouse-face-get 'ignore
+                       :value (format " %s" theme)
+                       :action (lambda (_w &optional event)
+                                 (custom-theme-checkbox-toggle widget event))
+                       :help-echo help-echo)
         (widget-insert " -- "
 		       (propertize (custom-theme-summary theme)
 				   'face 'shadow)
-- 
2.34.1