From b381929c9150376e1bc722aa309a9626ef3b394b Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 16 Apr 2022 15:57:33 +0200 Subject: [PATCH] Bind TAB and 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 72b1309cef4..e9a420e92db 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -123,6 +123,13 @@ of 'user-emacs-directory'. * Incompatible changes in Emacs 29.1 +--- +** 'TAB' and '' 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 86cf4a9ae5e..797ef120316 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 + "" #'backward-button) + +(defvar-keymap button-map + :doc "Keymap used by buttons." + :parent button-buffer-map + "RET" #'push-button + "" #'push-button + "" '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! + " " #'push-button + " " #'push-button) (define-minor-mode button-mode "A minor mode for navigating to buttons with the TAB key." -- 2.39.5