Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : master
http://hackage.haskell.org/trac/ghc/changeset/76bde331226e933b65b6433e983c50da1ce3b532 >--------------------------------------------------------------- commit 76bde331226e933b65b6433e983c50da1ce3b532 Author: Paolo Capriotti <[email protected]> Date: Wed Apr 11 14:34:25 2012 +0100 Add support for additional .ghci files in GHCi (#5265) Patch by Sam Anklesaria <[email protected]> >--------------------------------------------------------------- compiler/main/DynFlags.hs | 7 ++++++- docs/users_guide/flags.xml | 6 ++++++ docs/users_guide/ghci.xml | 12 ++++++++++++ ghc/InteractiveUI.hs | 4 ++-- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 2cc8446..13a5f01 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -597,6 +597,7 @@ data DynFlags = DynFlags { flushErr :: FlushErr, haddockOptions :: Maybe String, + ghciScripts :: [String], -- | what kind of {-# SCC #-} to add automatically profAuto :: ProfAuto, @@ -941,6 +942,7 @@ defaultDynFlags mySettings = haddockOptions = Nothing, flags = IntSet.fromList (map fromEnum defaultFlags), warningFlags = IntSet.fromList (map fromEnum standardWarnings), + ghciScripts = [], language = Nothing, safeHaskell = Sf_SafeInfered, thOnLoc = noSrcSpan, @@ -1183,7 +1185,7 @@ setObjectDir, setHiDir, setStubDir, setDumpDir, setOutputDir, setDylibInstallName, setObjectSuf, setHiSuf, setHcSuf, parseDynLibLoaderMode, setPgmP, addOptl, addOptP, - addCmdlineFramework, addHaddockOpts + addCmdlineFramework, addHaddockOpts, addGhciScript :: String -> DynFlags -> DynFlags setOutputFile, setOutputHi, setDumpPrefixForce :: Maybe String -> DynFlags -> DynFlags @@ -1255,6 +1257,8 @@ addCmdlineFramework f d = d{ cmdlineFrameworks = f : cmdlineFrameworks d} addHaddockOpts f d = d{ haddockOptions = Just f} +addGhciScript f d = d{ ghciScripts = f : ghciScripts d} + -- ----------------------------------------------------------------------------- -- Command-line options @@ -1545,6 +1549,7 @@ dynamic_flags = [ , Flag "haddock" (NoArg (setDynFlag Opt_Haddock)) , Flag "haddock-opts" (hasArg addHaddockOpts) , Flag "hpcdir" (SepArg setOptHpcDir) + , Flag "ghci-script" (hasArg addGhciScript) ------- recompilation checker -------------------------------------- , Flag "recomp" (NoArg (do unSetDynFlag Opt_ForceRecomp diff --git a/docs/users_guide/flags.xml b/docs/users_guide/flags.xml index 53bd4bf..0572039 100644 --- a/docs/users_guide/flags.xml +++ b/docs/users_guide/flags.xml @@ -493,6 +493,12 @@ <entry>-</entry> </row> <row> + <entry><option>-ghci-script</option></entry> + <entry>Read additional <filename>.ghci</filename> files</entry> + <entry>dynamic</entry> + <entry>-</entry> + </row> + <row> <entry><option>-read-dot-ghci</option></entry> <entry>Enable reading of <filename>.ghci</filename> files</entry> <entry>static</entry> diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml index 3e0d341..87ba79d 100644 --- a/docs/users_guide/ghci.xml +++ b/docs/users_guide/ghci.xml @@ -3105,6 +3105,10 @@ warning settings: wiki page: <ulink url="http://haskell.org/haskellwiki/GHC/GHCi">GHC/GHCi</ulink></para> + <para>Additionally, any files specified with + <literal>-ghci-script</literal> flags will be read after the + standard files, allowing the use of custom .ghci files.</para> + <para>Two command-line options control whether the startup files files are read:</para> @@ -3131,6 +3135,14 @@ warning settings: be used to override a previous <option>-ignore-dot-ghci</option> option.</para> </listitem> + <term> + <option>-ghci-script</option> + <indexterm><primary><option>-ghci-script</option></primary></indexterm> + </term> + <listitem> + <para>Read a specific file after the usual startup files. + Maybe be specified repeatedly for multiple inputs.</para> + </listitem> </varlistentry> </variablelist> diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs index 9761f42..b7e6241 100644 --- a/ghc/InteractiveUI.hs +++ b/ghc/InteractiveUI.hs @@ -432,8 +432,9 @@ runGHCi paths maybe_exprs = do setGHCContextFromGHCiState + dflags <- getDynFlags when (read_dot_files) $ do - mcfgs0 <- sequence [ current_dir, app_user_dir, home_dir ] + mcfgs0 <- sequence $ [ current_dir, app_user_dir, home_dir ] ++ map (return . Just ) (ghciScripts dflags) mcfgs <- liftIO $ mapM canonicalizePath' (catMaybes mcfgs0) mapM_ sourceConfigFile $ nub $ catMaybes mcfgs -- nub, because we don't want to read .ghci twice if the @@ -455,7 +456,6 @@ runGHCi paths maybe_exprs = do -- if verbosity is greater than 0, or we are connected to a -- terminal, display the prompt in the interactive loop. is_tty <- liftIO (hIsTerminalDevice stdin) - dflags <- getDynFlags let show_prompt = verbosity dflags > 0 || is_tty -- reset line number _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
