Created
January 2, 2019 20:10
-
-
Save emmanueldenloye/3f0715b633056735c71d3c81427111bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun haskell-quick-nix-build () | |
(interactive) | |
(when-let ((original-directory (file-name-directory (buffer-file-name)))) | |
(let ((current-directory original-directory)) | |
(while (and | |
(not | |
(or | |
(string= current-directory (expand-file-name "~")) | |
(string= current-directory (expand-file-name "/")))) | |
(not (directory-files current-directory nil "cabal$"))) | |
(setq current-directory ;this is gross | |
(mapconcat 'identity | |
(reverse | |
(cons "" | |
(cdr | |
(cdr | |
(reverse | |
(split-string | |
current-directory | |
"/")))))) | |
"/"))) | |
(unwind-protect | |
(not-if (directory-files current-directory nil "cabal$") | |
(message "Could not find a cabal file.") | |
(cd current-directory) | |
(compile "nix-shell --run \"cabal build\"" t)) | |
(cd original-directory))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment