Skip to content

Commit 36a1b56

Browse files
committed
Change/Fix: Bind jumper keys using transient suffix
Fixes #95. Thanks to Jimmy Yuen Ho Wong (@wyuenho).
2 parents 78d24cf + ed4f5c4 commit 36a1b56

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

README.org

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ Helm and Ivy are also supported. Note that the =helm= and =ivy= packages are no
138138
*Added*
139139
+ Option =magit-todos-submodule-list= controls whether to-dos in submodules are displayed (default: off). (Thanks to [[https://github.com/matsievskiysv][Matsievskiy S.V.]])
140140

141+
*Internal*
142+
+ Define jumper keys using a Transient suffix.
143+
141144
*** 1.5.3
142145

143146
*Fixes*

magit-todos.el

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
;; Author: Adam Porter <adam@alphapapa.net>
66
;; URL: http://github.com/alphapapa/magit-todos
77
;; Version: 1.6-pre
8-
;; Package-Requires: ((emacs "25.2") (async "1.9.2") (dash "2.13.0") (f "0.17.2") (hl-todo "1.9.0") (magit "2.13.0") (pcre2el "1.8") (s "1.12.0"))
8+
;; Package-Requires: ((emacs "25.2") (async "1.9.2") (dash "2.13.0") (f "0.17.2") (hl-todo "1.9.0") (magit "2.13.0") (pcre2el "1.8") (s "1.12.0") (transient "0.2.0"))
99
;; Keywords: magit, vc
1010

1111
;;; Commentary:
@@ -73,6 +73,7 @@
7373
(require 'f)
7474
(require 'hl-todo)
7575
(require 'magit)
76+
(require 'transient)
7677
(require 'pcre2el)
7778
(require 's)
7879

@@ -117,11 +118,6 @@ This should be set automatically by customizing
117118
Used to avoid running multiple simultaneous scans for a
118119
magit-status buffer.")
119120

120-
;; FIXME: Jumping binds. In `magit-status-mode-map' now, "j" is bound
121-
;; to `magit-status-jump', which is a Transient command; it's no
122-
;; longer bound to a prefix map. There doesn't seem to be a way to
123-
;; add binds to that Transient command's body.
124-
125121
(defvar magit-todos-section-map
126122
(let ((map (make-sparse-keymap)))
127123
(define-key map "jT" #'magit-todos-jump-to-todos)
@@ -373,18 +369,16 @@ from the \"topic2\" branch, this option could be set to
373369
:global t
374370
(if magit-todos-mode
375371
(progn
376-
(pcase (lookup-key magit-status-mode-map "jT")
377-
('nil (define-key magit-status-mode-map "jT" #'magit-todos-jump-to-todos))
378-
('magit-todos-jump-to-todos nil)
379-
(_ (message "magit-todos: Not overriding bind of \"jT\" in `magit-status-mode-map'.")))
372+
(transient-append-suffix #'magit-status-jump
373+
'(0 -1) '[("T" "Todos" magit-todos-jump-to-todos)
374+
("l" "List todos" magit-todos-list)])
380375
(magit-add-section-hook 'magit-status-sections-hook
381376
#'magit-todos--insert-todos
382377
nil
383378
'append)
384379
(add-hook 'magit-status-mode-hook #'magit-todos--add-to-status-buffer-kill-hook 'append))
385380
;; Disable mode
386-
(when (equal (lookup-key magit-status-mode-map "jT") #'magit-todos-jump-to-todos)
387-
(define-key magit-status-mode-map "jT" nil))
381+
(transient-remove-suffix #'magit-status-jump '(0 -1))
388382
(remove-hook 'magit-status-sections-hook #'magit-todos--insert-todos)
389383
(remove-hook 'magit-status-mode-hook #'magit-todos--add-to-status-buffer-kill-hook)))
390384

0 commit comments

Comments
 (0)