]> git.eshelyaron.com Git - emacs.git/commitdiff
Remove buttons when disabling 'button-mode'
authorRobert Pluim <rpluim@gmail.com>
Wed, 25 Sep 2024 14:52:57 +0000 (16:52 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 14 Oct 2024 17:38:18 +0000 (19:38 +0200)
* lisp/button.el (button-mode): Remove all buttons when disabling.
* doc/lispref/display.texi (Button Buffer Commands): Document
the change.  (Bug#73175)

(cherry picked from commit e631a3f30679d3c4e465a5765e261b068e9357dc)

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

index 4ce7a93a6f087c92301726bdd4b62f4e9ebac8bb..668cc224b2f16c80243400f4672071123cf1fbf8 100644 (file)
@@ -8077,6 +8077,7 @@ These are commands and functions for locating and operating on
 buttons in an Emacs buffer.
 
 @cindex buffer-button-map
+@findex button-mode
 @code{push-button} is the command that a user uses to actually push
 a button, and is bound by default in the button itself to @key{RET}
 and to @key{mouse-2} using a local keymap in the button's overlay or
@@ -8087,7 +8088,8 @@ additionally available in the keymap stored in
 @code{button-buffer-map} as a parent keymap for its keymap.
 Alternatively, the @code{button-mode} can be switched on for much the
 same effect: It's a minor mode that does nothing else than install
-@code{button-buffer-map} as a minor mode keymap.
+@code{button-buffer-map} as a minor mode keymap (note that disabling
+@code{button-mode} will remove all the buttons in the current buffer).
 
 If the button has a non-@code{nil} @code{follow-link} property, and
 @code{mouse-1-click-follows-link} is set, a quick @key{mouse-1} click
index 4ae09f2f1bb8eac2126da26ef1883288703f42f3..6646d253c949344368e0964a73599e226910b92d 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -180,6 +180,9 @@ response.
 *** New function 'unbuttonize-region'.
 It removes all the buttons in the specified region.
 
++++
+*** Disabling 'button-mode' now removes all buttons in the current buffer.
+
 ** Eshell
 
 ---
index de6ea8d966c14945b60d4dbfaae02cfcb70521bc..1a732bee98b2b85d22c9923191b33ecb2830c359 100644 (file)
@@ -80,8 +80,15 @@ Mode-specific keymaps may want to use this as their parent keymap."
   "<touchscreen-down>" #'push-button)
 
 (define-minor-mode button-mode
-  "A minor mode for navigating to buttons with the TAB key."
-  :keymap button-buffer-map)
+  "A minor mode for navigating to buttons with the TAB key.
+
+Disabling the mode will remove all buttons in the current buffer."
+  :keymap button-buffer-map
+  (when (not button-mode)
+    (save-excursion
+      (save-restriction
+        (widen)
+        (unbuttonize-region (point-min) (point-max))))))
 
 ;; Default properties for buttons.
 (put 'default-button 'face 'button)