         (merlin-type-region)
       (when (merlin-type-enclosing-query)
         (merlin-type-enclosing-go-up))))
-  (if merlin-arrow-keys-type-enclosing
-      (merlin-event-loop merlin-type-enclosing-map
-                         '((up . merlin-type-enclosing-go-up)
-                           (down . merlin-type-enclosing-go-down)))))
+  (when merlin-arrow-keys-type-enclosing
+    (set-temporary-overlay-map merlin-type-enclosing-map t)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; PACKAGE, PROJECT AND FLAGS MANAGEMENT ;;

    (setq merlin-enclosing-offset (1- merlin-enclosing-offset))
    (merlin-type-enclosing-go)))


(defvar merlin-type-enclosing-map
  (let ((keymap (make-sparse-keymap)))
    (define-key keymap (kbd "<up>") 'up)
    (define-key keymap (kbd "[up]") 'up)
    (define-key keymap (kbd "<down>") 'down)
    (define-key keymap (kbd "[down]") 'down)
    keymap)
  "The local map to navigate type enclosing.")


             (version (replace-regexp-in-string "\n$" "" version)))
        (message "%s (from shell)" version))
    (message "%s" (merlin-send-command '(version)))))

;;;;;;;;;;;;;;;;
;; MODE SETUP ;;
