Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Binding style decides how you call a certain hydra's functions. There are two styles with their own advantages and disadvantages. You can decide which one you prefer, and switch easily at any point.
Style 1: don't mess with the prefix
This style does not limit you from binding other commands to the prefix:
(defhydra hydra-zoom (global-map "C-c") "zoom" ("g" text-scale-increase "in") ("l" text-scale-decrease "out"))
It results in the following generated code:
(define-key global-map (kbd "C-c g") 'hydra-zoom/text-scale-increase) (define-key global-map (kbd "C-c l") 'hydra-zoom/text-scale-decrease)
The advantage of this approach is that the C-c isn't taken over, and you can still use e.g.:
(global-set-key (kbd "C-c o") 'occur)
The disadvantage is that you don't get the hydra hint when you press C-c, only after you press either C-c g or C-c l.
Style 2: take over the prefix
This code will exchange the advantage and the disadvantage:
(defhydra hydra-zoom () "zoom" ("g" text-scale-increase "in") ("l" text-scale-decrease "out")) (global-set-key (kbd "C-c") 'hydra-zoom/body)
You'll see the hint as soon as you press C-c. But you won't be able to use the C-c prefix for anything but this hydra. The C-c prefix is chosen here just to show how drastic the decision can be, since the use typically puts many commands on that prefix. However, the following setting can be a nice approach:
(global-set-key (kbd "C-c z") 'hydra-zoom/body)
Unlike C-c, C-c z in an unused prefix. It's OK to have this hydra take it over completely.
Style 1 or 2?
The decision is up to you. Once you're aware of them, you can mix and match them as you see fit.