emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master d482d06: * hydra/hydra.el: Use add/remove-function. Fix wa


From: Stefan Monnier
Subject: [elpa] master d482d06: * hydra/hydra.el: Use add/remove-function. Fix warning.
Date: Sun, 19 Apr 2015 20:00:57 +0000

branch: master
commit d482d069d72f437e187c8a4c8cf1a59dd912c742
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * hydra/hydra.el: Use add/remove-function.  Fix warning.
    
    * hydra/hydra.el (hydra--input-method-function): Move before first use.
    (hydra--imf): New function.
    (hydra-default-pre, hydra-disable): Use add/remove-function.
---
 packages/hydra/hydra.el |   31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/packages/hydra/hydra.el b/packages/hydra/hydra.el
index 7fc9d7e..8bc4341 100644
--- a/packages/hydra/hydra.el
+++ b/packages/hydra/hydra.el
@@ -123,6 +123,9 @@ warn: keep KEYMAP and issue a warning instead of running 
the command."
 (defvar hydra--ignore nil
   "When non-nil, don't call `hydra-curr-on-exit'")
 
+(defvar hydra--input-method-function nil
+  "Store overridden `input-method-function' here.")
+
 (defun hydra-disable ()
   "Disable the current Hydra."
   (remove-hook 'pre-command-hook 'hydra--clearfun)
@@ -131,9 +134,11 @@ warn: keep KEYMAP and issue a warning instead of running 
the command."
       (when overriding-terminal-local-map
         (internal-pop-keymap hydra-curr-map 'overriding-terminal-local-map)
         (unless hydra--ignore
-          (when hydra--input-method-function
-            (setq input-method-function hydra--input-method-function)
-            (setq hydra--input-method-function nil))
+          (if (fboundp 'remove-function)
+              (remove-function input-method-function #'hydra--imf)
+            (when hydra--input-method-function
+              (setq input-method-function hydra--input-method-function)
+              (setq hydra--input-method-function nil)))
           (when hydra-curr-on-exit
             (let ((on-exit hydra-curr-on-exit))
               (setq hydra-curr-on-exit nil)
@@ -358,15 +363,16 @@ Return DEFAULT if PROP is not in H."
        ((blue teal) t)
        (t nil)))))
 
-(defvar hydra--input-method-function nil
-  "Store overridden `input-method-function' here.")
+(defalias 'hydra--imf #'list)
 
 (defun hydra-default-pre ()
   "Default setup that happens in each head before :pre."
   (when (eq input-method-function 'key-chord-input-method)
-    (unless hydra--input-method-function
-      (setq hydra--input-method-function input-method-function)
-      (setq input-method-function nil))))
+    (if (fboundp 'add-function)
+        (add-function :override input-method-function #'hydra--imf)
+      (unless hydra--input-method-function
+        (setq hydra--input-method-function input-method-function)
+        (setq input-method-function nil)))))
 
 (defvar hydra-timeout-timer (timer-create)
   "Timer for `hydra-timeout'.")
@@ -1015,10 +1021,9 @@ DOC defaults to TOGGLE-NAME split and capitalized."
                    0
                  i)))))
 
-(provide 'hydra)
-
-;;; Local Variables:
-;;; outline-regexp: ";;\\*+"
-;;; End:
+;; Local Variables:
+;; outline-regexp: ";;\\*+"
+;; End:
 
+(provide 'hydra)
 ;;; hydra.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]