   "Restart the merlin toplevel for this buffer, taking into account new flags."
   (interactive)
   (let ((users (merlin-get-current-buffer-users)))
-    (if (merlin-process-started-p)
-        (ignore-errors (merlin-kill-process)))
+    (when (merlin-process-started-p)
+      (ignore-errors (merlin-kill-process)))
     (setq merlin-local-process (merlin-start-process merlin-current-flags users))
     (setq merlin-pending-errors nil)
     (merlin-load-project-file)

(defun merlin-start-process (flags &optional users)
  "Start the merlin process for the current buffer.
FLAGS are a list of strings denoting the parameters to be passed
to merlin. USERS can be used to set the users of this
buffer. Return the process created"
  (get-buffer-create (merlin-get-process-buffer-name))
  (let ((p (apply #'start-file-process (merlin-get-process-name)
                         (merlin-get-process-buffer-name)

  (add-to-list 'after-change-functions 'merlin-sync-edit)
  (merlin-load-project-file))

(defun merlin-can-handle-buffer ()
  "Return true if current buffer corresponds to a ML file."
  (and (buffer-file-name)
       (equal (file-name-extension (buffer-file-name)) "ml")))

(defun merlin-process-dead-p ()
  "Return non-nil if merlin process is dead."
  (and (merlin-get-process)
       (not (equal (process-status (merlin-get-process)) 'run))))

(defun merlin-lighter ()
  "Return the lighter for merlin which indicates the status of merlin process."
  (if (merlin-process-dead-p) " merlin(??)" " merlin"))

;;;###autoload

