 (defvar merlin-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "C-c <C-return>") 'merlin-point)
-    (define-key map (kbd "C-c C-t") 'merlin-show-type)
-    (define-key map (kbd "C-c e") 'merlin-dump-env)
+    (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-r") 'merlin-rewind)
     map
     ))

	(elt ans 1)
      nil)))
  
(defun merlin-get-type ()
  (let ((sexp (merlin-get-completion (merlin-ident-under-point))))
    (if (= (length (elt sexp 1)) 0)
	nil
      (merlin-trim (elt (elt sexp 1) 0)))))

(defun merlin-show-type-minibuffer ()
  (let ((ident (merlin-ident-under-point)))
    (let ((typ (merlin-type-of-expression ident)))
      (if (and typ (not (merlin-is-long typ)))
	  (message "%s : %s" ident typ)))))
(defun merlin-show-type () 
  (interactive)
  (let ((ans (merlin-type-of-expression (merlin-ident-under-point))))
    (if (not ans)
	(message "nothing found for %s" (merlin-ident-under-point))
      (if (not (merlin-is-long ans))
	  (message "%s : %s" (merlin-ident-under-point) ans)
	(progn
	  (display-buffer merlin-type-buffer)
	  (with-current-buffer merlin-type-buffer
	    (erase-buffer)
	    (insert ans)))))))

;; .merlin parsing
(defun merlin-add-path (kind dir)

(defun merlin-extract-complete (prefix l)
  "Parses and format completion results"
  (mapcar `(lambda (c) 
	     (if merlin-completion-types
		 (format "%s%s: %s" ,prefix
			 (cdr (assoc 'name c))
			 (cdr (assoc 'desc c)))
	       (concat ,prefix (cdr (assoc 'name c)))))
	  (append l nil)))

(defun merlin-source-action ()
  "Called when the user has pressed RET on a completion candidate. Remove the garbage"
  (if merlin-completion-types
      (save-excursion
	(let ((endpoint (point)))
	  (goto-char merlin-completion-point)
	  (search-forward ":")
	  (backward-char 1)
	  (delete-region (point) endpoint))))
)


