summaryrefslogtreecommitdiff
path: root/lisp/button.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-04-16 15:57:33 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-04-16 15:57:33 +0200
commitb381929c9150376e1bc722aa309a9626ef3b394b (patch)
tree643dd897b0e290339759d40b2791aaae2bcc853e /lisp/button.el
parentdcbef9045f0d5427470d660d240d1e6d5cf97663 (diff)
downloademacs-b381929c9150376e1bc722aa309a9626ef3b394b.tar.gz
emacs-b381929c9150376e1bc722aa309a9626ef3b394b.tar.bz2
emacs-b381929c9150376e1bc722aa309a9626ef3b394b.zip
Bind TAB and <backtab> on buttons
* lisp/button.el (button-map): Inherit from 'button-buffer-map'.
Diffstat (limited to 'lisp/button.el')
-rw-r--r--lisp/button.el41
1 files changed, 18 insertions, 23 deletions
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
+ "<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."