diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/button.el | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/lisp/button.el b/lisp/button.el index 8a7751d00da..86cf4a9ae5e 100644 --- a/lisp/button.el +++ b/lisp/button.el @@ -626,16 +626,29 @@ function argument. If DATA isn't present (or is nil), the button itself will be used instead as the function argument. If HELP-ECHO, use that as the `help-echo' property." - (propertize string - 'face 'button - 'mouse-face 'highlight - 'help-echo help-echo - 'button t - 'follow-link t - 'category t - 'button-data data - 'keymap button-map - 'action callback)) + (apply #'propertize string + (button--properties callback data help-echo))) + +(defun button--properties (callback data help-echo) + (list 'face 'button + 'font-lock-face 'button + 'mouse-face 'highlight + 'help-echo help-echo + 'button t + 'follow-link t + 'category t + 'button-data data + 'keymap button-map + 'action callback)) + +(defun buttonize-region (start end callback &optional data help-echo) + "Make the region between START and END into a button. +When clicked, CALLBACK will be called with the DATA as the +function argument. If DATA isn't present (or is nil), the button +itself will be used instead as the function argument. + +If HELP-ECHO, use that as the `help-echo' property." + (add-text-properties start end (button--properties callback data help-echo))) (provide 'button) |