3 (ert-deftest defhydra ()
7 '(defhydra hydra-error (global-map "M-g")
9 ("h" first-error "first")
10 ("j" next-error "next")
11 ("k" previous-error "prev")))
13 (defun hydra-error/first-error ()
14 "Create a hydra with a \"M-g\" body and the heads:
18 \"k\": `previous-error'
20 The body can be accessed via `hydra-error/body'.
22 Call the head: `first-error'."
24 (call-interactively #'first-error)
25 (when hydra-is-helpful
26 (message #("error: [h]: first, [j]: next, [k]: prev."
27 8 9 (face font-lock-keyword-face)
28 20 21 (face font-lock-keyword-face)
29 31 32 (face font-lock-keyword-face))))
31 (hydra-set-transient-map
33 (107 . hydra-error/previous-error)
34 (106 . hydra-error/next-error)
35 (104 . hydra-error/first-error)) t)))
37 (defun hydra-error/next-error ()
38 "Create a hydra with a \"M-g\" body and the heads:
42 \"k\": `previous-error'
44 The body can be accessed via `hydra-error/body'.
46 Call the head: `next-error'."
48 (call-interactively #'next-error)
49 (when hydra-is-helpful
50 (message #("error: [h]: first, [j]: next, [k]: prev."
51 8 9 (face font-lock-keyword-face)
52 20 21 (face font-lock-keyword-face)
53 31 32 (face font-lock-keyword-face))))
55 (hydra-set-transient-map
57 (107 . hydra-error/previous-error)
58 (106 . hydra-error/next-error)
59 (104 . hydra-error/first-error)) t)))
61 (defun hydra-error/previous-error ()
62 "Create a hydra with a \"M-g\" body and the heads:
66 \"k\": `previous-error'
68 The body can be accessed via `hydra-error/body'.
70 Call the head: `previous-error'."
72 (call-interactively #'previous-error)
73 (when hydra-is-helpful
74 (message #("error: [h]: first, [j]: next, [k]: prev."
75 8 9 (face font-lock-keyword-face)
76 20 21 (face font-lock-keyword-face)
77 31 32 (face font-lock-keyword-face))))
79 (hydra-set-transient-map
81 (107 . hydra-error/previous-error)
82 (106 . hydra-error/next-error)
83 (104 . hydra-error/first-error)) t)))
85 (unless (keymapp (lookup-key global-map (kbd "M-g")))
86 (define-key global-map (kbd "M-g") nil))
87 (define-key global-map [134217831 104] #'hydra-error/first-error)
88 (define-key global-map [134217831 106] #'hydra-error/next-error)
89 (define-key global-map [134217831 107] #'hydra-error/previous-error)
91 (defun hydra-error/body ()
92 "Create a hydra with a \"M-g\" body and the heads:
96 \"k\": `previous-error'
98 The body can be accessed via `hydra-error/body'."
100 (when hydra-is-helpful
101 (message #("error: [h]: first, [j]: next, [k]: prev."
102 8 9 (face font-lock-keyword-face)
103 20 21 (face font-lock-keyword-face)
104 31 32 (face font-lock-keyword-face))))
106 (hydra-set-transient-map
108 (107 . hydra-error/previous-error)
109 (106 . hydra-error/next-error)
110 (104 . hydra-error/first-error)) t)))))))
112 (provide 'hydra-test)