   (message "Instance: %s" instance)
   (merlin-kill-process (get-buffer (merlin-instance-buffer-name instance))))
 
-(defun merlin-is-last-user-p ()
+(defun merlin--acquired-buffer ()
   "Return whether the current buffer was the current user of the merlin process."
-  (equal (merlin-last-user) (buffer-name)))
+  (equal (merlin-process-owner) (buffer-name)))
 
 (defun merlin-process-started-p (name)
   "Return non-nil if the merlin process for the instance NAME is already started."

    (accept-process-output (merlin-process) 0.1 nil t))
  merlin-result)

(defun merlin-reset-user ()
  "Checks whether we need to change the current buffer viewed by merlin."
  (unless (merlin-is-last-user-p)
    (let ((name (buffer-name)))
      (with-current-buffer (merlin-process-buffer)
        (setq merlin-process-last-user name)))
    (merlin-load-project-file)))

(defun merlin-send-command-async (command callback-if-success &optional callback-if-exn)
  "Send COMMAND (with arguments ARGS) to merlin asynchronously.
Give the result to callback-if-success.  If merlin reported an
error and if CALLBACK-IF-EXN is non-nil, call the function with
the error message otherwise print a generic error message."
  (lexical-let*
      ((string (concat (prin1-to-string (if (listp command) command (list command)))
                        "\n"))


;; SPECIAL CASE OF COMMANDS

(defun merlin-refresh ()
  "Refresh changed merlin cmis."
  (interactive)
  (merlin--acquire-buffer)
  (merlin-send-command 'refresh)
  (merlin-after-save))

