[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 498d78b 26/28: Set pink/amaranth override recursively
From: |
Oleh Krehel |
Subject: |
[elpa] master 498d78b 26/28: Set pink/amaranth override recursively |
Date: |
Sun, 22 Mar 2015 16:34:48 +0000 |
branch: master
commit 498d78bbccd78d4663ec3d77cdf8faa136ea5f8c
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Set pink/amaranth override recursively
* hydra.el (hydra--modify-keymap): New defun.
(hydra--handle-nonhead): Update.
Fixes #81.
---
hydra.el | 47 ++++++++++++++++++++++++++++++++++-------------
1 files changed, 34 insertions(+), 13 deletions(-)
diff --git a/hydra.el b/hydra.el
index 684fdad..44d27ef 100644
--- a/hydra.el
+++ b/hydra.el
@@ -635,6 +635,22 @@ OTHER-POST is an optional extension to the :post key of
BODY."
(message "Pink Hydra can't currently handle prefixes, continuing"))
(message "Pink Hydra could not resolve: %S" keys))))
+(defun hydra--modify-keymap (keymap def)
+ "In KEYMAP, add DEF to each sub-keymap."
+ (cl-labels
+ ((recur (map)
+ (if (atom map)
+ map
+ (if (eq (car map) 'keymap)
+ (cons 'keymap
+ (cons
+ def
+ (recur (cdr map))))
+ (cons
+ (recur (car map))
+ (recur (cdr map)))))))
+ (recur keymap)))
+
(defun hydra--handle-nonhead (keymap name body heads)
"Setup KEYMAP for intercepting non-head bindings.
NAME, BODY and HEADS are parameters to `defhydra'."
@@ -650,19 +666,24 @@ NAME, BODY and HEADS are parameters to `defhydra'."
(memq (hydra--head-color h body) '(blue teal)))
heads)
(progn
- (define-key keymap [t]
- `(lambda ()
- (interactive)
- ,(cond
- ((memq body-color '(amaranth teal))
- '(message "An amaranth Hydra can only exit through a blue
head"))
- (t
- '(hydra-pink-fallback)))
- (hydra-set-transient-map hydra-curr-map t)
- (when hydra-is-helpful
- (unless hydra-lv
- (sit-for 0.8))
- (,(intern (format "%S/hint" name)))))))
+ (setcdr
+ keymap
+ (cdr
+ (hydra--modify-keymap
+ keymap
+ (cons t
+ `(lambda ()
+ (interactive)
+ ,(cond
+ ((memq body-color '(amaranth teal))
+ '(message "An amaranth Hydra can only exit through
a blue head"))
+ (t
+ '(hydra-pink-fallback)))
+ (hydra-set-transient-map hydra-curr-map t)
+ (when hydra-is-helpful
+ (unless hydra-lv
+ (sit-for 0.8))
+ (,(intern (format "%S/hint" name))))))))))
(unless (eq body-color 'teal)
(error
"An %S Hydra must have at least one blue head in order to exit"
- [elpa] master 3a77bf6 20/28: hydra-examples.el (hydra-apropos): Add., (continued)
- [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, 2015/03/22
- [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 <=
- [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