[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master a6c6a55 38/72: Improve compatibility for Emacs <= 24.3
From: |
Oleh Krehel |
Subject: |
[elpa] master a6c6a55 38/72: Improve compatibility for Emacs <= 24.3 |
Date: |
Fri, 06 Mar 2015 13:04:14 +0000 |
branch: master
commit a6c6a55aa26b0220cc3c796cfecec519dcb0b53c
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Improve compatibility for Emacs <= 24.3
* hydra.el (hydra-set-transient-map): Always take 3 arguments.
(hydra--pred): New defun.
(hydra-disable): Update, `overriding-terminal-local-map' is actually
also bound in 24.3.
Fixes #29
---
hydra.el | 39 +++++++++++++++++++++++++++------------
1 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/hydra.el b/hydra.el
index 7f90315..9e81a3f 100644
--- a/hydra.el
+++ b/hydra.el
@@ -80,9 +80,22 @@
(require 'lv)
(defalias 'hydra-set-transient-map
- (if (fboundp 'set-transient-map)
- 'set-transient-map
- 'set-temporary-overlay-map))
+ (if (fboundp 'set-transient-map)
+ 'set-transient-map
+ (lambda (map keep-pred &optional on-exit)
+ (set-temporary-overlay-map map (hydra--pred on-exit)))))
+
+(defun hydra--pred (on-exit)
+ "Generate a predicate on whether to continue the Hydra state.
+Call ON-EXIT for clean-up.
+This is a compatibility code for Emacs older than 24.4."
+ `(lambda ()
+ (if (lookup-key hydra-curr-map (this-command-keys-vector))
+ t
+ (hydra-cleanup)
+ ,(when on-exit
+ `(funcall ,(hydra--make-callable on-exit)))
+ nil)))
;;* Customize
(defgroup hydra nil
@@ -284,17 +297,19 @@ BODY is the second argument to `defhydra'"
((functionp hydra-last)
(funcall hydra-last))
- ;; Emacs 24.4.1
- ((boundp 'overriding-terminal-local-map)
- (setq overriding-terminal-local-map nil))
+ ;; Emacs 24.3 or older
+ ((< emacs-minor-version 4)
+ (setq emulation-mode-map-alists
+ (cl-remove-if
+ (lambda (x)
+ (and (consp x)
+ (consp (car x))
+ (equal (cdar x) hydra-curr-map)))
+ emulation-mode-map-alists)))
- ;; older
+ ;; Emacs 24.4.1
(t
- (while (and (consp (car emulation-mode-map-alists))
- (consp (caar emulation-mode-map-alists))
- (equal (cl-cdaar emulation-mode-map-alists) ',keymap))
- (setq emulation-mode-map-alists
- (cdr emulation-mode-map-alists))))))
+ (setq overriding-terminal-local-map nil))))
(defun hydra--unalias-var (str prefix)
"Return the symbol named STR if it's bound as a variable.
- [elpa] master 92e1922 19/72: hydra.el (hydra--hint): Take same arguments as `defhydra', (continued)
- [elpa] master 92e1922 19/72: hydra.el (hydra--hint): Take same arguments as `defhydra', Oleh Krehel, 2015/03/06
- [elpa] master 6f7cef2 22/72: Add teal body color, Oleh Krehel, 2015/03/06
- [elpa] master 7010772 32/72: hydra.el (hydra--head-color): Improve, Oleh Krehel, 2015/03/06
- [elpa] master d0e8d57 33/72: hydra.el (hydra-add-font-lock): Add `defhydradio', Oleh Krehel, 2015/03/06
- [elpa] master 0881733 28/72: hydra.el (defhydra): Fix typo, Oleh Krehel, 2015/03/06
- [elpa] master a4c4eb6 36/72: Add example for `Buffer-menu-mode', Oleh Krehel, 2015/03/06
- [elpa] master 88b32d5 24/72: hydra.el (hydra--hint): Add exception, Oleh Krehel, 2015/03/06
- [elpa] master c41c932 31/72: README.md: fix tables, Oleh Krehel, 2015/03/06
- [elpa] master 1eebfed 34/72: Allow `format'-style width specifiers in docstring, Oleh Krehel, 2015/03/06
- [elpa] master e962ff1 39/72: hydra.el: remove no :pre, :post restriction for Emacs<24.4, Oleh Krehel, 2015/03/06
- [elpa] master a6c6a55 38/72: Improve compatibility for Emacs <= 24.3,
Oleh Krehel <=
- [elpa] master 2c01db0 42/72: hydra.el (hydra--handle-nonhead): Update signature, Oleh Krehel, 2015/03/06
- [elpa] master a71b76e 35/72: Intercept quit signals, Oleh Krehel, 2015/03/06
- [elpa] master ae70e9a 41/72: Fix pink and teal Hydras running :post, Oleh Krehel, 2015/03/06
- [elpa] master 71d70f6 46/72: Add :body-pre switch, Oleh Krehel, 2015/03/06
- [elpa] master cb28124 44/72: Allow sexps in Ruby-style docstrings, Oleh Krehel, 2015/03/06
- [elpa] master ace99b3 51/72: hydra.el (hydra--make-defun): Update signature, Oleh Krehel, 2015/03/06
- [elpa] master efcffc0 45/72: hydra-examples.el: Add example 9, Oleh Krehel, 2015/03/06
- [elpa] master ef1f61d 40/72: hydra.el (hydra--handle-nonhead): Fix bug, Oleh Krehel, 2015/03/06
- [elpa] master 2eddb83 43/72: hydra-test.el (hydra-format): New test, Oleh Krehel, 2015/03/06
- [elpa] master 5242aad 48/72: Fix :exit t / :exit nil inheritance issue, Oleh Krehel, 2015/03/06