]> code.delx.au - gnu-emacs-elpa/commitdiff
Work around `overriding-terminal-local-map' being terminal-local
authorOleh Krehel <ohwoeowho@gmail.com>
Tue, 14 Apr 2015 11:34:09 +0000 (13:34 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Tue, 14 Apr 2015 11:54:40 +0000 (13:54 +0200)
* hydra.el (hydra-disable): Try to reset `overriding-terminal-local-map'
  for each frame, so that it doesn't happen that the hydra is cancelled
  in one frame, but not in the other. `hydra-curr-on-exit' is called in
  the first frame for which there's a transient map.

(hydra--clearfun): Disable when `overriding-terminal-local-map' is nil.

Fixes #105

hydra.el

index fea8701848d2e9e37611ac4abc7842c76456caa5..39c027cc2f08867cbf34f53c656e379807df6ef5 100644 (file)
--- a/hydra.el
+++ b/hydra.el
@@ -107,27 +107,30 @@ warn: keep KEYMAP and issue a warning instead of running the command."
 
 (defun hydra--clearfun ()
   "Disable the current Hydra unless `this-command' is a head."
-  (if (memq this-command '(handle-switch-frame
-                           keyboard-quit))
-      (hydra-disable)
-    (unless (eq this-command
-                (lookup-key hydra-curr-map (this-single-command-keys)))
-      (unless (cl-case hydra-curr-foreign-keys
-                (warn
-                 (setq this-command 'hydra-amaranth-warn))
-                (run
-                 t)
-                (t nil))
-        (hydra-disable)))))
+  (when (or
+         (memq this-command '(handle-switch-frame keyboard-quit))
+         (null overriding-terminal-local-map)
+         (not (or (eq this-command
+                      (lookup-key hydra-curr-map (this-single-command-keys)))
+                  (cl-case hydra-curr-foreign-keys
+                    (warn
+                     (setq this-command 'hydra-amaranth-warn))
+                    (run
+                     t)
+                    (t nil)))))
+    (hydra-disable)))
 
 (defun hydra-disable ()
   "Disable the current Hydra."
   (remove-hook 'pre-command-hook 'hydra--clearfun)
-  (internal-pop-keymap hydra-curr-map 'overriding-terminal-local-map)
-  (when hydra-curr-on-exit
-    (let ((on-exit hydra-curr-on-exit))
-      (setq hydra-curr-on-exit nil)
-      (funcall on-exit))))
+  (dolist (frame (frame-list))
+    (with-selected-frame frame
+      (when overriding-terminal-local-map
+        (internal-pop-keymap hydra-curr-map 'overriding-terminal-local-map)
+        (when hydra-curr-on-exit
+          (let ((on-exit hydra-curr-on-exit))
+            (setq hydra-curr-on-exit nil)
+            (funcall on-exit)))))))
 
 (unless (fboundp 'internal-push-keymap)
   (defun internal-push-keymap (keymap symbol)