]> code.delx.au - gnu-emacs-elpa/commitdiff
hydra.el: Use add/remove-function. Fix warning.
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 19 Apr 2015 20:00:53 +0000 (16:00 -0400)
committerOleh Krehel <ohwoeowho@gmail.com>
Fri, 1 May 2015 14:12:46 +0000 (16:12 +0200)
* hydra.el (hydra--input-method-function): Move before first use.
(hydra--imf): New function.
(hydra-default-pre, hydra-disable): Use add/remove-function.

hydra.el

index dd58e63918bee6fd87269f2b63166f71cea7e3d1..3412ca52d1fe6260ac98b7dbd2dbb424e502064c 100644 (file)
--- a/hydra.el
+++ b/hydra.el
@@ -141,9 +141,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)
@@ -373,12 +375,16 @@ Return DEFAULT if PROP is not in H."
        ((blue teal) t)
        (t nil)))))
 
+(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'.")
@@ -1030,11 +1036,11 @@ DOC defaults to TOGGLE-NAME split and capitalized."
                    0
                  i)))))
 
-(provide 'hydra)
-
 ;; Local Variables:
 ;; outline-regexp: ";;\\([;*]+ [^\s\t\n]\\|###autoload\\)\\|("
 ;; indent-tabs-mode: nil
 ;; End:
 
+(provide 'hydra)
+
 ;;; hydra.el ends here