diff --git a/.ghci b/.ghci new file mode 100644 index 0000000..f1b8571 --- /dev/null +++ b/.ghci @@ -0,0 +1 @@ +:set -idist/build/autogen/ diff --git a/.gitignore b/.gitignore index 0d2ac34..b7a81a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,9 @@ dist/ elisp/*.elc +*~ +# Mac OS generates +# .DS_Store + +# Where do these files come from? They're not readable. +# For instance, .#Help.page +# .#* diff --git a/Flag.hs b/Flag.hs new file mode 100644 index 0000000..60105f9 --- /dev/null +++ b/Flag.hs @@ -0,0 +1,10 @@ +module Flag where + +import DynFlags +import Types + +listFlags :: Options -> IO String +listFlags opt = return $ convert opt $ + [ "-f" ++ prefix ++ option + | (option,_,_) <- fFlags, prefix <- ["","no-"] + ] diff --git a/GHCMod.hs b/GHCMod.hs index a12fa93..d3bf94d 100644 --- a/GHCMod.hs +++ b/GHCMod.hs @@ -11,6 +11,7 @@ import Data.Typeable import Data.Version import Info import Lang +import Flag import Lint import List import Paths_ghc_mod @@ -31,6 +32,7 @@ usage = "ghc-mod version " ++ showVersion version ++ "\n" ++ "Usage:\n" ++ "\t ghc-mod list" ++ ghcOptHelp ++ "[-l]\n" ++ "\t ghc-mod lang [-l]\n" + ++ "\t ghc-mod flag [-l]\n" ++ "\t ghc-mod browse" ++ ghcOptHelp ++ "[-l] [-o] [ ...]\n" ++ "\t ghc-mod check" ++ ghcOptHelp ++ "\n" ++ "\t ghc-mod type" ++ ghcOptHelp ++ " \n" @@ -93,11 +95,13 @@ main = flip catches handlers $ do "info" -> withFile (infoExpr opt (safelist cmdArg 2) (safelist cmdArg 3)) (safelist cmdArg 1) "lint" -> withFile (lintSyntax opt) (safelist cmdArg 1) "lang" -> listLanguages opt + "flag" -> listFlags opt "boot" -> do mods <- listModules opt langs <- listLanguages opt + flags <- listFlags opt pre <- browseModule opt "Prelude" - return $ mods ++ langs ++ pre + return $ mods ++ langs ++ flags ++ pre cmd -> throw (NoSuchCommand cmd) putStr res where diff --git a/elisp/ghc-comp.el b/elisp/ghc-comp.el index 56df544..1c05700 100644 --- a/elisp/ghc-comp.el +++ b/elisp/ghc-comp.el @@ -48,6 +48,8 @@ unloaded modules are loaded") (defvar ghc-module-names nil) ;; completion for "import" (defvar ghc-merged-keyword nil) ;; completion for type/func/... (defvar ghc-language-extensions nil) +(defvar ghc-option-flags nil) +(defvar ghc-pragma-names '("LANGUAGE" "OPTIONS_GHC")) (defconst ghc-keyword-prefix "ghc-keyword-") (defvar ghc-keyword-Prelude nil) @@ -56,12 +58,13 @@ unloaded modules are loaded") (defun ghc-comp-init () (let* ((syms '(ghc-module-names ghc-language-extensions + ghc-option-flags ghc-keyword-Prelude)) (vals (ghc-boot (length syms)))) (ghc-set syms vals)) (ghc-add ghc-module-names "qualified") (ghc-add ghc-module-names "hiding") - (ghc-add ghc-language-extensions "LANGUAGE") + ;; (ghc-add ghc-language-extensions "LANGUAGE") (ghc-merge-keywords '("Prelude")) (run-with-idle-timer ghc-idle-timer-interval 'repeat 'ghc-idle-timer)) @@ -172,8 +175,16 @@ unloaded modules are loaded") ghc-module-names) ((save-excursion (beginning-of-line) - (looking-at "{-#")) + (looking-at "{-# LANGUAGE ")) ghc-language-extensions) + ((save-excursion + (beginning-of-line) + (looking-at "{-# OPTIONS_GHC ")) + ghc-option-flags) + ((save-excursion + (beginning-of-line) + (looking-at "{-# ")) + ghc-pragma-names) ((or (bolp) (let ((end (point))) (save-excursion diff --git a/ghc-mod.cabal b/ghc-mod.cabal index 637e966..a2ee77c 100644 --- a/ghc-mod.cabal +++ b/ghc-mod.cabal @@ -23,7 +23,7 @@ Data-Files: Makefile ghc.el ghc-func.el ghc-doc.el ghc-comp.el ghc-flymake.el ghc-command.el ghc-info.el ghc-ins-mod.el Executable ghc-mod Main-Is: GHCMod.hs - Other-Modules: List Browse Cabal CabalDev Check Info Lang Lint Types ErrMsg Paths_ghc_mod + Other-Modules: List Browse Cabal CabalDev Check Info Lang Flag Lint Types ErrMsg Paths_ghc_mod if impl(ghc >= 6.12) GHC-Options: -Wall -fno-warn-unused-do-bind else