 (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--process-busy (&optional instance-name)
+  (buffer-local-value 'merlin--process-busy (merlin-process-buffer instance-name)))
+
+(defun merlin--process-busy-set (value &optional instance-name)
+  (with-current-buffer (merlin-process-buffer instance-name)
+     (assert (eq merlin--process-busy (not value)))
+     (setq merlin--process-busy value)))
 
 (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-data nil
  "The process data (as returned by the grouping function) (only valid in a process buffer).")


(defun merlin-send-command (command &optional callback-if-exn)
  "Send COMMAND (with arguments ARGS) to merlin and returns the result."
  (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

