lang/haskell: fail gracefully if stack isn't installed

This commit is contained in:
Henrik Lissner 2018-02-14 07:44:49 -05:00
parent 871883cd89
commit 0ccdc065f9
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 13 additions and 1 deletions

View file

@ -2,8 +2,10 @@
;;;###if (featurep! +intero) ;;;###if (featurep! +intero)
(def-package! intero (def-package! intero
:hook (haskell-mode . intero-mode) :after haskell-mode
:config :config
(add-hook 'haskell-mode-hook #'+haskell|init-intero)
(unless (executable-find "stack") (unless (executable-find "stack")
(warn! "Couldn't find stack. Intero has been disabled.")) (warn! "Couldn't find stack. Intero has been disabled."))

View file

@ -0,0 +1,10 @@
;;; lang/haskell/autoload.el -*- lexical-binding: t; -*-
;;;###autoload
(defun +haskell|init-intero ()
"Initializes `intero-mode' in haskell-mode, unless stack isn't installed.
This is necessary because `intero-mode' doesn't do its own error checks."
(when (derived-mode-p 'haskell-mode)
(if (executable-find "stack")
(intero-mode +1)
(message "Couldn't find stack. Refusing to enable intero-mode."))))