-
-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define default directory for haskell-stack-ghc checker #1007
Define default directory for haskell-stack-ghc checker #1007
Conversation
@@ -6976,6 +6976,36 @@ Otherwise return the previously used cache directory." | |||
(or flycheck-haskell-ghc-cache-directory | |||
(make-temp-file "flycheck-haskell-ghc-cache" 'directory)))) | |||
|
|||
(defun flycheck-haskell--default-directory (checker) | |||
"Come up with a sutable default directory for Haskell to run checker in." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Come up sounds strange. Why not simply "find"?
Please also extend the docstring to explain what a "suitable" directory would be, i.e. document the behaviour of the function as well.
(replace-regexp-in-string | ||
(rx (* (any " \t\n")) eos) | ||
"" | ||
(shell-command-to-string "stack path --project-root")))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use process-lines instead of shell-command-to-string. We should not use shell commands without need.
Thanks. I've done a cursory review, will look at the details tomorrow. |
@flycheck/haskell @purcell Would you also take a look? Maybe also test this PR on different Haskell projects? |
@lunaryorn I've amended commit with your suggestions. |
@sergv, Looks good, thank you for writing this! I'm looking forward to using it. |
LGTM. I tried this patch on top of flycheck HEAD with a fairly vanilla stack project and all was well, so I'm pretty confident this will work. |
@@ -6976,6 +6976,45 @@ Otherwise return the previously used cache directory." | |||
(or flycheck-haskell-ghc-cache-directory | |||
(make-temp-file "flycheck-haskell-ghc-cache" 'directory)))) | |||
|
|||
(defun flycheck-haskell--find-default-directory (checker) | |||
"Come up with a sutable default directory for Haskell to run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sutable
→ suitable
I've added quick review notes as well. Thanks for this PR! |
@purcell Thanks for the review-of-the-review :)) |
@cpitclaudel I've rebased on master and added commit that fixes review notes |
(process-lines "stack" "path" "--project-root")) | ||
(stack-dir | ||
(when stack-output | ||
(car stack-output)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sergv The when
guard is redundant. (car nil)
is perfectly safe and evaluates to nil
so it's perfectly safe to just do (car (process-lines …))
.
@sergv Would you add a note about this change to |
LGTM. Thanks for the change 😊 I think though that #1012 should go in first. |
@lunaryorn Indeed, I missed it. Thank you! |
Default directory is detected either by looking for
stack.yaml
or askingstack path --project-root
forhaskel-stack-ghc
checker or by looking for cabal file in case ofhaskell-ghc
checker.@mrkkrp Please comment, if you think something should be done differently.