hlint options can be specified from ghc-hlint-options.

This commit is contained in:
Kazu Yamamoto 2010-06-14 11:56:35 +09:00
parent da8975c03f
commit f30eb343b0
5 changed files with 25 additions and 8 deletions

View File

@ -22,7 +22,7 @@ usage = "ghc-mod version 0.4.2\n"
++ "\t ghc-mod lang\n"
++ "\t ghc-mod browse <module> [<module> ...]\n"
++ "\t ghc-mod check <HaskellFile>\n"
++ "\t ghc-mod lint <HaskellFile>\n"
++ "\t ghc-mod [-h opt] lint <HaskellFile>\n"
++ "\t ghc-mod boot\n"
++ "\t ghc-mod help\n"
@ -31,12 +31,16 @@ usage = "ghc-mod version 0.4.2\n"
defaultOptions :: Options
defaultOptions = Options {
convert = toPlain
, hlintOpts = []
}
argspec :: [OptDescr (Options -> Options)]
argspec = [ Option "l" ["tolisp"]
(NoArg (\opts -> opts { convert = toLisp }))
"print as a list of Lisp"
, Option "h" ["hlintOpt"]
(ReqArg (\h opts -> opts { hlintOpts = h : hlintOpts opts }) "hlintOpt")
"hint to be ignored"
]
parseArgs :: [OptDescr (Options -> Options)] -> [String] -> (Options, [String])

View File

@ -6,9 +6,9 @@ import Language.Haskell.HLint
import Types
lintSyntax :: Options -> String -> IO String
lintSyntax _ file = pretty <$> lint file
lintSyntax opt file = pretty <$> lint opt file
where
pretty = unlines . map (concat . intersperse "\0" . lines)
lint :: String -> IO [String]
lint file = map show <$> hlint [file, "--quiet", "--ignore=Use camelCase"]
lint :: Options -> String -> IO [String]
lint opt file = map show <$> hlint ([file, "--quiet"] ++ hlintOpts opt)

View File

@ -5,7 +5,8 @@ import GHC
import GHC.Paths (libdir)
data Options = Options {
convert :: [String] -> String
convert :: [String] -> String
, hlintOpts :: [String]
}
withGHC :: Ghc [String] -> IO [String]

View File

@ -10,6 +10,12 @@
(require 'flymake)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar ghc-hlint-options nil "*Hlint options")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar ghc-error-buffer-name "*GHC Errors*")
(defvar ghc-flymake-allowed-file-name-masks
@ -30,13 +36,14 @@
(let ((after-save-hook nil))
(save-buffer))
(let ((file (file-name-nondirectory (buffer-file-name))))
(list ghc-module-command (ghc-flymake-command file))))
(list ghc-module-command (ghc-flymake-command file ghc-hlint-options))))
(defvar ghc-flymake-command nil) ;; nil: check, t: lint
(defun ghc-flymake-command (file)
(defun ghc-flymake-command (file opts)
(if ghc-flymake-command
(list "lint" file)
(let ((hopts (ghc-mapconcat (lambda (x) (list "-h" x)) opts)))
`(,@hopts "lint" ,file))
(list "check" file)))
(defun ghc-flymake-toggle-command ()

View File

@ -81,6 +81,11 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ghc-mapconcat (func list)
(apply 'append (mapcar func list)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst ghc-null 0)
(defconst ghc-newline 10)