 
 (defun merlin-wait-for-answer ()
   "Waits for merlin to answer"
-  (let ((times 0))
-    (while
-        (and (< times 20)
-             (or
-              (not (accept-process-output (merlin-get-process) 0.1 nil nil))
-              (not merlin-ready)))
-      (setq times (+ times 1)))
-    (setq merlin-buffer nil)
-    (setq merlin-ready nil)))
+  (with-current-buffer (merlin-get-process-buffer-name)
+    (let ((times 0))
+      (while
+          (and (< times 20)
+               (or
+                (not (accept-process-output (merlin-get-process) 0.1 nil nil))
+                (not merlin-ready)))
+        (setq times (+ times 1)))
+      (setq merlin-buffer nil)
+      (setq merlin-ready nil))))
 
 (defun merlin-start-process ()
   "Start the merlin process for the current buffer"

                                (set ,var nil)))))
      
;; PROCESS MANAGEMENT
(defun merlin-get-process ()
  "Returns the process of the current buffer"
  merlin-process)

(defun merlin-get-process-buffer-name ()
  "Returns the buffer name of the merlin process associated to the current buffer"
  "* merlin *")

(defun merlin-get-process-name ()
  "Returns the process name for the current buffer"
  "merlin"
  )



			 merlin-command))
        (name (buffer-name)))
;; set the global process (for now)
    (set (make-local-variable 'merlin-local-process) p)
    (set-process-query-on-exit-flag p nil)
    (set-process-filter p 'merlin-filter)
    (push p merlin-processes)
  ; don't forget to initialize temporary variable
  (with-current-buffer (merlin-get-process-buffer-name)
    (set (make-local-variable 'merlin-process-users) (list name))
