[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 1a13273 06/22: Allow to pause arbitrary hydras to the stac
From: |
Oleh Krehel |
Subject: |
[elpa] master 1a13273 06/22: Allow to pause arbitrary hydras to the stack |
Date: |
Fri, 16 Oct 2015 10:06:55 +0000 |
branch: master
commit 1a13273ff0ac095ddd91e75bf1e2ffac9efcb775
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Allow to pause arbitrary hydras to the stack
* hydra.el (hydra-pause-resume): New command.
(hydra-pause-ring): New defvar. Stores the paused hydras.
(hydra-keyboard-quit): Set `hydra-curr-map' to nil, so it's possible to
determine if any hydra is active.
(hydra--clearfun): Ignore `hydra-pause-resume', since the hydra needs to
be active for `hydra-pause-resume'.
Fixes #135
---
hydra.el | 43 +++++++++++++++++++++++++++++++------------
1 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/hydra.el b/hydra.el
index 0272348..d912c7d 100644
--- a/hydra.el
+++ b/hydra.el
@@ -116,18 +116,20 @@ warn: keep KEYMAP and issue a warning instead of running
the command."
(defun hydra--clearfun ()
"Disable the current Hydra unless `this-command' is a head."
- (when (or
- (memq this-command '(handle-switch-frame keyboard-quit))
- (null overriding-terminal-local-map)
- (not (or (eq this-command
- (lookup-key hydra-curr-map (this-single-command-keys)))
- (cl-case hydra-curr-foreign-keys
- (warn
- (setq this-command 'hydra-amaranth-warn))
- (run
- t)
- (t nil)))))
- (hydra-disable)))
+ (unless (eq this-command 'hydra-pause-resume)
+ (when (or
+ (memq this-command '(handle-switch-frame
+ keyboard-quit))
+ (null overriding-terminal-local-map)
+ (not (or (eq this-command
+ (lookup-key hydra-curr-map (this-single-command-keys)))
+ (cl-case hydra-curr-foreign-keys
+ (warn
+ (setq this-command 'hydra-amaranth-warn))
+ (run
+ t)
+ (t nil)))))
+ (hydra-disable))))
(defvar hydra--ignore nil
"When non-nil, don't call `hydra-curr-on-exit'.")
@@ -409,6 +411,7 @@ Return DEFAULT if PROP is not in H."
(hydra-disable)
(cancel-timer hydra-timeout-timer)
(cancel-timer hydra-message-timer)
+ (setq hydra-curr-map nil)
(unless (and hydra--ignore
(null hydra--work-around-dedicated))
(if hydra-lv
@@ -1060,6 +1063,22 @@ DOC defaults to TOGGLE-NAME split and capitalized."
0
i)))))
+(defvar hydra-pause-ring (make-ring 10)
+ "Ring for paused hydras.")
+
+(defun hydra-pause-resume ()
+ "Quit the current hydra and save it to the stack.
+If there's no active hydra, pop one from the stack and call its body.
+If the stack is empty, call the last hydra's body."
+ (interactive)
+ (cond (hydra-curr-map
+ (ring-insert hydra-pause-ring hydra-curr-body-fn)
+ (hydra-keyboard-quit))
+ ((zerop (ring-length hydra-pause-ring))
+ (funcall hydra-curr-body-fn))
+ (t
+ (funcall (ring-remove hydra-pause-ring 0)))))
+
;; Local Variables:
;; outline-regexp: ";;\\([;*]+ [^\s\t\n]\\|###autoload\\)\\|("
;; indent-tabs-mode: nil
- [elpa] master updated (2eb4c54 -> bfeccce), Oleh Krehel, 2015/10/16
- [elpa] master fd8e1b9 02/22: hydra.el (hydra-fontify-head-default): Add "%" exception, Oleh Krehel, 2015/10/16
- [elpa] master a2f8a23 01/22: Allow to escape ^ in docstrings, Oleh Krehel, 2015/10/16
- [elpa] master 2d45839 03/22: lv-window: split-window ignores window parameters, Oleh Krehel, 2015/10/16
- [elpa] master fca56c3 07/22: targets/hydra-init.el: Move, Oleh Krehel, 2015/10/16
- [elpa] master 1a13273 06/22: Allow to pause arbitrary hydras to the stack,
Oleh Krehel <=
- [elpa] master adc2997 08/22: Allow for "_[_" and "_]_" in docs, Oleh Krehel, 2015/10/16
- [elpa] master 1acd5f6 05/22: hydra.el (hydra-face-blue): Customize for dark themes, Oleh Krehel, 2015/10/16
- [elpa] master c8b4749 09/22: Allow binding heads to "%", Oleh Krehel, 2015/10/16
- [elpa] master 7aa8187 13/22: Allow to specify :face for each head, Oleh Krehel, 2015/10/16
- [elpa] master df7b079 10/22: hydra.el (hydra-head-format): Customize the key formatting, Oleh Krehel, 2015/10/16
- [elpa] master 900ca34 04/22: Allow access to the current hydra body, Oleh Krehel, 2015/10/16
- [elpa] master 1e9276a 12/22: Remove trailing whitespace from :columns docstring, Oleh Krehel, 2015/10/16
- [elpa] master 852ae26 14/22: Use quote instead of function to prevent compiler warnings, Oleh Krehel, 2015/10/16
- [elpa] master ea36afc 19/22: Allow "_", "!", and "&" as keys in docstrings, Oleh Krehel, 2015/10/16
- [elpa] master f58d356 17/22: Allow #'command syntax for heads, just to have it, Oleh Krehel, 2015/10/16