Ticket #5265: dyn5265..patch

File dyn5265..patch, 4.5 KB (added by SamAnklesaria, 4 years ago)
  • compiler/main/DynFlags.hs

    From 74172e48d61dfa904376a25383c26d426a6d01eb Mon Sep 17 00:00:00 2001
    From: Sam Anklesaria <[email protected]>
    Date: Sun, 31 Jul 2011 23:35:05 -0500
    Subject: [PATCH] trac #5265 (support for additional .ghci files in GHCi)
    
    ---
     compiler/main/DynFlags.hs  |    6 ++++++
     docs/users_guide/flags.xml |    6 ++++++
     docs/users_guide/ghci.xml  |   12 ++++++++++++
     ghc/InteractiveUI.hs       |    4 ++--
     4 files changed, 26 insertions(+), 2 deletions(-)
    
    diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
    index 68410cd..49d2d35 100644
    a b data DynFlags = DynFlags { 
    553553  log_action            :: LogAction,
    554554
    555555  haddockOptions :: Maybe String
     556
     557  ghciScripts :: [String]
    556558 }
    557559
    558560data Settings = Settings {
    defaultDynFlags mySettings = 
    860862        dirsToClean    = panic "defaultDynFlags: No dirsToClean",
    861863        generatedDumps = panic "defaultDynFlags: No generatedDumps",
    862864        haddockOptions = Nothing,
     865        ghciScripts = [],
    863866        flags = defaultFlags,
    864867        warningFlags = standardWarnings,
    865868        language = Nothing,
    addCmdlineFramework f d = d{ cmdlineFrameworks = f : cmdlineFrameworks d} 
    11401143
    11411144addHaddockOpts f d = d{ haddockOptions = Just f}
    11421145
     1146addGhciScript f d = d{ ghciScripts = f : ghciScripts d}
     1147
    11431148-- -----------------------------------------------------------------------------
    11441149-- Command-line options
    11451150
    dynamic_flags = [ 
    14131418  , flagA "haddock"        (NoArg (setDynFlag Opt_Haddock))
    14141419  , flagA "haddock-opts"   (hasArg addHaddockOpts)
    14151420  , flagA "hpcdir"         (SepArg setOptHpcDir)
     1421  , flagA "ghci-script"      (hasArg addGhciScript)
    14161422
    14171423        ------- recompilation checker --------------------------------------
    14181424  , flagA "recomp"         (NoArg (do { unSetDynFlag Opt_ForceRecomp
  • docs/users_guide/flags.xml

    diff --git a/docs/users_guide/flags.xml b/docs/users_guide/flags.xml
    index 37bf397..8a9634d 100644
    a b  
    486486              <entry>static</entry>
    487487              <entry>-</entry>
    488488            </row>
     489        <row>
     490          <entry><option>-ghci-script</option></entry>
     491          <entry>Read additional <filename>.ghci</filename> files</entry>
     492          <entry>dynamic</entry>
     493          <entry>-</entry>
     494       </row>
    489495            <row>
    490496              <entry><option>-read-dot-ghci</option></entry>
    491497              <entry>Enable reading of <filename>.ghci</filename> files</entry>
  • docs/users_guide/ghci.xml

    diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml
    index 72481eb..60843be 100644
    a b Prelude> :set -fno-glasgow-exts 
    28432843    wiki page: <ulink
    28442844      url="http://haskell.org/haskellwiki/GHC/GHCi">GHC/GHCi</ulink></para>
    28452845
     2846        <para>Additionally, any files specified with
     2847    <literal>-ghci-script</literal> flags will be read after the
     2848    standard files, allowing the use of custom .ghci files.</para>
     2849
    28462850    <para>Two command-line options control whether the
    28472851    startup files files are read:</para>
    28482852
    Prelude> :set -fno-glasgow-exts 
    28692873          be used to override a previous
    28702874          <option>-ignore-dot-ghci</option> option.</para>
    28712875        </listitem>
     2876        <term>
     2877         <option>-ghci-script</option>
     2878         <indexterm><primary><option>-ghci-script</option></primary></indexterm>
     2879    </term>
     2880        <listitem>
     2881          <para>Read a specific file after the usual startup files.
     2882          Maybe be specified repeatedly for multiple inputs.</para>
     2883        </listitem>
    28722884      </varlistentry>
    28732885    </variablelist>
    28742886
  • ghc/InteractiveUI.hs

    diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
    index 6cd5532..b0d5475 100644
    a b runGHCi paths maybe_exprs = do 
    425425     where
    426426      getDirectory f = case takeDirectory f of "" -> "."; d -> d
    427427
     428  dflags <- getDynFlags
    428429  when (read_dot_files) $ do
    429     mcfgs0 <- sequence [ current_dir, app_user_dir, home_dir ]
     430    mcfgs0 <- sequence $ [ current_dir, app_user_dir, home_dir ] ++ map (return . Just ) (ghciScripts dflags)
    430431    mcfgs <- liftIO $ mapM canonicalizePath' (catMaybes mcfgs0)
    431432    mapM_ sourceConfigFile $ nub $ catMaybes mcfgs
    432433        -- nub, because we don't want to read .ghci twice if the
    runGHCi paths maybe_exprs = do 
    448449  -- if verbosity is greater than 0, or we are connected to a
    449450  -- terminal, display the prompt in the interactive loop.
    450451  is_tty <- liftIO (hIsTerminalDevice stdin)
    451   dflags <- getDynFlags
    452452  let show_prompt = verbosity dflags > 0 || is_tty
    453453
    454454  case maybe_exprs of