     (cons (if bounds (car bounds) (point))
           (point))))
 
-;;;;;;;;;;;;;;;;;;;;;;;
-;; EXPRESSION TYPING ;;
-;;;;;;;;;;;;;;;;;;;;;;;
-
-(defun merlin--type-expression (exp callback-if-success &optional callback-if-exn)
-  "Get the type of EXP inside the local context."
-  (when exp (merlin/send-command-async
-             (list 'type 'expression (substring-no-properties exp)
-                   'at (merlin/unmake-point (point)))
-             callback-if-success callback-if-exn)))
+;;;;;;;;;;;;;;;;;
+;; TYPE BUFFER ;;
+;;;;;;;;;;;;;;;;;
+
+(defun merlin--count-lines (text)
+  (let ((count 0)
+        (pos   0))
+    (while (and (<= count 8)
+                (string-match "\n" text pos))
+           (setq pos (match-end 0))
+           (setq count (1+ count)))
+    count))
 
 (defun merlin/display-in-type-buffer (text)
   "Change content of type-buffer."


(defun merlin--document-pure (&optional ident)
  "Document the identifier IDENT at point."
  (let ((r (merlin--document-pos ident)))
    (message "%s" r)))

(defun merlin-document ()
  "Document the identifier under point"

    (insert text)
    (goto-char (point-min))))


;;;;;;;;;;;;;;;;;;;;;;;
;; EXPRESSION TYPING ;;
;;;;;;;;;;;;;;;;;;;;;;;

(defun merlin--type-expression (exp callback-if-success &optional callback-if-exn)
  "Get the type of EXP inside the local context."
  (when exp (merlin/send-command-async
             (list 'type 'expression (substring-no-properties exp)
                   'at (merlin/unmake-point (point)))
             callback-if-success callback-if-exn)))

(defun merlin--type-display (bounds type &optional quiet)
  "Display the type TYPE of the expression occuring at BOUNDS.
If QUIET is non nil, then an overlay and the merlin types can be used."
  (if (not type)
      (unless quiet (message "<no information>"))
    (let ((count (merlin--count-lines type)))
      (merlin/display-in-type-buffer type)
      (if (> count 8)
          (display-buffer merlin-type-buffer-name)
        (message "%s"
