Skip to content
Oleh Krehel edited this page Mar 11, 2015 · 1 revision

Using the functions generated by defhydra

If you define a simple hydra like this:

(defhydra hydra-zoom (global-map "<f2>")
  "zoom"
  ("g" text-scale-increase "in")
  ("l" text-scale-decrease "out"))

You can bind it to a key chord like this:

(key-chord-define-global "tt" 'hydra-zoom/body)

In fact, since defhydra returns the body symbol, you can even write it like this:

(key-chord-define-global
 "tt"
 (defhydra hydra-zoom (global-map "<f2>")
  "zoom"
  ("g" text-scale-increase "in")
  ("l" text-scale-decrease "out")))

If you like key chords so much that you don't want to touch the global map at all, you can e.g.:

(key-chord-define-global
 "hh"
 (defhydra hydra-error ()
   "goto-error"
   ("h" first-error "first")
   ("j" next-error "next")
   ("k" previous-error "prev")))

You can also substitute global-map with any other keymap, like c++-mode-map or yas-minor-mode-map.

See the introductory blog post for more information.

Clone this wiki locally