* hydra.el (hydra--make-defun): It will receive not the keymap, but the
variable that hold the keymap.
(defhydra): Define keymap as a variable.
* hydra-test.el (hydra-red-error): Update test.
(hydra-blue-toggle): Update test.
(hydra-amaranth-vi): Update test.
(hydra-zoom-duplicate-1): Update test.
(hydra-zoom-duplicate-2): Update test.
* hydra.el (hydra--make-defun): Update.
(hydra--head-name): Change signature, since body is needed to determine
the color. When the head will exit, add "-and-exit" to its name (except
for the nil head and body).
(defhydra): Update the call to `hydra--head-name', since it's not valid
until the head has a hint.
* hydra-test.el (hydra-blue-toggle): Update.
(hydra-amaranth-vi): Update.
(hydra-zoom-duplicate-1): Update.
(hydra-zoom-duplicate-2): Update.
Fixes#84
* hydra.el (hydra--format): Update. Treat variables in the same way as
s-expressions.
* hydra-test.el (hydra-format-2): Add test.
(hydra-format-with-sexp-2): Add test.
Fixes#85
Calling only `hydra-keyboard-quit' on switch-frame event was
effectively stopping the original frame switch. This change adds a
call to the original handler after calling `hydra-keyboard-quit'.
See #73
* hydra.el: Add `hydra--handle-switch-frame'
* hydra-test.el: Update
Fixes#77
* hydra.el (hydra--handle-nonhead): Bind the plain `hydra-keyboard-quit'
only when there's no :post.
(defhydra): When there's :post, add another head for keyboard quit.
* hydra-test.el (hydra-amaranth-vi): Update test.
Fixes#67.
* hydra.el (hydra--pad): New defun.
(hydra--matrix): New defun.
(hydra--cell): New defun.
(hydra--vconcat): New defun.
(hydra-cell-format): New defcustom.
(hydra--table): New defun.
(hydra-reset-radios): New defun.
(defhydra): Allow docstring to be eval-able.
(defhydradio): Don't define `.../reset-radios', instead define
`.../names' that can be passed to `hydra-reset-radios'.
(hydra-multipop): New defmacro.
(hydra--radio): Update the order - the docstring is now a mandatory
second arg, value is the optional third.
* hydra-test.el (defhydradio): Update test.
(hydra--pad): Add test.
(hydra--matrix): Add test.
(hydra--cell): Add test.
(hydra--vconcat): Add test.
(hydra--table): Add test.
* hydra-test.el: Revert tests.
* hydra.el (hydra-exit): Delete, since `hydra-exit' doesn't run :post.
(hydra--delete-duplicates): Simplify.
(defhydra): Simplify.
Hydras with nil body will still not be bound in outside keymaps.
Re #48Fixes#53
* hydra.el (hydra-exit): New command to be used for nil heads.
(hydra--delete-duplicates): Update for `hydra-exit'.
(defhydra): Don't bind `hydra-exit' in outside keymaps.
* hydra-test.el (hydra-blue-toggle): Update test.
(hydra-amaranth-vi): Update test.
Fixes#48.
hydra.el (hydra--delete-duplicates): Modify :cmd-name property of
duplicate head to to name of the head that it duplicates.
Heads are considered duplicate if their CMD and COLOR is the same.
The first of the duplicates gets a defun, the rest call it.
* hydra.el (defhydra): Bring heads into a uniform notation. If a
docstring is missing, set it to "". Set :cmd-name property to the
head's name.
* hydra-test.el: Add tests.
Fixes#52.
* 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--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--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.
* 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 (hydra--make-defun): Take an additional arg to paste as the
last statement.
(defhydra): Set `hydra-foo/body' last statement to
`(setq prefix-arg current-prefix-arg)'.
* hydra-test.el: Update tests.
Example:
(global-set-key
(kbd "C-z")
(defhydra hydra-vi ()
"vi"
("l" forward-char)
("q" nil "quit")))
Now, "C-u C-z l" will result in (forward-char 4). All the other "l" will
normally call (forward-char 1), unless an additional prefix is given.
The previous behavior allowed only for "C-z C-u l" to get
(forward-char 4).
Fixes#21.
* hydra.el (hydra--make-defun): `(catch 'hydra-disable ...)' should
extend thoughout the whole defun. The scope was reduced by mistake
earlier, now restoring.
* hydra-test.el: Update tests.
* hydra.el (hydra-keyboard-quit): New custom var.
(defhydra): Bind `hydra-keyboard-quit' to disable an amaranth Hydra.
* hydra-test.el (hydra-amaranth-vi): Update test.
* hydra.el (defhydra): First disable the transient map, then call red
head, allowing it to throw `hydra-disable' to break, then re-set
transient map.
If the called function raises an error, display this error for a
while, but still set the transient map.
* hydra-test.el: Update test.
Re #15.
* hydra.el (hydra-base-map): Model after `universal-argument-map'; all
Hydra keymaps will inherit from this one.
(hydra-curr-map): Current Hydra keymap. This is necessary for
e.g. `hydra--digit-argument' to return to the orignial keymap.
(hydra--universal-argument): New function.
(hydra--digit-argument): New function.
(hydra--negative-argument): New function.
(hydra--hint): Fix dangling `body-color'.
(defhydra): keymap will inherit `hydra-base-map'.
`hydra-current-map' will be set by red heads. In red heads, make the
function call after `set-transient-map' so that e.g. "Beginning of
buffer" error will not exit the Hydra.
* hydra-test.el: Update tests.
Fixes#13.
* hydra.el (hydra-face-red): New face.
(hydra-face-blue): New face.
(hydra--color): Each head now has a color: red is persistent, blue is
single-use. Head color inherits body color if it's not explicitly
overridden. Body color is red unless explicitly stated.
(hydra--face): Return face that corresponds to color.
(hydra--hint): New function, moved out of `defhydra'.
(hydra-disable): New function, moved out of `defhydra'.
(hydra--doc): New function, moved out of `defhydra'.
(defhydra): Commands that will vanquish the Hydra should be colored with
`hydra-face-blue'. The ones that will make the Hydra persist should be
colored with `hydra-face-red'.
Add autoload, move some code outside, Test HEAD's second element with
`null' instead of `functionp'.
* hydra-test.el (defhydra-red-error): Rename from `defhydra'.
(hydra-blue-toggle): Add test.
* README.md: Update.
Example:
(global-set-key
(kbd "C-c C-v")
(defhydra toggle ()
"toggle"
("t" toggle-truncate-lines "truncate" :color blue)
("f" auto-fill-mode "fill" :color blue)
("a" abbrev-mode "abbrev" :color blue)
("q" nil "cancel")))
Alternatively, since heads inherit color from the body:
(global-set-key
(kbd "C-c C-v")
(defhydra 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")))