mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
Add new function buttonize-region
* lisp/button.el (buttonize-region): New function. (button--properties): Factored out. (buttonize): Use it.
This commit is contained in:
parent
5ad6a08a2e
commit
d71ee07852
2 changed files with 27 additions and 10 deletions
4
etc/NEWS
4
etc/NEWS
|
|
@ -1377,6 +1377,10 @@ functions.
|
|||
|
||||
* Lisp Changes in Emacs 29.1
|
||||
|
||||
+++
|
||||
** New convenience function 'buttonize-region'.
|
||||
This works like 'buttonize', but for a region instead of a string.
|
||||
|
||||
+++
|
||||
** 'macroexp-let2*' can omit 'test' arg and use single-var bindings.
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue