 (defun intero-start-process-in-buffer (buffer &optional targets source-buffer)
   "Start an Intero worker in BUFFER for TARGETS, automatically
 performing a initial actions in SOURCE-BUFFER, if specified."
-  (let* ((options (intero-make-options-list targets))
+  (let* ((options
+          (intero-make-options-list
+           (or targets
+               (list (buffer-local-value 'intero-package-name buffer)))))
          (arguments options)
          (process (with-current-buffer buffer
+                    (when debug-on-error
+                      (message "Intero arguments: %S" arguments))
                     (message "Booting up intero ...")
                     (apply #'start-process "stack" buffer "stack" "ghci"
                            arguments))))

                "--docker-run-args=--interactive=true --tty=false"
                "--no-load"
                "--no-build")

          (let ((dir (make-temp-file "intero" t)))
            (list "--ghci-options"
                  (format "%S" (concat "-odir=" dir))

(defun intero-package-name ()
  "Get the current package name from a nearby .cabal file. If
there is none, return empty string."
  (or intero-package-name
      (setq intero-package-name
            (let ((cabal-file (intero-cabal-find-file)))
              (if cabal-file
                  (replace-regexp-in-string
                   ".cabal$" ""
                   (file-name-nondirectory (intero-cabal-find-file)))
                "")))))

(defun intero-cabal-find-file (&optional dir)
  "Search for package description file upwards starting from DIR.
