4

I use Hydra, and find it very useful. However, I often find that I can only remember the key to trigger the hydra itself, but can't remember which keys are used for the "heads".

Luckily, Hydra will give me a nicely formatted list of the keys and the commands they will trigger.

enter image description here

However, I can only seem to get this list of hints to come up once I have already successfully triggered one of the commands listed - this requires that I remember how to trigger at least one of the heads, which is sometimes not the case.

Is there any way to have the hints show up immediately? That is, if I have the following hydra:

(defhydra hydra-transpose (global-map "C-t")
  "transposing hydra"
  ("l" transpose-lines "lines")
  ("w" transpose-words "words")
  ("s" transpose-sexps "sexps")
  ("p" transpose-paragraphs "paragraphs")
  ("c" transpose-chars "characters")
  ("w" transpose-frame "windows")
  )

How can I get it to show me hints as soon as I hit C-t? The documentation seems to suggest that this is possible:

Assign a custom hint to this group of functions, so that you know immediately after pressing C-c that you can follow up with j or k.

But I have not yet been able to figure out how to accomplish this by reading the documentation, or by exploring the different hydra variables and functions. Does anyone know if this is possible/how to achieve it?

4

Here's how to do it:

(defhydra hydra-transpose ()
  "transposing hydra"
  ("l" transpose-lines "lines")
  ("w" transpose-words "words")
  ("s" transpose-sexps "sexps")
  ("p" transpose-paragraphs "paragraphs")
  ("c" transpose-chars "characters")
  ("w" transpose-frame "windows"))
(global-set-key (kbd "C-t") 'hydra-transpose/body)

See the documentation for more info.

  • Aha! I didn't think about using this style. I didn't consider the fact that using the other style (the style in my question), when I hit C-t, I haven't actually finished the command, and so of course the hints don't show up! Using this style solves the problem. Thanks! – elethan Jan 11 '16 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.