     (when (merlin-process-dead-p name)
       (let* ((buffer (get-buffer-create buffer-name))
              (process-environment (append
-                                    (if logfile
-                                      (list (format "MERLIN_LOG=%s" (expand-file-name logfile))))
-                                    environment
-                                    process-environment))
-             ;; issue #321, start-file-process not always defined
-             (start-file-process
-               (if (boundp 'start-file-process)
-                 #'start-file-process
-                 #'start-process))
-             ;; issue #341, emacs-pty broken with lines >=1024 chars on OSX
-             (process-connection-type nil)
-             (p (apply start-file-process "merlin" buffer-name
-                       command `("-protocol" "sexp" . ,(append extra-flags flags)))))
+                                   (if logfile
+                                       (list (format "MERLIN_LOG=%s" (expand-file-name logfile))))
+                                   environment
+                                   process-environment))
+             (p (merlin--start-process
+                 `("merlin" ,buffer-name ,command
+                   "-protocol" "sexp" . ,(append extra-flags flags)))))
         (with-current-buffer buffer
           (set-process-query-on-exit-flag p nil)
           (setq merlin-process p)

                  (t (error "Unhandled case in merlin--process-busy-set %S => %S"
                            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.
   CONFIGURATION is an association list with the following keys:

(defun merlin--grouping-function ()
  "Wrapper to call merlin-grouping-function and update internal variable."
  (setq merlin--grouping (merlin--sexp-remove-string-properties
                          (condition-case-unless-debug err
                              (funcall merlin-grouping-function)
                            (error (message "Error in merlin-grouping-function: %S" err) nil))))
  merlin--grouping)

(defun merlin-restart-process ()
