   "Cleans the buffer being killed."
   (if merlin-mode
       (merlin-process-remove-user)))
-  
-(defun merlin-insinuate ()
-  "Initialize merlin globally."
-  (add-hook 'after-save-hook (lambda ()
-                               (if merlin-mode
-                                   (merlin-to-point))))
-  (add-hook 'kill-buffer-hook 'merlin-kill-buffer-hook))
-                                      
+ 
+(add-hook 'merlin-mode-hook
+          (lambda ()
+            (add-hook 'kill-buffer-hook 'merlin-kill-buffer-hook nil 'make-it-local)
+            (add-hook 'after-save-hook 'merlin-to-end nil 'make-it-local)))
+
 (defun merlin-kill-all-processes ()
   "Kill all the remaining buffers containing merlin processes."
   (interactive)


(defun merlin-goto-point (data)
  "Go to the point indicated by `DATA' which must be an assoc list with fields line and col"
  (let ((line  (cdr (assoc 'line data)))
        (col   (cdr (assoc 'col data)))
        (lines (line-number-at-pos (point-max))))
    (if (> line lines) 
        (end-of-buffer)
      (progn (goto-char (point-min))
             (forward-line (1- line))
             (move-to-column col)))))

(defun merlin-goto-file-and-point (data &optional same-buffer-force)
  "Go to the file and position indicated by DATA which is an assoc list containing fields file, line and col.

  (let* ((bounds (bounds-of-thing-at-point 'ocaml-atom))
         (start  (if bounds (car bounds) (point)))
         (end    (if bounds (cdr bounds) (point)))
         (string (if bounds (merlin-buffer-substring start end) ""))
         (fallback (list (cons 'assoc nil)
                         (cons 'expr string)
                         (cons 'offset (- (point) start))))
