 (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?")
+(defvar merlin-idle-delay 0.50
+  "Number of seconds of idle time to wait before printing the type of the ident under the point.
+If user input arrives before this interval of time has elapsed
+after the last input, no documentation will be printed.
+
+If the timer is zero or negative, nothing is done."
+)
+
+(defvar merlin-idle-timer nil
+  "The timer used to print the type of the expression under point")
+
 ;; 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 \"\""

	      (merlin-handle-line buf words)
	      (forward-line))))
	(switch-to-buffer buf))))
    
;; Mode definition
(defun merlin-setup ()
  "Sets up a buffer for use with merlin"
  (interactive)
  (merlin-start-process)
  (auto-complete-mode)
  (setq ac-sources '(merlin-ac-source))
  (merlin-parse)
  (with-current-buffer merlin-type-buffer
    (tuareg-mode))
)
(define-minor-mode merlin-mode
  "Mode to use merlin tool inside OCaml tools."
  nil
  " merlin"
  '(("\C-i" . merlin-tell-previous-lines)
    ("\C-o" . merlin-get-type))
  :after-hook 'merlin-setup)


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

