[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 0d04664 115/385: implement batch compilat
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 0d04664 115/385: implement batch compilation |
Date: |
Tue, 5 Oct 2021 23:59:13 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 0d04664bd72c41c78bf378d201fc8b79e6d3784b
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
implement batch compilation
---
haskell-tng-compile.el | 41 +++++++++++++++++++++++++++++++++++++++-
haskell-tng-contrib.el | 33 ++++++++++++++++++++++++++++++++
haskell-tng-font-lock.el | 2 +-
haskell-tng-util.el | 7 +++++++
test/haskell-tng-compile-test.el | 2 ++
5 files changed, 83 insertions(+), 2 deletions(-)
diff --git a/haskell-tng-compile.el b/haskell-tng-compile.el
index 019729a..0aad467 100644
--- a/haskell-tng-compile.el
+++ b/haskell-tng-compile.el
@@ -13,16 +13,55 @@
(require 'compile)
(require 'ansi-color)
-;; FIXME implement batch compilation
;; TODO prettify-symbol rules for home dirs and project dirs, etc
;; TODO set compilation-directory when opening the file
;; TODO set compilation-environment to include TASTY envvars
(defvar haskell-tng-compile-error-regexp-alist
"The `compilation-error-regexp-alist' for `haskell-tng'."
+ ;; FIXME error-regexp-alist
nil
)
+(defvar haskell-tng-compile:history '("cabal v2-build -O0"))
+(defvar-local haskell-tng-compile:command nil)
+(defvar-local haskell-tng-compile:alt "cabal v2-clean")
+
+(defun haskell-tng-compile (&optional edit-command)
+ "`compile' specialised to Haskell:
+
+1. Runs the command from the cabal project directory.
+2. ghc info, warning and error detection.
+
+First use in a buffer or calling with a prefix will prompt for a
+command, otherwise the last command is used.
+
+The command history is global across all Haskell files.
+
+A universal argument will invoke `haskell-tng-compile:alt'."
+ (interactive "P")
+ (save-some-buffers (not compilation-ask-about-save)
+ compilation-save-buffers-predicate)
+ (let* ((last haskell-tng-compile:command)
+ (command (pcase edit-command
+ ((and 'nil (guard last)) last)
+ ('- haskell-tng-compile:alt)
+ (_ (read-shell-command
+ "Compile command: "
+ (or last (car haskell-tng-compile:history))
+ '(haskell-tng-compile:history . 1))))))
+ (setq-local haskell-tng-compile:command command)
+
+ (when-let (default-directory
+ (haskell-tng:locate-dominating-file
+ (rx (| "cabal.project" "cabal.project.local"
"cabal.project.freeze"
+ (: (+ any) ".cabal")))))
+ (compilation-start
+ command
+ 'haskell-tng-compilation-mode
+ ;; TODO name the compilation buffer
+ ))))
+
(defun haskell-tng-compile:ansi-color ()
(ansi-color-apply-on-region compilation-filter-start (point-max)))
diff --git a/haskell-tng-contrib.el b/haskell-tng-contrib.el
new file mode 100644
index 0000000..db43386
--- /dev/null
+++ b/haskell-tng-contrib.el
@@ -0,0 +1,33 @@
+;;; haskell-tng-contrib.el --- Untested features -*- lexical-binding: t -*-
+
+;; Copyright (C) 2019 Tseen She
+;; License: GPL 3 or any later version
+
+;;; Commentary:
+;;
+;; Untested / untestable commands that are either contributed by the community
+;; or require an external process to exist on PATH.
+;;
+;;; Code:
+
+(require 'subr-x)
+
+;; TODO a generic wrapper around commands that can be downloaded and built
using
+;; cabal v2-install.
+
+(defun haskell-tng-contrib:stylish-haskell ()
+ "Apply `stylish-haskell' rules."
+ (interactive)
+ (save-buffer)
+ (call-process "stylish-haskell" nil nil nil "-i" buffer-file-name)
+ (revert-buffer t t t))
+
+(defun haskell-tng-contrib:stack2cabal ()
+ "Prepare a stack project for use with cabal."
+ (interactive)
+ (when-let (default-directory
+ (locate-dominating-file default-directory "stack.yaml"))
+ (call-process "stack2cabal")))
+
+(provide 'haskell-tng-contrib)
+;;; haskell-tng-contrib.el ends here
diff --git a/haskell-tng-font-lock.el b/haskell-tng-font-lock.el
index 70b98b5..1732d3d 100644
--- a/haskell-tng-font-lock.el
+++ b/haskell-tng-font-lock.el
@@ -69,7 +69,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Here is the `font-lock-keywords' table of matchers and highlighters.
-(defvar
+(defconst
haskell-tng:keywords
;; These regexps use the `rx' library so we can reuse common subpatterns. It
;; also increases the readability of the code and, in many cases, allows us
to
diff --git a/haskell-tng-util.el b/haskell-tng-util.el
index 6c1e27e..aca9515 100644
--- a/haskell-tng-util.el
+++ b/haskell-tng-util.el
@@ -39,5 +39,12 @@
(forward-symbol -1)
(haskell-tng:indent-close)))
+(defun haskell-tng:locate-dominating-file (regexp)
+ "`locate-dominating-file' but starting from `default-directory'
+and taking a regexp."
+ (locate-dominating-file
+ default-directory
+ (lambda (dir) (directory-files dir nil regexp))))
+
(provide 'haskell-tng-util)
;;; haskell-tng-util.el ends here
diff --git a/test/haskell-tng-compile-test.el b/test/haskell-tng-compile-test.el
index 8f214cf..062c363 100644
--- a/test/haskell-tng-compile-test.el
+++ b/test/haskell-tng-compile-test.el
@@ -70,4 +70,6 @@
;; fontified t
(should (have-expected-errors (testdata "src/tasty-failure.compile"))))
+;; TODO test invoking haskell-tng-compile in a real project directory
+
;;; haskell-tng-compile-test.el ends here
- [nongnu] elpa/haskell-tng-mode 1f1110a 073/385: transcribe the grammar rules, (continued)
- [nongnu] elpa/haskell-tng-mode 1f1110a 073/385: transcribe the grammar rules, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 01789b1 075/385: y u no haskell-mode?, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode b8f3e3f 079/385: back out incomplete grammar rules, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 9e19b2b 080/385: double down on simpler grammar, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6e7a24f 083/385: lexer identifies conid / varid, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode b12e49a 086/385: consym, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 7d6fa3d 091/385: thoughts on lexers, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6a05d12 090/385: planning for indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 2060f7a 092/385: thoughts on indentation testing, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6d2d764 094/385: skeleton for indentation tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 0d04664 115/385: implement batch compilation,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode adb3c50 143/385: better insert indentation suggestions, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e79577e 132/385: match ghc source paths when compiling, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 8ec4807 145/385: somehow dropped font-lock-extend-region-multiline, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode d3a6a22 147/385: no todos in the test/src dir, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 85f20b1 154/385: indent coproducts, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3dbb883 013/385: more progress on multiline type expansion, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode c6382e1 036/385: almost got it with imports, then I lost it..., ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f3e3838 070/385: starting to transcribe the expression table, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ceaec13 098/385: groundwork for tab cycling, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 8b6d545 178/385: split all the tests, ELPA Syncer, 2021/10/06