   (interactive "p")
   (if (> arg 1)
       (merlin-show-type-of-region)
-    (let ((ident (merlin-ident-under-point)))
-      (if ident
-	  (merlin-show-type ident (merlin-type-of-expression ident))))))
+    (merlin-show-type (bounds-of-thing-at-point 'ocamlatom))))
 
 ;; .merlin parsing
 (defun merlin-add-path (kind dir)

              (end (merlin-make-point (cdr (assoc 'end ret))))
              (type (cdr (assoc 'type ret))))
          (merlin-create-overlay 'merlin-type-overlay start end 'next-error "1 sec")
          type))))
          

        
    

(defun merlin-type-of-expression-local (exp)
  "Get the type of an expression inside the local context"
  (merlin-is-return (merlin-send-command "type" 
					 (list "expression" exp "at" (merlin-unmake-point (point))))))

(defun merlin-type-of-expression-global (exp)
  "Get the type of an expression globally"
  (merlin-is-return (merlin-send-command "type" (list "expression" exp))))


(defun merlin-type-of-expression (exp)
  "Get the type of an expression by using `merlin-type-of-expression-local',
and if it fails, it uses `merlin-type-of-expression-global'"
  (or
   (merlin-type-of-expression-node)
   (merlin-type-of-expression-local exp)
   (merlin-type-of-expression-global exp)))
(defun merlin-show-type (name typ)
  "Show the given type. If typ is nil, nothing is done"
  (if typ
      (if (not (merlin-is-long typ))
	  (message "%s : %s" name typ)
	(progn
	  (display-buffer merlin-type-buffer)
	  (with-current-buffer merlin-type-buffer
	    (erase-buffer)
	    (insert typ))))))

(defun merlin-show-type-of-region ()
  "Show the type of the region"
  (interactive)
  (let ((exp (buffer-substring-no-properties 
	       (region-beginning) 
	       (region-end))))
    (if exp
	(merlin-show-type exp (merlin-type-of-expression exp)))))

(defun merlin-show-type-of-point-quiet ()
  "Show the type of the identifier under the point if it is short (a value)"
  (merlin-check-synchronize t)
  (let ((ident (merlin-ident-under-point)))
    (if ident
	(let ((typ (merlin-type-of-expression ident)))
	  (if (and typ (not (merlin-is-long typ)))
	      (message "%s : %s" ident typ))))))

(defun merlin-show-type-of-point (arg) 
  "Show the type of the identifier under the point. If it is called with a prefix argument, then show the type of the region."

(put 'ocamlatom 'bounds-of-thing-at-point
     'bounds-of-ocaml-atom-at-point)

; overlay management
(defun merlin-create-overlay (var start end face timer)
  "Creates an overlay in the current buffer starting at `start', ending at `end',
