 (defun merlin-setup ()
   "Sets up a buffer for use with merlin"
   (interactive)
-  (progn
-    (merlin-start-process)
-    (when (featurep 'auto-complete)
-      (auto-complete-mode)
-      (add-to-list 'ac-sources 'merlin-ac-source))
-    (set (make-local-variable 'merlin-lock-point) (point-min))
-    (set (make-local-variable 'merlin-buffer) nil)
-    (set (make-local-variable 'merlin-result) nil)
-    (set (make-local-variable 'merlin-idle-point) nil)
-    (set (make-local-variable 'merlin-completion-point) nil)
-    (set (make-local-variable 'merlin-ready) nil)
-    (set (make-local-variable 'merlin-pending-errors) nil)
-    (set (make-local-variable 'merlin-pending-errors-overlay) nil)
-    (set (make-local-variable 'merlin-type-overlay) nil)
-    (set (make-local-variable 'merlin-lock-zone-highlight-overlay) nil)
-    (set (make-local-variable 'merlin-lock-zone-margin-overlay) nil)
-    (set (make-local-variable 'merlin-error-prefix) nil)
-    (set (make-local-variable 'merlin-enclosing-types) nil)
-    (set (make-local-variable 'merlin-enclosing-offset) nil)
-    (set (make-local-variable 'merlin-last-point-type) nil)
-    (add-to-list 'after-change-functions 'merlin-edit)
-    (set-process-query-on-exit-flag (merlin-get-process) nil)
-    (merlin-parse)
-    (if (and (> merlin-idle-delay 0.) (not merlin-idle-timer))
-	(setq merlin-idle-timer
-              (run-with-idle-timer merlin-idle-delay t 'merlin-idle-hook)))
-    (with-current-buffer merlin-type-buffer
-      (funcall merlin-favourite-caml-mode))))
+  ; if there is not yet a buffer for the current buffer, create one
+  (if (not (merlin-get-process))
+      (merlin-start-process))
+  (when (featurep 'auto-complete)
+    (auto-complete-mode)
+    (add-to-list 'ac-sources 'merlin-ac-source))
+  (set (make-local-variable 'merlin-lock-point) (point-min))
+  (set (make-local-variable 'merlin-buffer) nil)
+  (set (make-local-variable 'merlin-result) nil)
+  (set (make-local-variable 'merlin-idle-point) nil)
+  (set (make-local-variable 'merlin-completion-point) nil)
+  (set (make-local-variable 'merlin-ready) nil)
+  (set (make-local-variable 'merlin-pending-errors) nil)
+  (set (make-local-variable 'merlin-pending-errors-overlay) nil)
+  (set (make-local-variable 'merlin-type-overlay) nil)
+  (set (make-local-variable 'merlin-lock-zone-highlight-overlay) nil)
+  (set (make-local-variable 'merlin-lock-zone-margin-overlay) nil)
+  (set (make-local-variable 'merlin-error-prefix) nil)
+  (set (make-local-variable 'merlin-enclosing-types) nil)
+  (set (make-local-variable 'merlin-enclosing-offset) nil)
+  (set (make-local-variable 'merlin-last-point-type) nil)
+  (add-to-list 'after-change-functions 'merlin-edit)
+  (merlin-parse)
+  (if (and (> merlin-idle-delay 0.) (not merlin-idle-timer))
+      (setq merlin-idle-timer
+            (run-with-idle-timer merlin-idle-delay t 'merlin-idle-hook)))
+  (with-current-buffer merlin-type-buffer
+    (funcall merlin-favourite-caml-mode)))
 (define-minor-mode merlin-mode
   "Mode to use merlin tool inside OCaml tools."
   nil

In particular you can specify nil, meaning that the locked zone is not represented at the screen"
  )


;; Internal variables


; Process / Reception related variables
(defvar merlin-process nil
  "The merlin process associated to the current buffer")
(defvar merlin-result nil
  "Temporary variables to store command results")
(defvar merlin-lock-zone-highlight-overlay nil 

          (merlin-setup)
        (progn
          (if (buffer-file-name)
              (message "merlin can only operate on ml files")
              nil)
          (merlin-mode -1)))
    (progn
      (cancel-timer merlin-idle-timer)
      (if merlin-lock-zone-highlight-overlay
          (delete-overlay merlin-lock-zone-highlight-overlay))
      (if merlin-lock-zone-margin-overlay
          (delete-overlay merlin-lock-zone-margin-overlay))
      (merlin-delete-error-overlays)
      (merlin-process-remove-user)
)))

(defun merlin-kill-buffer-hook ()
  "Cleans the buffer being killed."
  (if merlin-mode
      (merlin-mode -1)))
  
(defun merlin-insinuate ()
  "Initialize merlin."
  (add-hook 'kill-buffer-hook 'merlin-kill-buffer-hook))
                                      
(defun merlin-kill-all-buffers ()
  "Kill all the remaining buffers containing merlin processes"
  (interactive)
  (merlin-kill-process))

(provide 'merlin)
