[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 1290237 12/18: Disable key-chord for the duration of the h
From: |
Oleh Krehel |
Subject: |
[elpa] master 1290237 12/18: Disable key-chord for the duration of the hydra |
Date: |
Sat, 28 Mar 2015 15:04:27 +0000 |
branch: master
commit 12902375f334584c3187f121a5bbad91a2fc9721
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Disable key-chord for the duration of the hydra
* hydra.el (hydra--input-method-function): New defvar.
(hydra-default-pre): Disable key-chord.
(hydra-cleanup): Re-enable key-chord.
(hydra--make-defun): Call `hydra-default-pre' for each head.
Fixes #97
---
hydra-test.el | 24 ++++++++++++++++++++++--
hydra.el | 14 ++++++++++++++
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/hydra-test.el b/hydra-test.el
index 35e65bb..86aa2fb 100644
--- a/hydra-test.el
+++ b/hydra-test.el
@@ -48,6 +48,7 @@ The body can be accessed via `hydra-error/body'.
Call the head: `first-error'."
(interactive)
+ (hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (prog1 t (call-interactively (function
first-error)))
@@ -100,6 +101,7 @@ The body can be accessed via `hydra-error/body'.
Call the head: `next-error'."
(interactive)
+ (hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (prog1 t (call-interactively (function
next-error)))
@@ -152,6 +154,7 @@ The body can be accessed via `hydra-error/body'.
Call the head: `previous-error'."
(interactive)
+ (hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (prog1 t (call-interactively (function
previous-error)))
@@ -220,6 +223,7 @@ Call the head: `previous-error'."
The body can be accessed via `hydra-error/body'."
(interactive)
+ (hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(when hydra-is-helpful (hydra-error/hint))
@@ -280,6 +284,7 @@ The body can be accessed via `hydra-toggle/body'.
Call the head: `toggle-truncate-lines'."
(interactive)
+ (hydra-default-pre)
(hydra-disable)
(hydra-cleanup)
(catch (quote hydra-disable)
@@ -295,6 +300,7 @@ The body can be accessed via `hydra-toggle/body'.
Call the head: `auto-fill-mode'."
(interactive)
+ (hydra-default-pre)
(hydra-disable)
(hydra-cleanup)
(catch (quote hydra-disable)
@@ -310,6 +316,7 @@ The body can be accessed via `hydra-toggle/body'.
Call the head: `abbrev-mode'."
(interactive)
+ (hydra-default-pre)
(hydra-disable)
(hydra-cleanup)
(catch (quote hydra-disable)
@@ -325,6 +332,7 @@ The body can be accessed via `hydra-toggle/body'.
Call the head: `nil'."
(interactive)
+ (hydra-default-pre)
(hydra-disable)
(hydra-cleanup)
(catch (quote hydra-disable)))
@@ -346,6 +354,7 @@ Call the head: `nil'."
The body can be accessed via `hydra-toggle/body'."
(interactive)
+ (hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(when hydra-is-helpful (hydra-toggle/hint))
@@ -410,6 +419,7 @@ The body can be accessed via `hydra-vi/body'.
Call the head: `hydra-keyboard-quit'."
(interactive)
+ (hydra-default-pre)
(set-cursor-color "#e52b50")
(hydra-disable)
(hydra-cleanup)
@@ -427,6 +437,7 @@ The body can be accessed via `hydra-vi/body'.
Call the head: `next-line'."
(interactive)
+ (hydra-default-pre)
(set-cursor-color "#e52b50")
(hydra-disable)
(catch (quote hydra-disable)
@@ -484,6 +495,7 @@ The body can be accessed via `hydra-vi/body'.
Call the head: `previous-line'."
(interactive)
+ (hydra-default-pre)
(set-cursor-color "#e52b50")
(hydra-disable)
(catch (quote hydra-disable)
@@ -541,6 +553,7 @@ The body can be accessed via `hydra-vi/body'.
Call the head: `nil'."
(interactive)
+ (hydra-default-pre)
(set-cursor-color "#e52b50")
(hydra-disable)
(hydra-cleanup)
@@ -562,6 +575,7 @@ Call the head: `nil'."
The body can be accessed via `hydra-vi/body'."
(interactive)
+ (hydra-default-pre)
(set-cursor-color "#e52b50")
(hydra-disable)
(catch (quote hydra-disable)
@@ -902,10 +916,11 @@ The body can be accessed via `hydra-zoom/body'.
Call the head: `(text-scale-set 0)'."
(interactive)
+ (hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (prog1 t (call-interactively (function
(lambda nil (interactive)
-
(text-scale-set 0)))))
+
(text-scale-set 0)))))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))
@@ -951,11 +966,12 @@ The body can be accessed via `hydra-zoom/body'.
Call the head: `(text-scale-set 0)'."
(interactive)
+ (hydra-default-pre)
(hydra-disable)
(hydra-cleanup)
(catch (quote hydra-disable)
(call-interactively (function (lambda nil (interactive)
- (text-scale-set 0))))))
+ (text-scale-set 0))))))
(defun hydra-zoom/hint nil
(if hydra-lv (lv-message (format #("zoom: [r 0]: reset." 7 8 (face
hydra-face-red)
9 10 (face hydra-face-blue))))
@@ -969,6 +985,7 @@ Call the head: `(text-scale-set 0)'."
The body can be accessed via `hydra-zoom/body'."
(interactive)
+ (hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(when hydra-is-helpful (hydra-zoom/hint))
@@ -1024,6 +1041,7 @@ The body can be accessed via `hydra-zoom/body'.
Call the head: `(text-scale-set 0)'."
(interactive)
+ (hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(condition-case err (prog1 t (call-interactively (function
(lambda nil (interactive)
@@ -1073,6 +1091,7 @@ The body can be accessed via `hydra-zoom/body'.
Call the head: `(text-scale-set 0)'."
(interactive)
+ (hydra-default-pre)
(hydra-disable)
(hydra-cleanup)
(catch (quote hydra-disable)
@@ -1091,6 +1110,7 @@ Call the head: `(text-scale-set 0)'."
The body can be accessed via `hydra-zoom/body'."
(interactive)
+ (hydra-default-pre)
(hydra-disable)
(catch (quote hydra-disable)
(when hydra-is-helpful (hydra-zoom/hint))
diff --git a/hydra.el b/hydra.el
index f203283..51b9139 100644
--- a/hydra.el
+++ b/hydra.el
@@ -376,8 +376,21 @@ BODY is the second argument to `defhydra'"
(teal 'hydra-face-teal)
(t (error "Unknown color for %S" h))))
+(defvar hydra--input-method-function nil
+ "Store overridden `input-method-function' here.")
+
+(defun hydra-default-pre ()
+ "Default setup that happens in each head before :pre."
+ (when (eq input-method-function 'key-chord-input-method)
+ (unless hydra--input-method-function
+ (setq hydra--input-method-function input-method-function)
+ (setq input-method-function nil))))
+
(defun hydra-cleanup ()
"Clean up after a Hydra."
+ (when hydra--input-method-function
+ (setq input-method-function hydra--input-method-function)
+ (setq hydra--input-method-function nil))
(when (window-live-p lv-wnd)
(let ((buf (window-buffer lv-wnd)))
(delete-window lv-wnd)
@@ -574,6 +587,7 @@ OTHER-POST is an optional extension to the :post key of
BODY."
`(defun ,name ()
,doc
(interactive)
+ (hydra-default-pre)
,@(when body-pre (list body-pre))
(hydra-disable)
,@(when (memq color '(blue teal)) '((hydra-cleanup)))
- [elpa] master 84f4fe7 06/18: Don't default `hydra-repeat--prefix-arg' to 1, (continued)
- [elpa] master 84f4fe7 06/18: Don't default `hydra-repeat--prefix-arg' to 1, Oleh Krehel, 2015/03/28
- [elpa] master 6c6fc0b 07/18: Allow `hydra-repeat' to take a numeric arg, Oleh Krehel, 2015/03/28
- [elpa] master 87e4574 05/18: Mention the leading newline in `defhydra' docstring, Oleh Krehel, 2015/03/28
- [elpa] master 71491b9 04/18: Fix argument to `replace-match', Oleh Krehel, 2015/03/28
- [elpa] master f6697f3 02/18: Allow for the "%s`foo" spec., Oleh Krehel, 2015/03/28
- [elpa] master 5c3ab46 08/18: hydra.el (hydra--format): Amend regex, Oleh Krehel, 2015/03/28
- [elpa] master 1bad0c4 09/18: hydra.el (hydra--format): Update regex order, Oleh Krehel, 2015/03/28
- [elpa] master 03771f4 01/18: hydra.el: Turn on lexical-binding, Oleh Krehel, 2015/03/28
- [elpa] master fe1cfee 10/18: hydra-examples.el (hydra-rectangle): Update, Oleh Krehel, 2015/03/28
- [elpa] master c8c6b8c 03/18: Fix blue/red heads with same cmd, Oleh Krehel, 2015/03/28
- [elpa] master 1290237 12/18: Disable key-chord for the duration of the hydra,
Oleh Krehel <=
- [elpa] master cb4b78a 11/18: hydra-test.el (hydra-format-4): Add test, Oleh Krehel, 2015/03/28
- [elpa] master 640af46 13/18: hydra.el (defhydra): Improve docstring, Oleh Krehel, 2015/03/28
- [elpa] master 7843563 14/18: hydra.el (hydra--make-funcall): Add, Oleh Krehel, 2015/03/28
- [elpa] master e403363 16/18: hydra.el (defhydra): Avoid eager macroexpansion failure, Oleh Krehel, 2015/03/28
- [elpa] master 5032ec7 15/18: hydra.el (defhydra): Simplify and improve the key binding code, Oleh Krehel, 2015/03/28
- [elpa] master 4a6a31d 17/18: hydra.el: Bump version, Oleh Krehel, 2015/03/28
- [elpa] master da45e68 18/18: Merge commit '4a6a31d6d4d479720f4b66091892b0cda2377346' from hydra, Oleh Krehel, 2015/03/28