[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 97c9b9b 32/45: Move `this-command' setter
From: |
Oleh Krehel |
Subject: |
[elpa] master 97c9b9b 32/45: Move `this-command' setter |
Date: |
Thu, 16 Apr 2015 12:45:52 +0000 |
branch: master
commit 97c9b9b64c59e2b4314cef62549ebac3ad8c140e
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Move `this-command' setter
* hydra.el (hydra--call-interactively): New defun.
(hydra--make-defun): Update.
Re #79
---
hydra-test.el | 90 ++++++++++++++++++++++++++++++--------------------------
hydra.el | 29 ++++++++++++------
2 files changed, 67 insertions(+), 52 deletions(-)
diff --git a/hydra-test.el b/hydra-test.el
index 28b4519..267ccad 100644
--- a/hydra-test.el
+++ b/hydra-test.el
@@ -105,8 +105,11 @@ Call the head: `first-error'."
(interactive)
(hydra-default-pre)
(condition-case err
- (call-interactively
- (function first-error))
+ (progn
+ (setq this-command
+ (quote first-error))
+ (call-interactively
+ (function first-error)))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
@@ -121,9 +124,7 @@ Call the head: `first-error'."
(lambda nil
(hydra-keyboard-quit)
nil)
- nil)
- (setq this-command
- (quote first-error)))
+ nil))
(defun hydra-error/next-error nil
"Create a hydra with a \"M-g\" body and the heads:
@@ -138,8 +139,11 @@ Call the head: `next-error'."
(interactive)
(hydra-default-pre)
(condition-case err
- (call-interactively
- (function next-error))
+ (progn
+ (setq this-command
+ (quote next-error))
+ (call-interactively
+ (function next-error)))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
@@ -154,9 +158,7 @@ Call the head: `next-error'."
(lambda nil
(hydra-keyboard-quit)
nil)
- nil)
- (setq this-command
- (quote next-error)))
+ nil))
(defun hydra-error/previous-error nil
"Create a hydra with a \"M-g\" body and the heads:
@@ -171,8 +173,11 @@ Call the head: `previous-error'."
(interactive)
(hydra-default-pre)
(condition-case err
- (call-interactively
- (function previous-error))
+ (progn
+ (setq this-command
+ (quote previous-error))
+ (call-interactively
+ (function previous-error)))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
@@ -187,9 +192,7 @@ Call the head: `previous-error'."
(lambda nil
(hydra-keyboard-quit)
nil)
- nil)
- (setq this-command
- (quote previous-error)))
+ nil))
(unless (keymapp
(lookup-key
global-map
@@ -315,11 +318,12 @@ Call the head: `toggle-truncate-lines'."
(interactive)
(hydra-default-pre)
(hydra-keyboard-quit)
- (call-interactively
- (function
- toggle-truncate-lines))
- (setq this-command
- (quote toggle-truncate-lines)))
+ (progn
+ (setq this-command
+ (quote toggle-truncate-lines))
+ (call-interactively
+ (function
+ toggle-truncate-lines))))
(defun hydra-toggle/auto-fill-mode-and-exit nil
"Create a hydra with no body and the heads:
@@ -334,10 +338,11 @@ Call the head: `auto-fill-mode'."
(interactive)
(hydra-default-pre)
(hydra-keyboard-quit)
- (call-interactively
- (function auto-fill-mode))
- (setq this-command
- (quote auto-fill-mode)))
+ (progn
+ (setq this-command
+ (quote auto-fill-mode))
+ (call-interactively
+ (function auto-fill-mode))))
(defun hydra-toggle/abbrev-mode-and-exit nil
"Create a hydra with no body and the heads:
@@ -352,10 +357,11 @@ Call the head: `abbrev-mode'."
(interactive)
(hydra-default-pre)
(hydra-keyboard-quit)
- (call-interactively
- (function abbrev-mode))
- (setq this-command
- (quote abbrev-mode)))
+ (progn
+ (setq this-command
+ (quote abbrev-mode))
+ (call-interactively
+ (function abbrev-mode))))
(defun hydra-toggle/nil nil
"Create a hydra with no body and the heads:
@@ -369,8 +375,7 @@ The body can be accessed via `hydra-toggle/body'.
Call the head: `nil'."
(interactive)
(hydra-default-pre)
- (hydra-keyboard-quit)
- nil)
+ (hydra-keyboard-quit))
(set
(defvar hydra-toggle/hint nil
"Dynamic hint for hydra-toggle.")
@@ -477,8 +482,11 @@ Call the head: `next-line'."
(hydra-default-pre)
(set-cursor-color "#e52b50")
(condition-case err
- (call-interactively
- (function next-line))
+ (progn
+ (setq this-command
+ (quote next-line))
+ (call-interactively
+ (function next-line)))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
@@ -492,9 +500,7 @@ Call the head: `next-line'."
(lambda nil
(hydra-keyboard-quit)
(set-cursor-color "#ffffff"))
- (quote warn))
- (setq this-command
- (quote next-line)))
+ (quote warn)))
(defun hydra-vi/previous-line nil
"Create a hydra with no body and the heads:
@@ -509,8 +515,11 @@ Call the head: `previous-line'."
(hydra-default-pre)
(set-cursor-color "#e52b50")
(condition-case err
- (call-interactively
- (function previous-line))
+ (progn
+ (setq this-command
+ (quote previous-line))
+ (call-interactively
+ (function previous-line)))
((quit error)
(message "%S" err)
(unless hydra-lv (sit-for 0.8))))
@@ -524,9 +533,7 @@ Call the head: `previous-line'."
(lambda nil
(hydra-keyboard-quit)
(set-cursor-color "#ffffff"))
- (quote warn))
- (setq this-command
- (quote previous-line)))
+ (quote warn)))
(defun hydra-vi/nil nil
"Create a hydra with no body and the heads:
@@ -540,8 +547,7 @@ Call the head: `nil'."
(interactive)
(hydra-default-pre)
(set-cursor-color "#e52b50")
- (hydra-keyboard-quit)
- nil)
+ (hydra-keyboard-quit))
(set
(defvar hydra-vi/hint nil
"Dynamic hint for hydra-vi.")
diff --git a/hydra.el b/hydra.el
index e002c8a..fea8701 100644
--- a/hydra.el
+++ b/hydra.el
@@ -514,6 +514,16 @@ HEADS is a list of heads."
heads ",\n")
(format "The body can be accessed via `%S'." body-name)))
+(defun hydra--call-interactively (cmd name)
+ "Generate a `call-interactively' statement for CMD.
+Set `this-command' to NAME."
+ (if (and (symbolp name)
+ (not (memq name '(nil body))))
+ `(progn
+ (setq this-command ',name)
+ (call-interactively #',cmd))
+ `(call-interactively #',cmd)))
+
(defun hydra--make-defun (name body doc head
keymap body-pre body-before-exit
&optional body-after-exit)
@@ -541,16 +551,18 @@ BODY-AFTER-EXIT is added to the end of the wrapper."
,@(when body-pre (list body-pre))
,@(if (hydra--head-property head :exit)
`((hydra-keyboard-quit)
- ,(if body-after-exit
- `(unwind-protect
- ,(when cmd `(call-interactively #',cmd))
- ,body-after-exit)
- (when cmd `(call-interactively #',cmd))))
+ ,@(if body-after-exit
+ `((unwind-protect
+ ,(when cmd
+ (hydra--call-interactively cmd (cadr head)))
+ ,body-after-exit))
+ (when cmd
+ `(,(hydra--call-interactively cmd (cadr head))))))
(delq
nil
`(,(when cmd
`(condition-case err
- (call-interactively #',cmd)
+ ,(hydra--call-interactively cmd (cadr head))
((quit error)
(message "%S" err)
(unless hydra-lv
@@ -566,10 +578,7 @@ BODY-AFTER-EXIT is added to the end of the wrapper."
(list 'quote body-foreign-keys)))
,body-after-exit
,(when body-timeout
- `(hydra-timeout ,body-timeout)))))
- ,@(when (and (symbolp (cadr head))
- (not (memq (cadr head) '(nil body))))
- `((setq this-command ',(cadr head)))))))
+ `(hydra-timeout ,body-timeout))))))))
(defmacro hydra--make-funcall (sym)
"Transform SYM into a `funcall' to call it."
- [elpa] master 566aab7 31/45: Set `this-command' when appropriate, (continued)
- [elpa] master 566aab7 31/45: Set `this-command' when appropriate, Oleh Krehel, 2015/04/16
- [elpa] master 19cc1be 21/45: Use `unwind-protect' for :after-exit, Oleh Krehel, 2015/04/16
- [elpa] master 986226f 18/45: Simplify `keyboard-quit', Oleh Krehel, 2015/04/16
- [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 <=
- [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, 2015/04/16
- [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