 (ac-define-source "merlin" merlin-ac-source)
 
 ;; Get the type of an element"
+(defun merlin-trim (s)
+  (replace-regexp-in-string "\n\\'" "" s))
 (defun merlin-get-type () 
+  (let ((sexp (merlin-get-completion (merlin-ident-under-point))))
+    (if (= (length (elt sexp 1)) 0)
+	nil
+      (elt (elt sexp 1) 0))))
+
+(defun merlin-show-type-minibuffer ()
+  (let ((typ (merlin-get-type)))
+    (if (and typ (string-equal (cdr (assoc 'kind typ)) "Value"))
+	(message "%s" (merlin-trim (cdr (assoc 'desc typ)))))))
+(defun merlin-show-type () 
   (interactive)
-  (let ((sexp (merlin-get-completion (merlin-ident-under-point))))
-    (if (= (length (elt sexp 1)) 0) 
+  (let ((ans (merlin-get-type)))
+    (if (= (length ans) 0) 
 	(message "nothing found for %s" (merlin-ident-under-point))
-      (let ((ans (elt (elt sexp 1) 0)))
-	(if (string-equal (cdr (assoc 'kind ans)) "Value")
-	    (message "%s" (cdr (assoc 'desc ans)))
-	  (progn
-	    (display-buffer merlin-type-buffer)
-	    (with-current-buffer merlin-type-buffer
-	      (erase-buffer)
-	      (insert (cdr (assoc 'info ans))))))))))
+      (if (string-equal (cdr (assoc 'kind ans)) "Value")
+	  (message "%s" (merlin-trim (cdr (assoc 'desc ans))))
+	(progn
+	  (display-buffer merlin-type-buffer)
+	  (with-current-buffer merlin-type-buffer
+	    (erase-buffer)
+	    (insert (cdr (assoc 'info ans)))))))))
 
 ;; .merlin parsing
 (defun merlin-add-path (kind dir)

(defvar merlin-error-overlay nil "Merlin overlay used for errors")
(defvar merlin-buffer nil "Buffer for merlin input")
(defvar merlin-ready nil "Is reception done?")
;; UTILS
(defun merlin-compute-prefix (ident)
  "Computes the prefix of an identifier. The prefix of Foo.bar is Foo. and the prefix of bar is \"\""


(defun merlin-dump-env ()
  "Dump the environment"
  (interactive)
  (message "Env: %s"
	   (append (elt (merlin-send-command "dump" '("env")) 1) nil)))

