Subject: bug#77603: 31.0.50; Spurious fontification of the word customize in Help buffer

From: Visuwesh <[email-masked]>
Date: Mon, 07 Apr 2025 15:24:26 +0530

[திங்கள் ஏப்ரல் 07, 2025] Visuwesh wrote:

> Due to a thinko in the patch for bug#77173, Help buffer highlights
> _every_ instance of the word customize in the Help buffer.  To
> reproduce,
>
>   1. emacs -Q
>   2. C-h v icomplete-vertical-selected-prefix-indicator RET
>   3. Witness how the word "customized" in the docstring is partially
>      buttonised.
>
> The attached patch restricts the fontification to the customize blurb.

I had another thinko in the attached patch, in classic fashion (but
worked for some reason).  Please find attached instead.

>From bc9073b9310182649f01609cd263997a858c7c1f Mon Sep 17 00:00:00 2001
From: Visuwesh <[email-masked]>
Date: Mon, 7 Apr 2025 15:16:38 +0530
Subject: [PATCH] Limit fontification of "customize" in setopt suggestion

* lisp/help-fns.el (help-fns--customize-variable): Limit the
fontification to newly inserted text to avoid spurious
fontification of other instances of the word "customize."
---
 lisp/help-fns.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 46316665dda..e330eefbee9 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -1580,7 +1580,9 @@ help-fns--customize-variable
   ;; Make a link to customize if this variable can be customized.
   (when (custom-variable-p variable)
     (let ((customize-label "customize")
-          (custom-set (get variable 'custom-set)))
+          (custom-set (get variable 'custom-set))
+          (opoint (with-current-buffer standard-output
+                    (point))))
       (princ (concat "  You can " customize-label (or text " this variable.")))
       (when (and custom-set
                  ;; Don't override manually written documentation.
@@ -1597,7 +1599,7 @@ help-fns--customize-variable
                         "."))))
       (with-current-buffer standard-output
 	(save-excursion
-          (while (re-search-backward (concat "\\(" customize-label "\\)") nil t)
+          (while (re-search-backward (concat "\\(" customize-label "\\)") opoint t)
 	    (help-xref-button 1 'help-customize-variable variable))))
       (terpri))))
 
-- 
2.47.2