integrating hlint.

This commit is contained in:
Kazu Yamamoto
2010-05-06 15:29:55 +09:00
parent 85fdba4ffa
commit bb363c92e7
6 changed files with 62 additions and 9 deletions

View File

@@ -30,7 +30,23 @@
(let ((after-save-hook nil))
(save-buffer))
(let ((file (file-name-nondirectory (buffer-file-name))))
(list ghc-module-command (list "check" file))))
(list ghc-module-command (ghc-flymake-command file))))
(defvar ghc-hlint (ghc-which "hlint"))
(defvar ghc-flymake-command nil) ;; nil: check, t: lint
(defun ghc-flymake-command (file)
(if ghc-flymake-command
(list "-f" ghc-hlint "lint" file)
(list "check" file)))
(defun ghc-flymake-toggle-command ()
(interactive)
(setq ghc-flymake-command (not ghc-flymake-command))
(if ghc-flymake-command
(message "Syntax check with hlint")
(message "Syntax check with GHC")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -49,7 +65,7 @@
(defun ghc-flymake-insert-errors (title errs)
(save-excursion
(insert title "\n")
(mapc (lambda (x) (insert x "\n")) errs)))
(mapc (lambda (x) (insert (ghc-replace-character x ghc-null ghc-newline) "\n")) errs)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@@ -79,4 +79,9 @@
(ghc-add ret (read m))))
(error ()))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst ghc-null 0)
(defconst ghc-newline 10)
(provide 'ghc-func)

View File

@@ -41,6 +41,7 @@
(defvar ghc-insert-key "\et")
(defvar ghc-sort-key "\es")
(defvar ghc-check-key "\C-x\C-s")
(defvar ghc-toggle-key "\C-c\C-c")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
@@ -61,6 +62,7 @@
(define-key haskell-mode-map ghc-insert-key 'ghc-insert-template)
(define-key haskell-mode-map ghc-sort-key 'ghc-sort-lines)
(define-key haskell-mode-map ghc-check-key 'ghc-save-buffer)
(define-key haskell-mode-map ghc-toggle-key 'ghc-flymake-toggle-command)
(ghc-comp-init)
(setq ghc-initialized t)))