branch: master commit 7de26d04a6fa27a976d6b4135c8c08dd4c2795bf Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
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