[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master eb181fd 23/28: Call :post for :timeout
From: |
Oleh Krehel |
Subject: |
[elpa] master eb181fd 23/28: Call :post for :timeout |
Date: |
Sun, 22 Mar 2015 16:34:47 +0000 |
branch: master
commit eb181fde0cf12f2c46c92fe753918a291cf3bea0
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Call :post for :timeout
* hydra.el (hydra--make-defun): When both :timeout and :post are given,
if `hydra-timeout' runs out, it will call :post before
`hydra-keyboard-quit'.
(hydra-timeout): Update to call function if it's given. Always call
`hydra-keyboard-quit' afterwards.
For this example code:
(global-set-key
(kbd "C-c t")
(defhydra test-hydra-b
(:timeout 2.0 :post (message "test b quit"))
"test b"
("x" (message "x"))
("y" (message "y"))
("q" nil "quit")))
The message "test b quit" is issued:
- on "q"
- on "x" or "y", after one of them has started the timer, and the timer
ran out. The timer is set to 2.0 seconds, and is reset each time "x"
or "y" is pressed.
- not on a plain "C-c t"
Fixes #34
---
hydra.el | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/hydra.el b/hydra.el
index 2680f38..c5a74a2 100644
--- a/hydra.el
+++ b/hydra.el
@@ -610,7 +610,10 @@ OTHER-POST is an optional extension to the :post key of
BODY."
`(lambda () (hydra-cleanup)))))
,(or other-post
(when body-timeout
- `(hydra-timeout ,body-timeout))))))))))
+ (list 'hydra-timeout
+ body-timeout
+ (when body-post
+ (hydra--make-callable
body-post))))))))))))
(defun hydra-pink-fallback ()
"On intercepting a non-head, try to run it."
@@ -774,8 +777,7 @@ NAMES should be defined by `defhydradio' or similar."
"Timer for `hydra-timeout'.")
(defun hydra-timeout (secs &optional function)
- "In SECS seconds call FUNCTION.
-FUNCTION defaults to `hydra-disable'.
+ "In SECS seconds call FUNCTION, then `hydra-keyboard-quit'.
Cancel the previous `hydra-timeout'."
(cancel-timer hydra-timer)
(setq hydra-timer (timer-create))
@@ -783,7 +785,10 @@ Cancel the previous `hydra-timeout'."
(timer-relative-time (current-time) secs))
(timer-set-function
hydra-timer
- (or function #'hydra-keyboard-quit))
+ `(lambda ()
+ ,(when function
+ `(funcall ,function))
+ (hydra-keyboard-quit)))
(timer-activate hydra-timer))
;;* Macros
- [elpa] master 3c4b3fd 16/28: lv.el: Update truncation rules, (continued)
- [elpa] master 3c4b3fd 16/28: lv.el: Update truncation rules, Oleh Krehel, 2015/03/22
- [elpa] master 3f11348 13/28: README.md: Add toc, Oleh Krehel, 2015/03/22
- [elpa] master 5e8c7f2 18/28: hydra.el (hydra--format): Extend key regex with "; :", Oleh Krehel, 2015/03/22
- [elpa] master 3a77bf6 20/28: hydra-examples.el (hydra-apropos): Add., Oleh Krehel, 2015/03/22
- [elpa] master 622c798 10/28: README.md: move some stuff to wiki, add more stuff, Oleh Krehel, 2015/03/22
- [elpa] master 9f9dcf9 17/28: Bind [switch-frame] to `hydra-keyboard-quit', Oleh Krehel, 2015/03/22
- [elpa] master 543e97b 19/28: Fix switch-frame handling., Oleh Krehel, 2015/03/22
- [elpa] master 97d6987 21/28: Add hydra-rectangle example, Oleh Krehel, 2015/03/22
- [elpa] master bfe65da 15/28: README.md: Fix up typos, Oleh Krehel, 2015/03/22
- [elpa] master d44bf58 22/28: Don't bind `hydra-keyboard-quit' in foreign keymaps, Oleh Krehel, 2015/03/22
- [elpa] master eb181fd 23/28: Call :post for :timeout,
Oleh Krehel <=
- [elpa] master 30a073b 25/28: hydra.el (hydra-keyboard-quit): Clean up the message area, Oleh Krehel, 2015/03/22
- [elpa] master 8e4b1fa 24/28: lv.el (lv-message): Use setq-local for window-min-height, Oleh Krehel, 2015/03/22
- [elpa] master 498d78b 26/28: Set pink/amaranth override recursively, Oleh Krehel, 2015/03/22
- [elpa] master 7783f89 27/28: Minor fixes, Oleh Krehel, 2015/03/22
- [elpa] master a071b60 09/28: README.md: update, Oleh Krehel, 2015/03/22
- [elpa] master 5aa7896 28/28: Merge commit '7783f89cdbb3e3ba57f232552729715148e0b9a1' from hydra, Oleh Krehel, 2015/03/22