diff options
| author | Kévin Le Gouguec | 2025-02-20 22:37:13 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec | 2025-03-08 17:29:34 +0100 |
| commit | f23ee932509e0a67aaafc499f0cd6b25535e4b95 (patch) | |
| tree | 4d9127f6b4b6813c11d9c95c461af30c41e66f37 /test | |
| parent | 269d337f9191cb58e70f93f8aae47a9bd8d635f9 (diff) | |
| download | emacs-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 'test')
| -rw-r--r-- | test/lisp/button-tests.el | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/lisp/button-tests.el b/test/lisp/button-tests.el index 7f6a5bd52cd..b784cf02e28 100644 --- a/test/lisp/button-tests.el +++ b/test/lisp/button-tests.el | |||
| @@ -101,4 +101,32 @@ | |||
| 101 | (setq button (insert-button "overlay" 'help-echo help)) | 101 | (setq button (insert-button "overlay" 'help-echo help)) |
| 102 | (should (equal (button--help-echo button) "overlay: x"))))) | 102 | (should (equal (button--help-echo button) "overlay: x"))))) |
| 103 | 103 | ||
| 104 | (ert-deftest button--preserve-help-echo () | ||
| 105 | "Ensure buttonizing functions preserve existing `help-echo' properties." | ||
| 106 | ;; buttonize. | ||
| 107 | (let* ((string (propertize "button text" 'help-echo "help text")) | ||
| 108 | (button (buttonize string #'ignore))) | ||
| 109 | (should (equal (get-text-property 0 'help-echo button) | ||
| 110 | "help text"))) | ||
| 111 | ;; buttonize-region. | ||
| 112 | (with-temp-buffer | ||
| 113 | (insert (propertize "button text" 'help-echo "help text")) | ||
| 114 | (buttonize-region (point-min) (point) #'ignore) | ||
| 115 | (should (equal (get-text-property (point-min) 'help-echo) | ||
| 116 | "help text")) | ||
| 117 | ;; unbuttonize-region should not clear the property either. | ||
| 118 | (unbuttonize-region (point-min) (point)) | ||
| 119 | (should (equal (get-text-property (point-min) 'help-echo) | ||
| 120 | "help text"))) | ||
| 121 | ;; unbuttonize-region should still clear properties applied with | ||
| 122 | ;; buttonize. | ||
| 123 | (with-temp-buffer | ||
| 124 | (insert "button text") | ||
| 125 | (buttonize-region (point-min) (point) #'ignore nil "help text") | ||
| 126 | (should (equal (get-text-property (point-min) 'help-echo) | ||
| 127 | "help text")) | ||
| 128 | (unbuttonize-region (point-min) (point)) | ||
| 129 | (should (equal (get-text-property (point-min) 'help-echo) | ||
| 130 | nil)))) | ||
| 131 | |||
| 104 | ;;; button-tests.el ends here | 132 | ;;; button-tests.el ends here |