Subject: bug#51550: 29.0.50; Customize Group INS buttons sometimes don't have a left box line

From: Mauro Aranda <[email-masked]>
Date: Mon, 17 Feb 2025 06:31:12 -0300

Mauro Aranda <[email-masked]> writes:

 > Now, I think one way to fix this (assuming we're sure we want the
 > :box attribute for the widget-field face) is not by changing the widgets
 > (or whatever content) that come after the editable-field widget, since
 > that's something we can't control in the Widget library. Instead,
 > the focus should be in the editable-field.  I attach a patch to show
 > what I'm thinking about, but I need to test it more.

After a month, I've now tested it a lot more, and didn't find any
problems.  I attach an updated patch, based on master.

I'll install it in a few days if there are no objections.

From d3b1827bc406afa932ac2ac0f8bce2a115f817f0 Mon Sep 17 00:00:00 2001
From: Mauro Aranda <[email-masked]>
Date: Thu, 16 Jan 2025 18:45:18 -0300
Subject: [PATCH] Avoid display bugs after editable-field widgets

* lisp/wid-edit.el (widget-specify-button): Don't add an
invisible space before the button to avoid bugs that surface
with the widget-field face.  The Widget library is not
the one that puts a :box attribute for the button face, and we
can't control what other library users put after editable-field
widgets.
(widget-specify-field): Add the invisible space here, after the
newline.  Since we're the ones that added a :box attribute to
the widget-field face, we should take care of protecting
whatever comes after the editable-field widget.  (Bug#51550)
---
 lisp/wid-edit.el | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index a1d4c4850ae..aac834c05d7 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -427,7 +427,12 @@ widget-specify-field
 	(overlay-put overlay 'local-map keymap)
 	(overlay-put overlay 'face face)
 	(overlay-put overlay 'follow-link follow-link)
-	(overlay-put overlay 'help-echo help-echo))
+        (overlay-put overlay 'help-echo help-echo)
+        ;; Since the `widget-field' face has a :box attribute, we need to add
+        ;; some character with no face after the newline character, to avoid
+        ;; clashing with text that comes after the field and has a face with
+        ;; a :box attribute too.  (Bug#51550)
+        (overlay-put overlay 'after-string #(" " 0 1 (invisible t))))
       (setq to (1- to))
       (setq rear-sticky t))
     (let ((overlay (make-overlay from to nil nil rear-sticky)))
@@ -468,8 +473,6 @@ widget-specify-button
     (widget-put widget :button-overlay overlay)
     (when (functionp help-echo)
       (setq help-echo 'widget-mouse-help))
-    (overlay-put overlay 'before-string
-                 (propertize " " 'invisible t 'face face))
     (overlay-put overlay 'button widget)
     (overlay-put overlay 'keymap (widget-get widget :keymap))
     (overlay-put overlay 'evaporate t)
-- 
2.34.1