Skip to content

Commit e74ec5a

Browse files
Update 'auto mode to consider nix-shell.
1 parent 1a16c90 commit e74ec5a

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

haskell-process.el

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686

8787
(defcustom haskell-process-args-nix-shell
8888
'("shell.nix")
89-
"The path for starting nix-shell."
89+
"Any arguments for starting nix-shell."
9090
:group 'haskell-interactive
9191
:type '(choice string (repeat string)))
9292

@@ -120,7 +120,7 @@ See `haskell-process-do-cabal' for more details."
120120
'auto
121121
"The inferior Haskell process type to use."
122122
:type '(choice (const auto) (const ghci) (const cabal-repl) (const cabal-dev) (const cabal-ghci)
123-
(const nix-shell-ghci) (const nix-shell-cabal-repl)
123+
(const nix-shell-ghci) (const nix-shell-cabal-repl))
124124
:group 'haskell-interactive)
125125

126126
(defcustom haskell-process-log
@@ -535,12 +535,17 @@ to be loaded by ghci."
535535
(defun haskell-process-type ()
536536
"Return `haskell-process-type', or a guess if that variable is 'auto."
537537
(if (eq 'auto haskell-process-type)
538-
(if (locate-dominating-file default-directory
539-
(lambda (f)
540-
(or (string= ".cabal-sandbox" f)
541-
(string-match-p "\\.cabal\\'" f))))
542-
'cabal-repl
543-
'ghci)
538+
(let ((nix-shell-found (locate-dominating-file default-directory
539+
(lambda (f)
540+
(string= "shell.nix" f))))
541+
(cabal-found (locate-dominating-file default-directory
542+
(lambda (f)
543+
(or (string= ".cabal-sandbox" f)
544+
(string-match-p "\\.cabal\\'" f))))))
545+
(cond ((and cabal-found nix-shell-found) 'nix-shell-cabal-repl)
546+
(cabal-found 'cabal-repl)
547+
(nix-shell-found 'nix-shell-ghci)
548+
(t 'ghci)))
544549
haskell-process-type))
545550

546551
(defun haskell-process-do-cabal (command)

0 commit comments

Comments
 (0)