[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master f01c87e 38/45: Fix red heads not exiting temporarily
From: |
Oleh Krehel |
Subject: |
[elpa] master f01c87e 38/45: Fix red heads not exiting temporarily |
Date: |
Thu, 16 Apr 2015 12:45:55 +0000 |
branch: master
commit f01c87e37c9646a3b32fbe1c390c6f94b8c153a8
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Fix red heads not exiting temporarily
* hydra.el (hydra--ignore): New defvar.
(hydra-disable): Don't call :post unless `hydra--ignore' is nil.
(hydra--make-defun): Temporarily disable transient map before calling
the command.
Fixes #109
---
hydra-test.el | 24 ++++++++++++++++++++++++
hydra.el | 40 +++++++++++++++++++++++-----------------
2 files changed, 47 insertions(+), 17 deletions(-)
diff --git a/hydra-test.el b/hydra-test.el
index 267ccad..7d361e6 100644
--- a/hydra-test.el
+++ b/hydra-test.el
@@ -104,6 +104,8 @@ The body can be accessed via `hydra-error/body'.
Call the head: `first-error'."
(interactive)
(hydra-default-pre)
+ (let ((hydra--ignore t))
+ (hydra-keyboard-quit))
(condition-case err
(progn
(setq this-command
@@ -138,6 +140,8 @@ The body can be accessed via `hydra-error/body'.
Call the head: `next-error'."
(interactive)
(hydra-default-pre)
+ (let ((hydra--ignore t))
+ (hydra-keyboard-quit))
(condition-case err
(progn
(setq this-command
@@ -172,6 +176,8 @@ The body can be accessed via `hydra-error/body'.
Call the head: `previous-error'."
(interactive)
(hydra-default-pre)
+ (let ((hydra--ignore t))
+ (hydra-keyboard-quit))
(condition-case err
(progn
(setq this-command
@@ -229,6 +235,8 @@ Call the head: `previous-error'."
The body can be accessed via `hydra-error/body'."
(interactive)
(hydra-default-pre)
+ (let ((hydra--ignore nil))
+ (hydra-keyboard-quit))
(when hydra-is-helpful
(if hydra-lv
(lv-message
@@ -397,6 +405,8 @@ Call the head: `nil'."
The body can be accessed via `hydra-toggle/body'."
(interactive)
(hydra-default-pre)
+ (let ((hydra--ignore nil))
+ (hydra-keyboard-quit))
(when hydra-is-helpful
(if hydra-lv
(lv-message
@@ -481,6 +491,8 @@ Call the head: `next-line'."
(interactive)
(hydra-default-pre)
(set-cursor-color "#e52b50")
+ (let ((hydra--ignore t))
+ (hydra-keyboard-quit))
(condition-case err
(progn
(setq this-command
@@ -514,6 +526,8 @@ Call the head: `previous-line'."
(interactive)
(hydra-default-pre)
(set-cursor-color "#e52b50")
+ (let ((hydra--ignore t))
+ (hydra-keyboard-quit))
(condition-case err
(progn
(setq this-command
@@ -568,6 +582,8 @@ The body can be accessed via `hydra-vi/body'."
(interactive)
(hydra-default-pre)
(set-cursor-color "#e52b50")
+ (let ((hydra--ignore nil))
+ (hydra-keyboard-quit))
(when hydra-is-helpful
(if hydra-lv
(lv-message
@@ -651,6 +667,8 @@ The body can be accessed via `hydra-zoom/body'.
Call the head: `(text-scale-set 0)'."
(interactive)
(hydra-default-pre)
+ (let ((hydra--ignore t))
+ (hydra-keyboard-quit))
(condition-case err
(call-interactively
(function
@@ -708,6 +726,8 @@ Call the head: `(text-scale-set 0)'."
The body can be accessed via `hydra-zoom/body'."
(interactive)
(hydra-default-pre)
+ (let ((hydra--ignore nil))
+ (hydra-keyboard-quit))
(when hydra-is-helpful
(if hydra-lv
(lv-message
@@ -792,6 +812,8 @@ The body can be accessed via `hydra-zoom/body'.
Call the head: `(text-scale-set 0)'."
(interactive)
(hydra-default-pre)
+ (let ((hydra--ignore t))
+ (hydra-keyboard-quit))
(condition-case err
(call-interactively
(function
@@ -849,6 +871,8 @@ Call the head: `(text-scale-set 0)'."
The body can be accessed via `hydra-zoom/body'."
(interactive)
(hydra-default-pre)
+ (let ((hydra--ignore nil))
+ (hydra-keyboard-quit))
(when hydra-is-helpful
(if hydra-lv
(lv-message
diff --git a/hydra.el b/hydra.el
index 970716f..e370dbc 100644
--- a/hydra.el
+++ b/hydra.el
@@ -120,6 +120,9 @@ warn: keep KEYMAP and issue a warning instead of running
the command."
(t nil)))))
(hydra-disable)))
+(defvar hydra--ignore nil
+ "When non-nil, don't call `hydra-curr-on-exit'")
+
(defun hydra-disable ()
"Disable the current Hydra."
(remove-hook 'pre-command-hook 'hydra--clearfun)
@@ -127,10 +130,11 @@ warn: keep KEYMAP and issue a warning instead of running
the command."
(with-selected-frame frame
(when overriding-terminal-local-map
(internal-pop-keymap hydra-curr-map 'overriding-terminal-local-map)
- (when hydra-curr-on-exit
- (let ((on-exit hydra-curr-on-exit))
- (setq hydra-curr-on-exit nil)
- (funcall on-exit)))))))
+ (unless hydra--ignore
+ (when hydra-curr-on-exit
+ (let ((on-exit hydra-curr-on-exit))
+ (setq hydra-curr-on-exit nil)
+ (funcall on-exit))))))))
(unless (fboundp 'internal-push-keymap)
(defun internal-push-keymap (keymap symbol)
@@ -563,25 +567,27 @@ BODY-AFTER-EXIT is added to the end of the wrapper."
`(,(hydra--call-interactively cmd (cadr head))))))
(delq
nil
- `(,(when cmd
+ `((let ((hydra--ignore ,(not (eq (cadr head) 'body))))
+ (hydra-keyboard-quit))
+ ,(when cmd
`(condition-case err
,(hydra--call-interactively cmd (cadr head))
((quit error)
(message "%S" err)
(unless hydra-lv
(sit-for 0.8)))))
- (when hydra-is-helpful
- (if hydra-lv
- (lv-message (eval ,hint))
- (message (eval ,hint))))
- (hydra-set-transient-map
- ,keymap
- (lambda () (hydra-keyboard-quit) ,body-before-exit)
- ,(when body-foreign-keys
- (list 'quote body-foreign-keys)))
- ,body-after-exit
- ,(when body-timeout
- `(hydra-timeout ,body-timeout))))))))
+ (when hydra-is-helpful
+ (if hydra-lv
+ (lv-message (eval ,hint))
+ (message (eval ,hint))))
+ (hydra-set-transient-map
+ ,keymap
+ (lambda () (hydra-keyboard-quit) ,body-before-exit)
+ ,(when body-foreign-keys
+ (list 'quote body-foreign-keys)))
+ ,body-after-exit
+ ,(when body-timeout
+ `(hydra-timeout ,body-timeout))))))))
(defmacro hydra--make-funcall (sym)
"Transform SYM into a `funcall' to call it."
- [elpa] master 51e7753 19/45: Alias :post to :before-exit, and add :after-exit, (continued)
- [elpa] master 51e7753 19/45: Alias :post to :before-exit, and add :after-exit, Oleh Krehel, 2015/04/16
- [elpa] master 3d7d8c7 20/45: Add basic error handling, Oleh Krehel, 2015/04/16
- [elpa] master 684f8a2 39/45: Add integration test for red hydras temporarily exiting, Oleh Krehel, 2015/04/16
- [elpa] master d3d435d 25/45: Finalize head inheritance, Oleh Krehel, 2015/04/16
- [elpa] master b2c9ea6 36/45: README.md: Update intro, Oleh Krehel, 2015/04/16
- [elpa] master d678cc0 34/45: Work around `overriding-terminal-local-map' being terminal-local, Oleh Krehel, 2015/04/16
- [elpa] master d6e00ed 33/45: README.md: Add video demo link, Oleh Krehel, 2015/04/16
- [elpa] master 97c9b9b 32/45: Move `this-command' setter, Oleh Krehel, 2015/04/16
- [elpa] master 60ce256 41/45: Add an idle message timeout option, Oleh Krehel, 2015/04/16
- [elpa] master 99b2aea 35/45: hydra.el (hydra--format): Match alnum for the "_..._" syntax, Oleh Krehel, 2015/04/16
- [elpa] master f01c87e 38/45: Fix red heads not exiting temporarily,
Oleh Krehel <=
- [elpa] master f972634 45/45: Merge commit '742d66a63e86ac740e610faa5abba97e7f8ad5c2' from hydra, Oleh Krehel, 2015/04/16
- [elpa] master aeaabd3 42/45: hydra.el (defhydra): Re-throw a caught error when debug-on-error, Oleh Krehel, 2015/04/16
- [elpa] master 742d66a 44/45: hydra.el: Bump version, Oleh Krehel, 2015/04/16
- [elpa] master 09b63b5 43/45: Don't re-activate key chords too early, Oleh Krehel, 2015/04/16
- [elpa] master cab5a73 37/45: README.md: Update `hydra-zoom/body', Oleh Krehel, 2015/04/16
- [elpa] master 00aef59 40/45: hydra.el (hydra--format): Fix "s-t" issue, Oleh Krehel, 2015/04/16