aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorKévin Le Gouguec2025-02-20 22:37:13 +0100
committerKévin Le Gouguec2025-03-08 17:29:34 +0100
commitf23ee932509e0a67aaafc499f0cd6b25535e4b95 (patch)
tree4d9127f6b4b6813c11d9c95c461af30c41e66f37 /lisp
parent269d337f9191cb58e70f93f8aae47a9bd8d635f9 (diff)
downloademacs-f23ee932509e0a67aaafc499f0cd6b25535e4b95.tar.gz
emacs-f23ee932509e0a67aaafc499f0cd6b25535e4b95.zip
Prevent button.el from clearing help-echo strings
In order to fix one of the issues discussed in bug#61413, i.e. 'buttonize' clobbering the help-echo property set by 'icon-string'. This is a reasonable interpretation of the button.el docstrings - "if HELP-ECHO, use that as the `help-echo' property"; conversely, if not HELP-ECHO, then do not do anything, preserving existing values for that property. * lisp/button.el (button--properties): Only add a help-echo property if HELP-ECHO is non-nil. Add an additional property for bookkeeping. (unbuttonize-region): Check for that bookkeeping property before clearing help-echo. * test/lisp/button-tests.el (button--preserve-help-echo): Validate these changes.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/button.el32
1 files changed, 21 insertions, 11 deletions
diff --git a/lisp/button.el b/lisp/button.el
index 674de1bb4fa..58f00c4c2ad 100644
--- a/lisp/button.el
+++ b/lisp/button.el
@@ -652,15 +652,19 @@ Also see `buttonize-region'."
652 string)) 652 string))
653 653
654(defun button--properties (callback data help-echo) 654(defun button--properties (callback data help-echo)
655 (list 'font-lock-face 'button 655 (append
656 'mouse-face 'highlight 656 (list 'font-lock-face 'button
657 'help-echo help-echo 657 'mouse-face 'highlight
658 'button t 658 'button t
659 'follow-link t 659 'follow-link t
660 'category t 660 'category t
661 'button-data data 661 'button-data data
662 'keymap button-map 662 'keymap button-map
663 'action callback)) 663 'action callback)
664 (and help-echo
665 (list 'help-echo help-echo
666 ;; Record that button.el is responsible for this property.
667 'help-echo-button t))))
664 668
665(defun buttonize-region (start end callback &optional data help-echo) 669(defun buttonize-region (start end callback &optional data help-echo)
666 "Make the region between START and END into a button. 670 "Make the region between START and END into a button.
@@ -681,8 +685,14 @@ This removes both text-property and overlay based buttons."
681 (when (overlay-get o 'button) 685 (when (overlay-get o 'button)
682 (delete-overlay o))) 686 (delete-overlay o)))
683 (with-silent-modifications 687 (with-silent-modifications
684 (remove-text-properties start end 688 (remove-text-properties
685 (button--properties nil nil nil)) 689 start end
690 (append
691 (button--properties nil nil nil)
692 ;; Only remove help-echo if it was added by button.el.
693 (and (get-text-property start 'help-echo-button)
694 (list 'help-echo nil
695 'help-echo-button nil))))
686 (add-face-text-property start end 696 (add-face-text-property start end
687 'button nil))) 697 'button nil)))
688 698