emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master b381929c91 1/2: Bind TAB and <backtab> on buttons


From: Lars Ingebrigtsen
Subject: master b381929c91 1/2: Bind TAB and <backtab> on buttons
Date: Sat, 16 Apr 2022 09:58:39 -0400 (EDT)

branch: master
commit b381929c9150376e1bc722aa309a9626ef3b394b
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Bind TAB and <backtab> on buttons
    
    * lisp/button.el (button-map): Inherit from 'button-buffer-map'.
---
 etc/NEWS       |  7 +++++++
 lisp/button.el | 41 ++++++++++++++++++-----------------------
 2 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 72b1309cef..e9a420e92d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -123,6 +123,13 @@ of 'user-emacs-directory'.
 
 * Incompatible changes in Emacs 29.1
 
+---
+** 'TAB' and '<backtab>' is now bound in 'button-map'.
+This means that if you're standing on a button, 'TAB' will take you to
+the next button, even if the mode has bound it to something else.
+This also means that 'TAB' on a button in an 'outline-minor-mode'
+heading will move point instead of collapsing the outline.
+
 ---
 ** 'Info-default-directory-list' is no longer populated at Emacs startup.
 If you have code in your init file that removes directories from
diff --git a/lisp/button.el b/lisp/button.el
index 86cf4a9ae5..797ef12031 100644
--- a/lisp/button.el
+++ b/lisp/button.el
@@ -55,29 +55,24 @@
   "Default face used for buttons."
   :group 'basic-faces)
 
-(defvar button-map
-  (let ((map (make-sparse-keymap)))
-    ;; The following definition needs to avoid using escape sequences that
-    ;; might get converted to ^M when building loaddefs.el
-    (define-key map [(control ?m)] 'push-button)
-    (define-key map [mouse-2] 'push-button)
-    (define-key map [follow-link] 'mouse-face)
-    ;; FIXME: You'd think that for keymaps coming from text-properties on the
-    ;; mode-line or header-line, the `mode-line' or `header-line' prefix
-    ;; shouldn't be necessary!
-    (define-key map [mode-line mouse-2] 'push-button)
-    (define-key map [header-line mouse-2] 'push-button)
-    map)
-  "Keymap used by buttons.")
-
-(defvar button-buffer-map
-  (let ((map (make-sparse-keymap)))
-    (define-key map [?\t] 'forward-button)
-    (define-key map "\e\t" 'backward-button)
-    (define-key map [backtab] 'backward-button)
-    map)
-  "Keymap useful for buffers containing buttons.
-Mode-specific keymaps may want to use this as their parent keymap.")
+(defvar-keymap button-buffer-map
+  :doc  "Keymap useful for buffers containing buttons.
+Mode-specific keymaps may want to use this as their parent keymap."
+  "TAB" #'forward-button
+  "C-TAB" #'backward-button
+  "<backtab>" #'backward-button)
+
+(defvar-keymap button-map
+  :doc "Keymap used by buttons."
+  :parent button-buffer-map
+  "RET" #'push-button
+  "<mouse-2>" #'push-button
+  "<follow-link>" 'mouse-face
+  ;; FIXME: You'd think that for keymaps coming from text-properties on the
+  ;; mode-line or header-line, the `mode-line' or `header-line' prefix
+  ;; shouldn't be necessary!
+  "<mode-line> <mouse-2>" #'push-button
+  "<header-line> <mouse-2>" #'push-button)
 
 (define-minor-mode button-mode
   "A minor mode for navigating to buttons with the TAB key."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]