From: Robert Pluim Date: Wed, 25 Sep 2024 14:52:57 +0000 (+0200) Subject: Remove buttons when disabling 'button-mode' X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=782a90f7c934c9e5e539e90515b522fa3e2dab17;p=emacs.git Remove buttons when disabling 'button-mode' * 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) --- diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 4ce7a93a6f0..668cc224b2f 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -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 diff --git a/etc/NEWS b/etc/NEWS index 4ae09f2f1bb..6646d253c94 100644 --- 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 --- diff --git a/lisp/button.el b/lisp/button.el index de6ea8d966c..1a732bee98b 100644 --- a/lisp/button.el +++ b/lisp/button.el @@ -80,8 +80,15 @@ Mode-specific keymaps may want to use this as their parent keymap." "" #'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)