]> code.delx.au - gnu-emacs-elpa/commit
Distinguish red and blue hydra heads
authorOleh Krehel <ohwoeowho@gmail.com>
Sun, 1 Feb 2015 17:43:44 +0000 (18:43 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Sun, 1 Feb 2015 20:30:27 +0000 (21:30 +0100)
commit6f142e342a4228640cb50a45e224f932679355bb
tree052d59252fb337c04d1128810cee7606447ef9f5
parentb359db633e46987c9107e89199717c2194b9a045
Distinguish red and blue hydra heads

* hydra.el (hydra-face-red): New face.
(hydra-face-blue): New face.

(hydra--color): Each head now has a color: red is persistent, blue is
single-use. Head color inherits body color if it's not explicitly
overridden. Body color is red unless explicitly stated.

(hydra--face): Return face that corresponds to color.
(hydra--hint): New function, moved out of `defhydra'.
(hydra-disable): New function, moved out of `defhydra'.
(hydra--doc): New function, moved out of `defhydra'.

(defhydra): Commands that will vanquish the Hydra should be colored with
`hydra-face-blue'. The ones that will make the Hydra persist should be
colored with `hydra-face-red'.
Add autoload, move some code outside, Test HEAD's second element with
`null' instead of `functionp'.

* hydra-test.el (defhydra-red-error): Rename from `defhydra'.
(hydra-blue-toggle): Add test.

* README.md: Update.

Example:

    (global-set-key
     (kbd "C-c C-v")
     (defhydra toggle ()
       "toggle"
       ("t" toggle-truncate-lines "truncate" :color blue)
       ("f" auto-fill-mode "fill" :color blue)
       ("a" abbrev-mode "abbrev" :color blue)
       ("q" nil "cancel")))

Alternatively, since heads inherit color from the body:

    (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")))
README.md
hydra-test.el
hydra.el