[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 7de26d0 64/72: Add `hydra-repeat': hydra-specific `repeat'
From: |
Oleh Krehel |
Subject: |
[elpa] master 7de26d0 64/72: Add `hydra-repeat': hydra-specific `repeat' |
Date: |
Fri, 06 Mar 2015 13:04:23 +0000 |
branch: master
commit 7de26d04a6fa27a976d6b4135c8c08dd4c2795bf
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Add `hydra-repeat': hydra-specific `repeat'
* 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.el | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/hydra.el b/hydra.el
index 6959cc9..24d194c 100644
--- a/hydra.el
+++ b/hydra.el
@@ -215,6 +215,21 @@ Vanquishable only through a blue head.")
(interactive "P")
(let ((universal-argument-map hydra-curr-map))
(negative-argument arg)))
+;;* Repeat
+(defvar hydra-repeat--prefix-arg nil
+ "Prefix arg to use with `hydra-repeat'.")
+
+(defvar hydra-repeat--command nil
+ "Command to use with `hydra-repeat'.")
+
+(defun hydra-repeat ()
+ "Repeat last command with last prefix arg."
+ (interactive)
+ (unless (string-match "hydra-repeat$" (symbol-name last-command))
+ (setq hydra-repeat--command last-command)
+ (setq hydra-repeat--prefix-arg (or last-prefix-arg 1)))
+ (setq current-prefix-arg hydra-repeat--prefix-arg)
+ (funcall hydra-repeat--command))
;;* Misc internals
(defvar hydra-last nil
- [elpa] master 0f733d8 37/72: Add an option to fontify heads in a custom way, (continued)
- [elpa] master 0f733d8 37/72: Add an option to fontify heads in a custom way, Oleh Krehel, 2015/03/06
- [elpa] master c413b5f 54/72: Allow for a custom key format spec in docstrings, Oleh Krehel, 2015/03/06
- [elpa] master 54004d2 52/72: hydra.el (hydra-verbose): New defcustom, Oleh Krehel, 2015/03/06
- [elpa] master 0d9c95e 47/72: Update README.md, Oleh Krehel, 2015/03/06
- [elpa] master 3c06695 56/72: Amend the key regex in docstring to include <>, Oleh Krehel, 2015/03/06
- [elpa] master e567bd6 59/72: lv.el (lv-window): set-window-parameter 'no-other-window, Oleh Krehel, 2015/03/06
- [elpa] master eb1e0fc 58/72: Don't bind nil heads in outside keymaps, Oleh Krehel, 2015/03/06
- [elpa] master 41ec124 50/72: Avoid generating multiple defuns with same name, Oleh Krehel, 2015/03/06
- [elpa] master db0415e 49/72: hydra.el (hydra-keyboard-quit): Add, Oleh Krehel, 2015/03/06
- [elpa] master 55682e7 57/72: Improve handling of heads with duplicate cmd, Oleh Krehel, 2015/03/06
- [elpa] master 7de26d0 64/72: Add `hydra-repeat': hydra-specific `repeat',
Oleh Krehel <=
- [elpa] master f231dc0 55/72: Simplify the hint part of each head, Oleh Krehel, 2015/03/06
- [elpa] master 764f4b6 67/72: hydra.el (hydra--format): Amend key regex, Oleh Krehel, 2015/03/06
- [elpa] master 8e90037 65/72: Add some features for generating tables, Oleh Krehel, 2015/03/06
- [elpa] master 3040f45 61/72: hydra.el (hydra--format): Amend key regex, Oleh Krehel, 2015/03/06
- [elpa] master e1e2e3e 69/72: lv.el (lv-window): Bind `golden-ratio-mode' to nil, Oleh Krehel, 2015/03/06
- [elpa] master 8dec3cd 70/72: Allow for a %s(test) spec in docstring, Oleh Krehel, 2015/03/06
- [elpa] master 9fc928b 63/72: hydra.el (hydra--format): Amend key regex, Oleh Krehel, 2015/03/06
- [elpa] master 989ed95 53/72: Rename compat toggle - :nonheads -> :foreign-keys, Oleh Krehel, 2015/03/06
- [elpa] master 9c68e0a 68/72: Add :timeout option to hydra body, Oleh Krehel, 2015/03/06
- [elpa] master e342c33 71/72: hydra-ox.el: Emulate org-mode export dispatch, Oleh Krehel, 2015/03/06