       (with-current-buffer buffer
         (erase-buffer)
         (setq intero-targets targets)
+        (setq intero-source-buffer source-buffer)
         (setq intero-arguments arguments)
+        (setq intero-starting t)
         (setq intero-callbacks
-              (list (list source-buffer
-                          (lambda (source-buffer _msg)
-                            (when source-buffer
-                              (with-current-buffer source-buffer
-                                (when flycheck-mode
-                                  (run-with-timer 0 nil
-                                                  'intero-call-in-buffer
-                                                  (current-buffer)
-                                                  'intero-flycheck-buffer))))
+              (list (list (cons source-buffer
+                                buffer)
+                          (lambda (buffers _msg)
+                            (let ((source-buffer (car buffers))
+                                  (process-buffer (cdr buffers)))
+                              (with-current-buffer process-buffer
+                                (setq-local intero-starting nil))
+                              (when source-buffer
+                                (with-current-buffer source-buffer
+                                  (when flycheck-mode
+                                    (run-with-timer 0 nil
+                                                    'intero-call-in-buffer
+                                                    (current-buffer)
+                                                    'intero-flycheck-buffer)))))
                             (message "Booted up intero!"))))))
       (set-process-filter process
                           (lambda (process string)

  (flycheck-mode)
  (flycheck-buffer))

(defun intero-make-options-list (targets)
  "Make the stack ghci options list."
  (append (list "--with-ghc"
                "intero"
                "--docker-run-args=--interactive=true --tty=false"
                "--no-load"
                "--no-build")
          (let ((dir (make-temp-file "intero" t)))
            (list "--ghci-options"
                  (concat "-odir=" dir)

  "Targets used for the stack process.")
(make-variable-buffer-local 'intero-targets)

(defvar intero-source-buffer (list)
  "Buffer from which Intero was first requested to start.")
(make-variable-buffer-local 'intero-source-buffer)

(defvar intero-project-root nil
  "The project root of the current buffer.")
(make-variable-buffer-local 'intero-project-root)
