Merge pull request #35 from conal/master

Auto-completion for compiler option flags and for pragmas
This commit is contained in:
Kazu Yamamoto 2012-01-22 21:34:29 -08:00
commit 8e86f64f05
6 changed files with 37 additions and 4 deletions

1
.ghci Normal file
View File

@ -0,0 +1 @@
:set -idist/build/autogen/

7
.gitignore vendored
View File

@ -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
# .#*

10
Flag.hs Normal file
View File

@ -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-"]
]

View File

@ -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] <module> [<module> ...]\n"
++ "\t ghc-mod check" ++ ghcOptHelp ++ "<HaskellFile>\n"
++ "\t ghc-mod type" ++ ghcOptHelp ++ "<HaskellFile> <module> <expression>\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

View File

@ -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

View File

@ -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