(or emacs irrelevant)

Hydra 0.12.0 is out

With a month's time and almost 50 commits since that last one, a new version of Hydra has emerged. As usual, I'll just re-state the release notes.

Fixes

  • Handling of heads with duplicate cmd was improved.
  • Don't bind nil in outside keymaps.
  • Work-around golden-ratio-mode in lv-window.
  • C-g (hydra-keyboard-quit) should run :post.
  • Bind [switch-frame] to hydra-keyboard-quit.
  • :post is called for :timeout.

New Features

  • hydra-key-format-spec is a new defcustom for the keys format in the docstring. It's "%s" by default, but you can set it to e.g. "%-4s" if you like.
  • The key regex was extended to include most common key binding characters.
  • hydra-repeat is a hydra-specific repeat function. It behaves as you would expect repeat to behave.
  • New body option - :timeout. Use e.g. :timeout 2.0 to set the timer. After the first head is called, a timer is started to disable the hydra. Each new head call resets this timer, so the hydra won't disappear as long as you keep typing.
  • Lines are truncated in lv-message. This is useful for large docstring not to become misaligned when the window becomes too small.

Allow for a %s(test) spec in the docstring

The spec that's used for e.g. (test) is %S. So if (test) returns a string, it will be quoted. This may not be desired, hence the new feature. Example:

(defhydra hydra-marked-items (dired-mode-map "")
  "
Number of marked items: %(length (dired-get-marked-files))
Directory size: %s(shell-command-to-string \"du -hs\")
"
  ("m" dired-mark "mark"))

The pink/amaranth override is set recursively

This fixes the issue in this hydra:

(defhydra hydra-test (:color amaranth)
  "foo"
  ("fo" (message "yay"))
  ("q" nil))

Before, pressing e.g. fp would not issue a warning, since f started its own keymap. This is now fixed.

An option to specify the hint for all heads in body

When you write a large docstring, you usually pass nil as the hint for most heads. Now you can omit it, if you set :hint nil in body. Example:

(defhydra hydra-org-template (:color blue :hint nil)
  "
_c_enter  _q_uote    _L_aTeX:
_l_atex   _e_xample  _i_ndex:
_a_scii   _v_erse    _I_NCLUDE:
_s_rc     ^ ^        _H_TML:
_h_tml    ^ ^        _A_SCII:
"
  ("s" (hot-expand "<s"))
  ("e" (hot-expand "<e"))
  ("q" (hot-expand "<q"))
  ("v" (hot-expand "<v"))
  ("c" (hot-expand "<c"))
  ("l" (hot-expand "<l"))
  ("h" (hot-expand "<h"))
  ("a" (hot-expand "<a"))
  ("L" (hot-expand "<L"))
  ("i" (hot-expand "<i"))
  ("I" (hot-expand "<I"))
  ("H" (hot-expand "<H"))
  ("A" (hot-expand "<A"))
  ("<" self-insert-command "ins")
  ("o" nil "quit"))

Emulate org-mode export dispatch with hydra-ox

You can also look at that code to see how nested hydras work. Several other examples were added to hydra-examples.el.

Outro

I hope that you enjoy all the new features/fixes, and thanks to all the people that contributed to them. Happy hacking!