* hydra-init.el: Add bare init.
Now, typing:
make compile
in the hydra repository will start an "emacs -q" with all hydras from
hydra-examples.el defined. Thus you can test that they work for you.
The simplest one is "<f2> g", you can type that in any buffer.
If you want to test with a different version of emacs, just type e.g.:
make compile emacs=emacs24
Re #70.
* 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-ox.el (hydra-ox): New radiogroup.
(hydra-ox-html): New hydra.
(hydra-ox-latex): New hydra.
(hydra-ox-text): New hydra.
(hydra-ox): New hydra that includes the above three hydras.
(org-mode-map): Add test binding.
Re #66.
* hydra.el (hydra-set-transient-map): Avoid compiler warnings.
(hydra--format): Add s? to regex.
- %(test) will translate to (format "%S" (test))
- %s(test) will translate to (format "%s" (test))
The width specifiers should work for both, e.g. % -10(test) or %
-10s(test).
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"))
Fixes#65.
* hydra.el (hydra--make-defun): Call `hydra-timeout' with :timeout if
it's given.
(hydra-timer): New var to hold the timer.
(hydra-timeout): New function to call `hydra-keyboard-quit' with delay.
(hydra-keyboard-quit): Cancel `hydra-timeout' timer.
Re #34.
* 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.el (hydra-repeat): New defun.
(hydra-repeat--command): New defvar.
(hydra-repeat--prefix-arg): New defvar.
Example:
(defhydra hydra-vi ()
"vi"
("h" backward-char)
("j" next-line)
("k" previous-line)
("l" forward-char)
("." hydra-repeat))
(global-set-key (kbd "C-v") 'hydra-vi/body)
"C-v 4l.." will result in movement forward by 4 chars 3 times: first
time from "4l", the other two from "..".
Fixes#59.
* 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 (defhydra): All heads that don't have a hint, will get "" as
hint. The behavior will remain the same.
(hydra--head-property): Simplify, since plist is now always `cdddr'.
(hydra--hint): Simplify, heads always have length at least 3. Simplify,
third element is always a string or nil.
* 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.