[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 9a8e2f1 04/17: hydra.el (hydra-keyboard-quit): New custom
From: |
Oleh Krehel |
Subject: |
[elpa] master 9a8e2f1 04/17: hydra.el (hydra-keyboard-quit): New custom var |
Date: |
Tue, 10 Feb 2015 07:13:23 +0000 |
branch: master
commit 9a8e2f10f0f14fa4ba637bde6fd76a606ffaedde
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
hydra.el (hydra-keyboard-quit): New custom var
* 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-test.el | 136 ++++++++++++++++++++++++++++++++-------------------------
hydra.el | 16 ++++++-
2 files changed, 90 insertions(+), 62 deletions(-)
diff --git a/hydra-test.el b/hydra-test.el
index 57409fd..5e7c0d4 100644
--- a/hydra-test.el
+++ b/hydra-test.el
@@ -361,7 +361,8 @@ The body can be accessed via `toggle/body'."
("j" next-line)
("k" previous-line)
("q" nil "quit")))
- '(progn (defun hydra-vi/forward-char nil "Create a hydra with no body
and the heads:
+ '(progn
+ (defun hydra-vi/forward-char nil "Create a hydra with no body and the
heads:
\"l\": `forward-char',
\"h\": `backward-char',
@@ -372,61 +373,64 @@ The body can be accessed via `toggle/body'."
The body can be accessed via `hydra-vi/body'.
Call the head: `forward-char'."
- (interactive)
- (set-cursor-color "#e52b50")
- (catch (quote hydra-disable)
- (hydra-disable)
- (condition-case err (prog1 t (call-interactively
(function forward-char)))
- ((debug error)
- (message "%S" err)
- (sit-for 0.8)
- nil)))
- (when hydra-is-helpful (message #("vi: l, h, j, k, [q]:
quit." 4 5 (face hydra-face-amaranth)
- 7 8 (face
hydra-face-amaranth)
- 10 11 (face
hydra-face-amaranth)
- 13 14 (face
hydra-face-amaranth)
- 17 18 (face
hydra-face-blue))))
- (setq hydra-last
- (hydra-set-transient-map
- (setq hydra-curr-map
- (quote (keymap (t lambda nil (interactive)
- (message "An amaranth
Hydra can only exit through a blue head")
- (hydra-set-transient-map
hydra-curr-map t)
- (when hydra-is-helpful
(sit-for 0.8)
- (message #("vi: l,
h, j, k, [q]: quit." 4 5 (face hydra-face-amaranth)
- 7 8 (face
hydra-face-amaranth)
- 10 11
(face hydra-face-amaranth)
- 13 14
(face hydra-face-amaranth)
- 17 18
(face hydra-face-blue)))))
- (113 . hydra-vi/nil)
- (107 . hydra-vi/previous-line)
- (106 . hydra-vi/next-line)
- (104 . hydra-vi/backward-char)
- (108 . hydra-vi/forward-char)
- (kp-subtract .
hydra--negative-argument)
- (kp-9 . hydra--digit-argument)
- (kp-8 . hydra--digit-argument)
- (kp-7 . hydra--digit-argument)
- (kp-6 . hydra--digit-argument)
- (kp-5 . hydra--digit-argument)
- (kp-4 . hydra--digit-argument)
- (kp-3 . hydra--digit-argument)
- (kp-2 . hydra--digit-argument)
- (kp-1 . hydra--digit-argument)
- (kp-0 . hydra--digit-argument)
- (57 . hydra--digit-argument)
- (56 . hydra--digit-argument)
- (55 . hydra--digit-argument)
- (54 . hydra--digit-argument)
- (53 . hydra--digit-argument)
- (52 . hydra--digit-argument)
- (51 . hydra--digit-argument)
- (50 . hydra--digit-argument)
- (49 . hydra--digit-argument)
- (48 . hydra--digit-argument)
- (45 .
hydra--negative-argument)
- (21 .
hydra--universal-argument))))
- t)))
+ (interactive)
+ (set-cursor-color "#e52b50")
+ (catch (quote hydra-disable)
+ (hydra-disable)
+ (condition-case err (prog1 t (call-interactively (function
forward-char)))
+ ((debug error)
+ (message "%S" err)
+ (sit-for 0.8)
+ nil)))
+ (when hydra-is-helpful (message #("vi: l, h, j, k, [q]: quit."
4 5 (face hydra-face-amaranth)
+ 7 8 (face hydra-face-amaranth)
+ 10 11 (face
hydra-face-amaranth)
+ 13 14 (face
hydra-face-amaranth)
+ 17 18 (face
hydra-face-blue))))
+ (setq hydra-last
+ (hydra-set-transient-map
+ (setq hydra-curr-map
+ (quote (keymap (7 lambda nil (interactive)
+ (hydra-disable)
+ (set-cursor-color "#ffffff"))
+ (t lambda nil (interactive)
+ (message "An amaranth Hydra can
only exit through a blue head")
+ (hydra-set-transient-map
hydra-curr-map t)
+ (when hydra-is-helpful (sit-for
0.8)
+ (message #("vi: l, h, j,
k, [q]: quit." 4 5 (face hydra-face-amaranth)
+ 7 8 (face
hydra-face-amaranth)
+ 10 11 (face
hydra-face-amaranth)
+ 13 14 (face
hydra-face-amaranth)
+ 17 18 (face
hydra-face-blue)))))
+ (113 . hydra-vi/nil)
+ (107 . hydra-vi/previous-line)
+ (106 . hydra-vi/next-line)
+ (104 . hydra-vi/backward-char)
+ (108 . hydra-vi/forward-char)
+ (kp-subtract .
hydra--negative-argument)
+ (kp-9 . hydra--digit-argument)
+ (kp-8 . hydra--digit-argument)
+ (kp-7 . hydra--digit-argument)
+ (kp-6 . hydra--digit-argument)
+ (kp-5 . hydra--digit-argument)
+ (kp-4 . hydra--digit-argument)
+ (kp-3 . hydra--digit-argument)
+ (kp-2 . hydra--digit-argument)
+ (kp-1 . hydra--digit-argument)
+ (kp-0 . hydra--digit-argument)
+ (57 . hydra--digit-argument)
+ (56 . hydra--digit-argument)
+ (55 . hydra--digit-argument)
+ (54 . hydra--digit-argument)
+ (53 . hydra--digit-argument)
+ (52 . hydra--digit-argument)
+ (51 . hydra--digit-argument)
+ (50 . hydra--digit-argument)
+ (49 . hydra--digit-argument)
+ (48 . hydra--digit-argument)
+ (45 . hydra--negative-argument)
+ (21 . hydra--universal-argument))))
+ t)))
(defun hydra-vi/backward-char nil "Create a hydra with no body and the
heads:
\"l\": `forward-char',
@@ -455,7 +459,10 @@ Call the head: `backward-char'."
(setq hydra-last
(hydra-set-transient-map
(setq hydra-curr-map
- (quote (keymap (t lambda nil (interactive)
+ (quote (keymap (7 lambda nil (interactive)
+ (hydra-disable)
+ (set-cursor-color "#ffffff"))
+ (t lambda nil (interactive)
(message "An amaranth Hydra can
only exit through a blue head")
(hydra-set-transient-map
hydra-curr-map t)
(when hydra-is-helpful (sit-for
0.8)
@@ -521,7 +528,10 @@ Call the head: `next-line'."
(setq hydra-last
(hydra-set-transient-map
(setq hydra-curr-map
- (quote (keymap (t lambda nil (interactive)
+ (quote (keymap (7 lambda nil (interactive)
+ (hydra-disable)
+ (set-cursor-color "#ffffff"))
+ (t lambda nil (interactive)
(message "An amaranth Hydra can
only exit through a blue head")
(hydra-set-transient-map
hydra-curr-map t)
(when hydra-is-helpful (sit-for
0.8)
@@ -587,7 +597,10 @@ Call the head: `previous-line'."
(setq hydra-last
(hydra-set-transient-map
(setq hydra-curr-map
- (quote (keymap (t lambda nil (interactive)
+ (quote (keymap (7 lambda nil (interactive)
+ (hydra-disable)
+ (set-cursor-color "#ffffff"))
+ (t lambda nil (interactive)
(message "An amaranth Hydra can
only exit through a blue head")
(hydra-set-transient-map
hydra-curr-map t)
(when hydra-is-helpful (sit-for
0.8)
@@ -659,7 +672,10 @@ The body can be accessed via `hydra-vi/body'."
(setq hydra-last
(hydra-set-transient-map
(setq hydra-curr-map
- (quote (keymap (t lambda nil (interactive)
+ (quote (keymap (7 lambda nil (interactive)
+ (hydra-disable)
+ (set-cursor-color "#ffffff"))
+ (t lambda nil (interactive)
(message "An amaranth Hydra can
only exit through a blue head")
(hydra-set-transient-map
hydra-curr-map t)
(when hydra-is-helpful (sit-for
0.8)
diff --git a/hydra.el b/hydra.el
index b070e21..89f21d8 100644
--- a/hydra.el
+++ b/hydra.el
@@ -80,6 +80,11 @@
:type 'boolean
:group 'hydra)
+(defcustom hydra-keyboard-quit ""
+ "This binding will quit an amaranth Hydra.
+It's the only other way to quit it besides though a blue head.
+It's possible to set this to nil.")
+
(defface hydra-face-red
'((t (:foreground "#7F0055" :bold t)))
"Red Hydra heads will persist indefinitely."
@@ -277,7 +282,8 @@ It defaults to `global-set-key'.
When `(keymapp METHOD)`, it becomes:
(lambda (key command) (define-key METHOD key command))"
- (declare (indent 1))
+ (declare (indent 1)
+ (obsolete defhydra "0.8.0"))
`(defhydra ,(intern
(concat
"hydra-" (replace-regexp-in-string " " "_" body)))
@@ -358,7 +364,13 @@ in turn can be either red or blue."
(when hydra-is-helpful
(sit-for 0.8)
(message ,hint))))
- (error "An amaranth Hydra must have at least one blue head in order to
exit")))
+ (error "An amaranth Hydra must have at least one blue head in order to
exit"))
+ (when hydra-keyboard-quit
+ (define-key keymap hydra-keyboard-quit
+ `(lambda ()
+ (interactive)
+ (hydra-disable)
+ ,body-post))))
`(progn
,@(cl-mapcar
(lambda (head name)
- [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 <=
- [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, 2015/02/10
- [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