diff --git a/Check.hs b/Check.hs index d3af95c..e0513fd 100644 --- a/Check.hs +++ b/Check.hs @@ -31,7 +31,7 @@ check opt fileName = withGHC $ do clearWarnings readRef ref where - options = ["-Wall","-fno-warn-unused-do-bind"] + options = ["-Wall","-fno-warn-unused-do-bind"] ++ map ((++) "-i") (checkIncludes opt) handleParseError ref e = do liftIO . writeIORef ref $ errBagToStrList . srcErrorMessages $ e return Succeeded diff --git a/GHCMod.hs b/GHCMod.hs index 92b644a..38ecf84 100644 --- a/GHCMod.hs +++ b/GHCMod.hs @@ -26,7 +26,7 @@ usage = "ghc-mod version 0.6.0\n" ++ "\t ghc-mod list [-l]\n" ++ "\t ghc-mod lang [-l]\n" ++ "\t ghc-mod browse [-l] [-o] [ ...]\n" - ++ "\t ghc-mod check \n" + ++ "\t ghc-mod check [-i inc] \n" ++ "\t ghc-mod type \n" ++ "\t ghc-mod info \n" ++ "\t ghc-mod lint [-h opt] \n" @@ -39,6 +39,7 @@ defaultOptions :: Options defaultOptions = Options { convert = toPlain , hlintOpts = [] + , checkIncludes = [] , operators = False , packageConfs = [] , useUserPackageConf = True @@ -60,6 +61,9 @@ argspec = [ Option "l" ["tolisp"] , Option "" ["no-user-package-conf"] (NoArg (\opts -> opts{ useUserPackageConf = False })) "do not read the user package database" + , Option "i" ["include"] + (ReqArg (\i opts -> opts{ checkIncludes = i : (checkIncludes opts)}) "include") + "directory to include in search for modules" ] parseArgs :: [OptDescr (Options -> Options)] -> [String] -> (Options, [String]) diff --git a/Types.hs b/Types.hs index e5a3a2f..c459c70 100644 --- a/Types.hs +++ b/Types.hs @@ -11,6 +11,7 @@ import GHC.Paths (libdir) data Options = Options { convert :: [String] -> String , hlintOpts :: [String] + , checkIncludes :: [String] , operators :: Bool , packageConfs :: [FilePath] , useUserPackageConf :: Bool diff --git a/elisp/ghc-flymake.el b/elisp/ghc-flymake.el index 366b100..04bb15e 100644 --- a/elisp/ghc-flymake.el +++ b/elisp/ghc-flymake.el @@ -16,6 +16,15 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defcustom ghc-flymake-check-includes nil + "list of directories to include when checking file" + :type '(repeat string) + :risky nil + :require 'ghc-flymake + :group 'ghc-flymake) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (defconst ghc-error-buffer-name "*GHC Errors*") (defconst ghc-flymake-allowed-file-name-masks @@ -44,8 +53,11 @@ (if ghc-flymake-command (let ((hopts (ghc-mapconcat (lambda (x) (list "-h" x)) opts))) `(,@hopts "lint" ,file)) - (list "check" file))) - + (if (null ghc-flymake-check-includes) + (list "check" file) + (let ((includes (ghc-mapconcat (lambda (x) (list "-i" x)) ghc-flymake-check-includes))) + `("check" ,@includes ,file))))) + (defun ghc-flymake-toggle-command () (interactive) (setq ghc-flymake-command (not ghc-flymake-command))