     (set (make-local-variable 'merlin-enclosing-overlay) nil)
     (set (make-local-variable 'merlin-enclosing-types) nil)
     (set (make-local-variable 'merlin-enclosing-offset) nil)
+    (set (make-local-variable 'merlin-last-point-type) nil)
     (setq ac-sources '(merlin-ac-source))
     (add-to-list 'after-change-functions 'merlin-edit)
     (set-process-query-on-exit-flag (merlin-get-process) nil)

  (let ((map (make-sparse-keymap)))
    (define-key map (kbd "C-c <C-return>") 'merlin-to-point)
    (define-key map (kbd "C-c C-t") 'merlin-show-type-of-point)
    (define-key map (kbd "C-c l") 'merlin-use)
    (define-key map (kbd "C-c C-x") 'merlin-next-error)
    (define-key map (kbd "C-c C-r") 'merlin-rewind)

(defun merlin-type-enclosing ()
  "If there is a selected type enclosing, kill it. Otherwise start a new session at point"
  (interactive)
  (let ((list
         (mapcar
          '(lambda (obj)
             (cons
              (cdr (assoc 'type obj))
              (merlin-make-bounds obj)))
          (elt
               (merlin-is-return
                (merlin-send-command "type" (list "enclosing" (merlin-unmake-point (point)))))
               1))))
    (setq merlin-enclosing-types list)
    (setq merlin-enclosing-offset -1)
    (if merlin-enclosing-overlay (delete-overlay merlin-enclosing-overlay))
    (setq merlin-enclosing-overlay nil)))

(defun merlin-magic-show-type (arg)
  "Performs true magic."
  (interactive "p")
  (if (equal merlin-last-point-type (point))
      (if (> arg 1)
          (merlin-type-enclosing-go-down)
        (merlin-type-enclosing-go-up))
    (progn
      (setq merlin-last-point-type (point))
      (merlin-type-enclosing)
      (merlin-type-enclosing-go-up))))

(defun merlin-type-enclosing-go ()
  "Highlight the given corresponding enclosing data (of the form (type . bounds)"
  (let ((data (elt merlin-enclosing-types merlin-enclosing-offset)))
    (merlin-create-overlay 'merlin-enclosing-overlay (cdr data) 'next-error "5 sec")
    (message "%s" (car data))))

(defun merlin-type-enclosing-go-up ()
