hydra 0.5.0
This release introduces colorful Hydra heads. Now, each head is:
- either red - calling this head will not vanquish the Hydra. This is the default one, and
is exactly the same as the previous behavior - or blue - calling this head will vanquish the Hydra.
You can mix-and-match the colors, if you like.
Here's an example of a pure-blue Hydra:
(global-set-key
(kbd "C-c C-v")
(defhydra toggle (:color blue)
"toggle"
("a" abbrev-mode "abbrev")
("d" toggle-debug-on-error "debug")
("f" auto-fill-mode "fill")
("t" toggle-truncate-lines "truncate")
("w" whitespace-mode "whitespace")
("q" nil "cancel")))
Here's an almost all-red Hydra, with one blue head:
(defhydra hydra-error (global-map "M-g")
"goto-error"
("h" first-error "first")
("j" next-error "next")
("k" previous-error "prev")
("v" recenter-top-bottom "recenter")
("q" nil "quit"))
The q became blue, because its function is nil
.
Or, for example, you could make the first head also blue:
(defhydra hydra-error (global-map "M-g")
"goto-error"
("h" first-error "first" :color blue)
("j" next-error "next")
("k" previous-error "prev")
("v" recenter-top-bottom "recenter")
("q" nil "quit"))
The advantages of a pure-blue Hydra over a plain nested keymap:
-
You get a hint straight away, e.g. after C-c C-v
toggle: [a]: abbrev, [d]: debug, [f]: fill, [t]: truncate, [w]: whitespace, [q]: cancel.
-
You can still cancel C-c C-v with any other command.