]> git.eshelyaron.com Git - emacs.git/commitdiff
Add unbuttonize-region
authorRobert Pluim <rpluim@gmail.com>
Wed, 25 Sep 2024 13:49:53 +0000 (15:49 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 14 Oct 2024 17:38:17 +0000 (19:38 +0200)
* doc/lispref/display.texi (Making Buttons): Document it.
* lisp/button.el (unbuttonize-region): New function, removes all
buttons in the specified region.

(cherry picked from commit 08ee074a6f140a82e327fba446c05c96fe64932c)

doc/lispref/display.texi
etc/NEWS
lisp/button.el

index 1362806fee74426286b1fc879d706cae76a14761..4ce7a93a6f087c92301726bdd4b62f4e9ebac8bb 100644 (file)
@@ -7992,6 +7992,11 @@ between @var{start} and @var{end} into a button.  Arguments
 @code{help-echo} property of the button.
 @end defun
 
+@defun unbuttonize-region start end
+This function removes all buttons between @var{start} and @var{end} in
+the current buffer (both overlay and text-property based ones).
+@end defun
+
 @node Manipulating Buttons
 @subsection Manipulating Buttons
 @cindex manipulating buttons
index 7bb4d60ac06935e0d26ae571efebc59bd8e3e74f..4ae09f2f1bb8eac2126da26ef1883288703f42f3 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -174,6 +174,12 @@ When called with a prefix argument, accepting, declining, or tentatively
 accepting an icalendar event will prompt for a comment to add to the
 response.
 
+** Button
+
++++
+*** New function 'unbuttonize-region'.
+It removes all the buttons in the specified region.
+
 ** Eshell
 
 ---
index c05847291729423d86f26653c0215d0322dfe26a..de6ea8d966c14945b60d4dbfaae02cfcb70521bc 100644 (file)
@@ -663,10 +663,22 @@ itself will be used instead as the function argument.
 
 If HELP-ECHO, use that as the `help-echo' property.
 
-Also see `buttonize'."
+Also see `buttonize' and `unbuttonize-region'."
   (add-text-properties start end (button--properties callback data help-echo))
   (add-face-text-property start end 'button t))
 
+(defun unbuttonize-region (start end)
+  "Remove all the buttons between START and END.
+This removes both text-property and overlay based buttons."
+  (dolist (o (overlays-in start end))
+    (when (overlay-get o 'button)
+      (delete-overlay o)))
+  (with-silent-modifications
+    (remove-text-properties start end
+                            (button--properties nil nil nil))
+    (add-face-text-property start end
+                            'button nil)))
+
 (provide 'button)
 
 ;;; button.el ends here