 
 (defun merlin-send-command (command &optional callback-if-exn)
   "Send COMMAND (with arguments ARGS) to merlin and returns the result."
-  (merlin--wait-for-answer (merlin-send-command-async
+  (let ((promise (merlin-send-command-async
                             command (lambda (data) data) callback-if-exn)))
+    (when promise
+      (merlin--process-busy-set t)
+      (let ((w32-pipe-read-delay 0)) ;; fix 50ms latency of emacs on win32
+        (while (not (car promise))
+               (accept-process-output (merlin-process) 1.0)))
+      (merlin--process-busy-set nil)
+      (cdr promise))))
 
 ;; SPECIAL CASE OF COMMANDS
 

(defun merlin-process-owner (&optional instance-name)
  "Return the last user of the process of the current buffer."
  (buffer-local-value 'merlin-process-owner (merlin-process-buffer instance-name)))

(defun merlin-start-process (flags &optional configuration)
  "Start the merlin process by fetching the information inside CONFIGURATION. FLAGS contains the list of flags to give merlin.

(defvar merlin-process-queue nil
  "The transaction queue for the local process (only valid in a process buffer).")
(make-variable-buffer-local 'merlin-process-queue)

(defvar merlin--process-busy nil
  "Non-nil if process is busy treating a synchronous operation.")
(make-variable-buffer-local 'merlin--process-busy)

(defvar merlin-process-data nil
  "The process data (as returned by the grouping function) (only valid in a process buffer).")
