hydra.el: Use add/remove-function. Fix warning.

* hydra.el (hydra--input-method-function): Move before first use.
(hydra--imf): New function.
(hydra-default-pre, hydra-disable): Use add/remove-function.
master
Stefan Monnier 11 years ago committed by Oleh Krehel
parent c78367f640
commit 2bc9146199
  1. 22
      hydra.el

@ -141,9 +141,11 @@ warn: keep KEYMAP and issue a warning instead of running the command."
(when overriding-terminal-local-map (when overriding-terminal-local-map
(internal-pop-keymap hydra-curr-map 'overriding-terminal-local-map) (internal-pop-keymap hydra-curr-map 'overriding-terminal-local-map)
(unless hydra--ignore (unless hydra--ignore
(when hydra--input-method-function (if (fboundp 'remove-function)
(setq input-method-function hydra--input-method-function) (remove-function input-method-function #'hydra--imf)
(setq hydra--input-method-function nil)) (when hydra--input-method-function
(setq input-method-function hydra--input-method-function)
(setq hydra--input-method-function nil)))
(when hydra-curr-on-exit (when hydra-curr-on-exit
(let ((on-exit hydra-curr-on-exit)) (let ((on-exit hydra-curr-on-exit))
(setq hydra-curr-on-exit nil) (setq hydra-curr-on-exit nil)
@ -373,12 +375,16 @@ Return DEFAULT if PROP is not in H."
((blue teal) t) ((blue teal) t)
(t nil))))) (t nil)))))
(defalias 'hydra--imf #'list)
(defun hydra-default-pre () (defun hydra-default-pre ()
"Default setup that happens in each head before :pre." "Default setup that happens in each head before :pre."
(when (eq input-method-function 'key-chord-input-method) (when (eq input-method-function 'key-chord-input-method)
(unless hydra--input-method-function (if (fboundp 'add-function)
(setq hydra--input-method-function input-method-function) (add-function :override input-method-function #'hydra--imf)
(setq input-method-function nil)))) (unless hydra--input-method-function
(setq hydra--input-method-function input-method-function)
(setq input-method-function nil)))))
(defvar hydra-timeout-timer (timer-create) (defvar hydra-timeout-timer (timer-create)
"Timer for `hydra-timeout'.") "Timer for `hydra-timeout'.")
@ -1030,11 +1036,11 @@ DOC defaults to TOGGLE-NAME split and capitalized."
0 0
i))))) i)))))
(provide 'hydra)
;; Local Variables: ;; Local Variables:
;; outline-regexp: ";;\\([;*]+ [^\s\t\n]\\|###autoload\\)\\|(" ;; outline-regexp: ";;\\([;*]+ [^\s\t\n]\\|###autoload\\)\\|("
;; indent-tabs-mode: nil ;; indent-tabs-mode: nil
;; End: ;; End:
(provide 'hydra)
;;; hydra.el ends here ;;; hydra.el ends here

Loading…
Cancel
Save