]> code.delx.au - gnu-emacs-elpa/commitdiff
Set `this-command' when appropriate
authorOleh Krehel <ohwoeowho@gmail.com>
Mon, 13 Apr 2015 19:29:45 +0000 (21:29 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Mon, 13 Apr 2015 19:29:45 +0000 (21:29 +0200)
* hydra.el (hydra--make-defun): Update.

* hydra-test.el: Update tests.

Re #79

hydra-test.el
hydra.el

index a8facfed8c0e32b793ff093a01336ecbea0ec566..28b4519a5f6ad9e1bdcb519d54c2c7a689373343 100644 (file)
@@ -121,7 +121,9 @@ Call the head: `first-error'."
          (lambda nil
            (hydra-keyboard-quit)
            nil)
-         nil))
+         nil)
+        (setq this-command
+              (quote first-error)))
       (defun hydra-error/next-error nil
         "Create a hydra with a \"M-g\" body and the heads:
 
@@ -152,7 +154,9 @@ Call the head: `next-error'."
          (lambda nil
            (hydra-keyboard-quit)
            nil)
-         nil))
+         nil)
+        (setq this-command
+              (quote next-error)))
       (defun hydra-error/previous-error nil
         "Create a hydra with a \"M-g\" body and the heads:
 
@@ -183,7 +187,9 @@ Call the head: `previous-error'."
          (lambda nil
            (hydra-keyboard-quit)
            nil)
-         nil))
+         nil)
+        (setq this-command
+              (quote previous-error)))
       (unless (keymapp
                (lookup-key
                 global-map
@@ -311,7 +317,9 @@ Call the head: `toggle-truncate-lines'."
         (hydra-keyboard-quit)
         (call-interactively
          (function
-          toggle-truncate-lines)))
+          toggle-truncate-lines))
+        (setq this-command
+              (quote toggle-truncate-lines)))
       (defun hydra-toggle/auto-fill-mode-and-exit nil
         "Create a hydra with no body and the heads:
 
@@ -327,7 +335,9 @@ Call the head: `auto-fill-mode'."
         (hydra-default-pre)
         (hydra-keyboard-quit)
         (call-interactively
-         (function auto-fill-mode)))
+         (function auto-fill-mode))
+        (setq this-command
+              (quote auto-fill-mode)))
       (defun hydra-toggle/abbrev-mode-and-exit nil
         "Create a hydra with no body and the heads:
 
@@ -343,7 +353,9 @@ Call the head: `abbrev-mode'."
         (hydra-default-pre)
         (hydra-keyboard-quit)
         (call-interactively
-         (function abbrev-mode)))
+         (function abbrev-mode))
+        (setq this-command
+              (quote abbrev-mode)))
       (defun hydra-toggle/nil nil
         "Create a hydra with no body and the heads:
 
@@ -480,7 +492,9 @@ Call the head: `next-line'."
          (lambda nil
            (hydra-keyboard-quit)
            (set-cursor-color "#ffffff"))
-         (quote warn)))
+         (quote warn))
+        (setq this-command
+              (quote next-line)))
       (defun hydra-vi/previous-line nil
         "Create a hydra with no body and the heads:
 
@@ -510,7 +524,9 @@ Call the head: `previous-line'."
          (lambda nil
            (hydra-keyboard-quit)
            (set-cursor-color "#ffffff"))
-         (quote warn)))
+         (quote warn))
+        (setq this-command
+              (quote previous-line)))
       (defun hydra-vi/nil nil
         "Create a hydra with no body and the heads:
 
index 57a78fc5ea5a1d90d8016495f28fc3d165803e78..e002c8a8125190e325fe630f84b9a67db6587017 100644 (file)
--- a/hydra.el
+++ b/hydra.el
@@ -566,7 +566,10 @@ 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))))))))
+                        `(hydra-timeout ,body-timeout)))))
+       ,@(when (and (symbolp (cadr head))
+                    (not (memq (cadr head) '(nil body))))
+               `((setq this-command ',(cadr head)))))))
 
 (defmacro hydra--make-funcall (sym)
   "Transform SYM into a `funcall' to call it."
@@ -779,8 +782,6 @@ result of `defhydra'."
              (body-inherit (plist-get body-plist :inherit))
              (body-foreign-keys (hydra--body-foreign-keys body))
              (body-exit (hydra--body-exit body)))
-        (hydra--make-funcall body-before-exit)
-        (hydra--make-funcall body-after-exit)
         (dolist (base body-inherit)
           (setq heads (append heads (copy-sequence (eval base)))))
         (dolist (h heads)
@@ -827,6 +828,8 @@ result of `defhydra'."
            heads)
           (hydra--make-funcall body-pre)
           (hydra--make-funcall body-body-pre)
+          (hydra--make-funcall body-before-exit)
+          (hydra--make-funcall body-after-exit)
           (when (memq body-foreign-keys '(run warn))
             (unless (cl-some
                      (lambda (h)