File: hydra.el.html

This package can be used to tie related commands into a family of short bindings with a common prefix - a Hydra.

Once you summon the Hydra (through the prefixed binding), all the heads can be called in succession with only a short extension. The Hydra is vanquished once Hercules, any binding that isn't the Hydra's head, arrives. Note that Hercules, besides vanquishing the Hydra, will still serve his original purpose, calling his proper command. This makes the Hydra very seamless, it's like a minor mode that disables itself automagically.

Here's an example Hydra, bound in the global map (you can use any keymap in place of global-map):

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

It allows to start a command chain either like this:
"<f2> gg4ll5g", or "<f2> lgllg".

Here's another approach, when you just want a "callable keymap":

    (defhydra hydra-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"))

This binds nothing so far, but if you follow up with:

    (global-set-key (kbd "C-c C-v") 'hydra-toggle/body)

you will have bound "C-c C-v a", "C-c C-v d" etc.

Knowing that defhydra defines e.g. hydra-toggle/body command, you can nest Hydras if you wish, with hydra-toggle/body possibly becoming a blue head of another Hydra.

If you want to learn all intricacies of using defhydra without having to figure it all out from this source code, check out the wiki: https://github.com/abo-abo/hydra/wiki. There's a wealth of information there. Everyone is welcome to bring the existing pages up to date and add new ones.

Additionally, the file hydra-examples.el serves to demo most of the functionality.

Defined variables (31)

hydra--ignore
hydra--input-method-function
hydra--posframe-timer
hydra--work-around-dedicated
hydra-amaranth-warn-message
hydra-base-map
hydra-cell-format
hydra-curr-body-fn
hydra-curr-foreign-keys
hydra-curr-map
hydra-curr-on-exit
hydra-deactivate
hydra-default-hint
hydra-doc-format-spec
hydra-fontify-head-function
hydra-head-format
hydra-hint-display-alist
hydra-hint-display-type
hydra-is-helpful
hydra-key-doc-function
hydra-key-format-spec
hydra-key-regex
hydra-look-for-remap
hydra-message-timer
hydra-pause-ring
hydra-posframe-show-params
hydra-repeat--command
hydra-repeat--prefix-arg
hydra-timeout-timer
hydra-verbose
hydra-width-spec-regex

Defined functions (71)

defhydra(NAME BODY &optional DOCSTRING &rest HEADS)
defhydra+
defhydradio
hydra--body-exit
hydra--body-foreign-keys
hydra--call-interactively
hydra--call-interactively-remap-maybe
hydra--callablep
hydra--cell
hydra--clearfun
hydra--complain
hydra--cycle-radio
hydra--delete-duplicates
hydra--describe-key
hydra--digit-argument
hydra--doc
hydra--eval-and-format
hydra--format
hydra--format-1
hydra--generate-matrix
hydra--head-has-property
hydra--head-name
hydra--head-property
hydra--head-set-property
hydra--hint
hydra--hint-from-matrix
hydra--hint-from-matrix-1
hydra--hint-heads-wocol
hydra--hint-row
hydra--imf
hydra--make-callable
hydra--make-defun
hydra--make-funcall
hydra--matrix
hydra--negative-argument
hydra--normalize-body
hydra--normalize-heads
hydra--pad
hydra--pad-heads
hydra--prop
hydra--quote-maybe
hydra--radio
hydra--sort-heads
hydra--strip-align-markers
hydra--table
hydra--to-string
hydra--universal-argument
hydra--vconcat
hydra-add-font-lock
hydra-add-imenu
hydra-amaranth-warn
hydra-default-pre
hydra-disable
hydra-fontify-head
hydra-fontify-head-default
hydra-fontify-head-greyscale
hydra-get-property
hydra-idle-message
hydra-interpose
hydra-key-doc-function-default
hydra-keyboard-quit
hydra-multipop
hydra-pause-resume
hydra-plist-get-default
hydra-posframe-show
hydra-repeat
hydra-reset-radios
hydra-set-property
hydra-set-transient-map
hydra-show-hint
hydra-timeout

Defined faces (0)