[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d41be74 11/17: `hydra/body' will pass the initial `current
From: |
Oleh Krehel |
Subject: |
[elpa] master d41be74 11/17: `hydra/body' will pass the initial `current-prefix-arg' along |
Date: |
Tue, 10 Feb 2015 07:13:26 +0000 |
branch: master
commit d41be74d54aee29a0e9b55ead32960b75d70c438
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
`hydra/body' will pass the initial `current-prefix-arg' along
* 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-test.el | 9 ++++++---
hydra.el | 8 +++++---
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/hydra-test.el b/hydra-test.el
index 4376ab3..f2311ab 100644
--- a/hydra-test.el
+++ b/hydra-test.el
@@ -237,7 +237,8 @@ The body can be accessed via `hydra-error/body'."
(48 . hydra--digit-argument)
(45 . hydra--negative-argument)
(21 . hydra--universal-argument))))
- t))))))))
+ t))
+ (setq prefix-arg current-prefix-arg)))))))
(ert-deftest hydra-blue-toggle ()
(should
@@ -350,7 +351,8 @@ The body can be accessed via `toggle/body'."
(48 . hydra--digit-argument)
(45 . hydra--negative-argument)
(21 . hydra--universal-argument))))
- t))))))))
+ t))
+ (setq prefix-arg current-prefix-arg)))))))
(ert-deftest hydra-amaranth-vi ()
(unless (version< emacs-version "24.4")
@@ -557,7 +559,8 @@ The body can be accessed via `hydra-vi/body'."
(48 . hydra--digit-argument)
(45 . hydra--negative-argument)
(21 .
hydra--universal-argument))))
- t)))))))))
+ t))
+ (setq prefix-arg current-prefix-arg))))))))
(provide 'hydra-test)
diff --git a/hydra.el b/hydra.el
index 86abcfc..e4699ee 100644
--- a/hydra.el
+++ b/hydra.el
@@ -240,7 +240,7 @@ HEADS is a list of heads."
(defun hydra--make-defun (name cmd color
doc hint keymap
- body-color body-pre body-post)
+ body-color body-pre body-post &optional other-post)
"Make a defun wrapper, using NAME, CMD, COLOR, DOC, HINT, and KEYMAP.
BODY-COLOR, BODY-PRE, and BODY-POST are used as well."
`(defun ,name ()
@@ -268,7 +268,8 @@ BODY-COLOR, BODY-PRE, and BODY-POST are used as well."
(setq hydra-curr-map ',keymap)
t
,@(if (and (not (eq body-color 'amaranth))
body-post)
- `((lambda () ,body-post)))))))))))
+ `((lambda () ,body-post)))))
+ ,other-post))))))
;;* Macros
;;** hydra-create
@@ -417,7 +418,8 @@ in turn can be either red or blue."
(error "Invalid :bind property %S" head))))))
heads names))
,(hydra--make-defun body-name nil nil doc hint keymap
- body-color body-pre body-post))))
+ body-color body-pre body-post
+ '(setq prefix-arg current-prefix-arg)))))
(provide 'hydra)
- [elpa] master updated (61bddf2 -> 11b130e), Oleh Krehel, 2015/02/10
- [elpa] master b65db57 02/17: Update :post for amaranth Hydras, Oleh Krehel, 2015/02/10
- [elpa] master 9991985 01/17: hydra-test.el: update the test to not fail for older Emacs, Oleh Krehel, 2015/02/10
- [elpa] master 1660d71 05/17: Allow :pre and :post to be function symbols, Oleh Krehel, 2015/02/10
- [elpa] master 7ead8db 06/17: hydra.el (defhydra): Declare indent 2, Oleh Krehel, 2015/02/10
- [elpa] master 1b1d31d 07/17: Support local hydra heads, Oleh Krehel, 2015/02/10
- [elpa] master 9a8e2f1 04/17: hydra.el (hydra-keyboard-quit): New custom var, Oleh Krehel, 2015/02/10
- [elpa] master 9b31ead 08/17: Update semantics for local heads to `:bind nil', Oleh Krehel, 2015/02/10
- [elpa] master 969fa66 10/17: fix typo - single not singe, Oleh Krehel, 2015/02/10
- [elpa] master d41be74 11/17: `hydra/body' will pass the initial `current-prefix-arg' along,
Oleh Krehel <=
- [elpa] master ad771a4 03/17: Move defun-creating code into a defun, Oleh Krehel, 2015/02/10
- [elpa] master 763bb2a 13/17: Allow lambda :bind property for body and heads, Oleh Krehel, 2015/02/10
- [elpa] master 0712a43 12/17: README.md: update, Oleh Krehel, 2015/02/10
- [elpa] master d10c26e 14/17: Update comments and mark the old examples obsolete, Oleh Krehel, 2015/02/10
- [elpa] master 0c08964 16/17: README.md: update, Oleh Krehel, 2015/02/10
- [elpa] master 4ca646e 15/17: Allow a sexp as head's CMD paramater, Oleh Krehel, 2015/02/10
- [elpa] master bb01930 09/17: Fix "catch 'hydra-disable", Oleh Krehel, 2015/02/10
- [elpa] master 11b130e 17/17: Merge commit '0c08964462812942db51d177e6ea922b26019e65' from hydra, Oleh Krehel, 2015/02/10