* hydra.el (hydra-key-format-spec): New defcustom.
(hydra--format): Use `hydra-key-format-spec'. Allow for 0-9 and / in key
bindings.
Here's an example of how to use a flexible format spec for each key:
(let (hydra-key-format-spec)
(defhydra hydra-zoom (global-map "<f2>")
"
zoom: _g_reater _ -5l_esser re_ 7c_enter zer_0_"
("g" text-scale-increase nil)
("l" text-scale-decrease nil)
("c" recenter-top-bottom nil)
("0" (text-scale-set 0) nil :exit t)))
Fixes#50.
* hydra.el (hydra--head-name): New defun.
(hydra--delete-duplicates): New defun.
(defhydra): Update to use `hydra--delete-duplicates' and `hydra--head-name'.
* hydra.el (hydra--format): Improve. No error handling or checking yet,
but should work fine if the docstring is correct.
* hydra-test.el (hydra-format-with-sexp): Add test.
Fixes#42.
* hydra.el (hydra-set-transient-map): Always take 3 arguments.
(hydra--pred): New defun.
(hydra-disable): Update, `overriding-terminal-local-map' is actually
also bound in 24.3.
Fixes#29
* hydra.el (hydra--hint): Process less data.
(hydra--format): Change to add `format'-style width specifiers.
Example:
(defhydra hydra-toggle (:color pink)
"
_a_ abbrev-mode: % 4`abbrev-mode^^^^ _f_ auto-fill-mode: %`auto-fill-function
_d_ debug-on-error: % 4`debug-on-error^ _t_ truncate-lines: %`truncate-lines
_w_ whitespace-mode:% 4`whitespace-mode _g_ golden-ratio-mode: %`golden-ratio-mode
"
("a" abbrev-mode nil)
("d" toggle-debug-on-error nil)
("f" auto-fill-mode nil)
("g" golden-ratio-mode nil)
("t" toggle-truncate-lines nil)
("w" whitespace-mode nil)
("q" nil "quit"))
Here, ^^^ represent empty characters used to compensate for the fact
that the lengths of variable symbols are different.
You can choose not to use them. The result will be the same, but your
code will look misaligned.
Fixes#39.
* hydra.el (hydra--head-color): Adapt compat switches.
(hydra--body-color): Adapt compat switches.
(hydra--handle-nonhead): Move verbatim from `defhydra'.
(defhydra): Move verbatim to `hydra--handle-nonhead'.
* README.md: Update with two tables.
* hydra-test.el: Add compat tests.
New compat switches are:
- ":exit t" for ":color blue"
- ":nonheads warn" for ":color amaranth"
- ":nonheads warn :exit t" for ":color teal"
- ":nonheads run" for ":color pink"
See the compat tests to get the intuition of how both ways translate
between each other.
Fixes#27.
* hydra.el (hydra-face-teal): New face.
(hydra--face): Update.
(defhydra): Teal color is the same as amaranth, except the heas inherit
blue instead of red.
This Hydra can reasonably be either blue or teal:
(global-set-key
(kbd "C-c C-v")
(defhydra hydra-toggle (:color teal)
"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")))
* hydra.el (hydra-face-red): Set default to actual color red.
(hydra-face-blue): Set default to actual color blue.
(hydra-face-amaranth): Explain better in the doc.
(hydra-face-pink): Explain better in the doc.
* hydra.el (hydra--head-color): Rename from `hydra--color'.
(hydra--body-color): New defun.
(hydra--message): First arg isn't pre-processed by `hydra--hint'.
(defhydra): Update call to `hydra-message'.
* hydra.el (hydra--unalias-var): New defun.
(hydra--format): New defun.
(hydra--message): Use `hydra-format' instead of a static string.
Update signature.
(defhydra): Add a warning the pink Hydras can't yet handle unbound
prefix, e.g. "C-x". Update arguments given to `hydra--message'.
* hydra-test.el: Update tests, only hint functions were slightly
affected.
Example of using the newfound functionality:
(defhydra hydra-toggle (:color pink)
"
_a_ abbrev-mode: %`abbrev-mode
_d_ debug-on-error: %`debug-on-error
_f_ auto-fill-mode: %`auto-fill-function
_g_ golden-ratio-mode: %`golden-ratio-mode
_t_ truncate-lines: %`truncate-lines
_w_ whitespace-mode: %`whitespace-mode
"
("a" abbrev-mode nil)
("d" toggle-debug-on-error nil)
("f" auto-fill-mode nil)
("g" golden-ratio-mode nil)
("t" toggle-truncate-lines nil)
("w" whitespace-mode nil)
("q" nil "cancel"))
(global-set-key (kbd "C-c C-v") 'hydra-toggle/body)
Here, "Foo %`abbrev-mode" becomes equivelent to:
(format "Foo %S" abbrev-mode).
And "_a_" becomes equivalent to:
(propertize "a" 'face 'hydra-face-pink).
The hints for all heads except "q" have been set to nil, since their
equivalent is already displayed in the docstring.
* hydra.el (hydra-face-pink): New face.
(hydra--face): Update.
(defhydra): Pink is a variation on amaranth. It still intercepts all
bindings, but will call the intercepted bindings if they're valid.
Re #38.
* lv.el (lv-wnd): New variable.
(lv-window): New defun to get a window similar in properties to Echo Area.
(lv-message): New defun, a replacement for `message', that writes to `lv-window'.
* hydra.el (hydra-lv): New defcustom. If nil, use the Echo Area,
otherwise, use LV.
(hydra-disable): Add optional arg KILL-LV.
(hydra--message): New defun to dispatch on `hydra-lv'.
(hydra--make-defun): Prematurely disable with LV only for blue heads,
since regenerating LV window would cause screen tearing. No need for
timeouts between `message' when using LV. HINT argument is now a
function symbol that returns a string, instead of a plain string.
(defhydra): Generate a new defun with name `NAME/hint'.
* Makefile: Load lv.
* hydra-test.el: Update all tests.
* README.md: Update.
* hydra.el (defhydra): With amaranth body, all heads that aren't blue
become amaranth. Specifying red explicitly does nothing. Add a check and
warn when this happens.
re #29
* hydra.el (hydra--hint): If the HINT part of HEAD is explicitely nil,
omit it from the compound hint.
Example:
(global-set-key
(kbd "C-M-o")
(defhydra hydra-window (:color amaranth)
"window"
("h" windmove-left nil)
("j" windmove-down nil)
("k" windmove-up nil)
("l" windmove-right nil)
("v" (lambda ()
(interactive)
(split-window-right)
(windmove-right))
"vert")
("x" (lambda ()
(interactive)
(split-window-below)
(windmove-down))
"horz")
("q" nil "cancel")))
Here, "h", "j", "k", "l" will not be in the echo area.
* hydra.el (hydra--make-callable): New function.
(defhydra): Use `hydra--make-callable'. Now, head's CMD is either:
command name, nil, a sexp. In case of a sexp, it will be wrapped
unevaluated in an interactive lambda. You can use a `progn' to have many
statements in the sexp.
Fixes#25.
Example:
(defhydra hydra-launcher (:color blue)
"Launch"
("h" man "man")
("r" (browse-url "http://www.reddit.com/r/emacs/") "reddit")
("w" (browse-url "http://www.emacswiki.org/") "emacswiki")
("s" shell "shell")
("q" nil "cancel"))
(global-set-key (kbd "C-c r") 'hydra-launcher/body)