GNU ELPA - hydra

hydra

Description
Make bindings that stick around.
Latest
hydra-0.15.0.tar (.sig), 2024-Mar-31, 90.0 KiB
Maintainer
Oleh Krehel <ohwoeowho@gmail.com>
Atom feed
hydra.xml
Website
https://github.com/abo-abo/hydra
Browse ELPA's repository
CGit or Gitweb
Badge

To install this package from Emacs, use package-install or list-packages.

Full description

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 orignal 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.

Old versions

hydra-0.14.0.tar.lz2017-Jul-2229.0 KiB
hydra-0.13.5.tar.lz2016-Mar-0516.9 KiB
hydra-0.13.4.tar.lz2015-Dec-0824.7 KiB
hydra-0.13.3.tar.lz2015-Oct-1724.6 KiB
hydra-0.13.2.tar.lz2015-May-0222.7 KiB
hydra-0.13.1.tar.lz2015-Apr-1721.9 KiB
hydra-0.12.1.tar.lz2015-Mar-2921.4 KiB
hydra-0.11.0.tar.lz2015-Mar-0718.9 KiB
hydra-0.9.0.tar.lz2015-Feb-1010.8 KiB
hydra-0.8.0.tar.lz2015-Feb-098.82 KiB
hydra-0.6.1.tar.lz2015-Feb-057.22 KiB
hydra-0.5.0.tar.lz2015-Feb-046.41 KiB
hydra-0.3.1.tar.lz2015-Jan-253.65 KiB
hydra-0.3.0.tar.lz2015-Jan-222.87 KiB

News

1. 0.15.0

1.1. New Features

1.1.1. defhydra
  1. New :base-map option in body plist

    In case your hydra conficts with el:hydra-base-map, you can now override it.

    Example:

    (defhydra hydra-numbers (:base-map (make-sparse-keymap))
      "test"
      ("0" (message "zero"))
      ("1" (message "one")))
    

    See #285.

  2. Make no docstring equivalent to :hint nil

    Example:

    (defhydra hydra-clock (:color blue)
      ("q" nil "quit" :column "Clock")
      ("c" org-clock-cancel "cancel" :color pink :column "Do")
      ("d" org-clock-display "display")
      ("e" org-clock-modify-effort-estimate "effort")
      ("i" org-clock-in "in")
      ("j" org-clock-goto "jump")
      ("o" org-clock-out "out")
      ("r" org-clock-report "report"))
    

    See #291.

  3. Declare /params and /docstring

    See #185.

  4. Sexp hints are now supported for :columns

    Example

    (defhydra hydra-test ()
      "Test"
      ("j" next-line (format-time-string "%H:%M:%S" (current-time)) :column "One")
      ("k" previous-line (format-time-string "%H:%M:%S" (current-time)))
      ("l" backward-char "back" :column "Two"))
    

    See #311.

1.1.2. defhydra+

New macro. Allows to add heads to an existing hydra.

Example:

(defhydra hydra-extendable ()
  "extendable"
  ("j" next-line "down"))

(defhydra+ hydra-extendable ()
  ("k" previous-line "up"))

See #185.

1.1.3. el:hydra-hint-display-type

Customize what to use to display the hint:

  • el:message
  • el:lv-message
  • posframe

el:hydra-lv is now obsolete. See #317.