     ("sn" mc/skip-to-next-like-this "skip next")
     ("sp" mc/skip-to-previous-like-this "skip prev")
     ("e" mc/edit-lines "edit lines")
-    ("SPC" (progn (mc/keyboard-quit)
-                  (mc/keyboard-quit)
-                  (when (fboundp 'my/hydra-modes-pop)
-                    (my/hydra-modes-pop))) "cancel" :color blue)))
+    ("SPC" (my/hydra-modes-pop 'my/hydra-cursor-exit) "cancel" :color blue))
+
+  (defun my/hydra-cursor-exit ()
+    (interactive)
+    (mc/keyboard-quit)
+    (mc/keyboard-quit)))
 
 (use-package modalka
   :bind (("M-<SPC>" . modalka-mode))

  :config
  (defhydra hydra-window-layout ()
    "layout"
    ("a" ace-window "ace" :color blue)
    ("P" my/windresize-up)
    ("p" windmove-up "up")
    ("F" my/windresize-right)

        (my/vcs-gutter-mode -1)
      (my/vcs-gutter-mode t))))

(defvar my/hydra-modes-stack nil)

(defun my/hydra-modes-push (expr)
  (push `(lambda () ,expr) my/hydra-modes-stack))

(defun my/hydra-modes-pop (&optional fun)
  (interactive)
  (when fun
    (call-interactively fun))
  (let ((x (pop my/hydra-modes-stack)))
    (when x
      (funcall x))))

(use-package hydra
  :commands hydra-modes/body
  :bind (("C-c m" . hydra-modes/body))
  :config
  (defhydra hydra-modes (:color teal)
    "modes"
