Ticket #5265: 5265.patch

File 5265.patch, 3.7 KB (added by SamAnklesaria, 4 years ago)
  • compiler/main/StaticFlags.hs

    From e7150aff2e5dbbce9d8930478d97fec2607e343c Mon Sep 17 00:00:00 2001
    From: Sam Anklesaria <[email protected]>
    Date: Sun, 19 Jun 2011 17:36:07 -0500
    Subject: [PATCH] trac #5265 (support for additional .ghci files)
    
    ---
     compiler/main/StaticFlags.hs |   11 ++++++++++-
     docs/users_guide/flags.xml   |    6 ++++++
     docs/users_guide/ghci.xml    |    4 ++++
     ghc/InteractiveUI.hs         |    3 ++-
     4 files changed, 22 insertions(+), 2 deletions(-)
    
    diff --git a/compiler/main/StaticFlags.hs b/compiler/main/StaticFlags.hs
    index f6d0af2..d8e63ab 100644
    a b module StaticFlags ( 
    7272
    7373        -- misc opts
    7474        opt_IgnoreDotGhci,
     75        opt_GhciScripts,
    7576        opt_ErrorSpans,
    7677        opt_GranMacros,
    7778        opt_HiVersion,
    module StaticFlags ( 
    9293import Config
    9394import FastString
    9495import Util
    95 import Maybes           ( firstJusts )
     96import Maybes           ( firstJusts, catMaybes )
    9697import Panic
    9798
    9899import Data.Maybe       ( listToMaybe )
    lookUp :: FastString -> Bool 
    121122lookup_def_int   :: String -> Int -> Int
    122123lookup_def_float :: String -> Float -> Float
    123124lookup_str       :: String -> Maybe String
     125lookup_all_str   :: String -> [String]
    124126
    125127-- holds the static opts while they're being collected, before
    126128-- being unsafely read by unpacked_static_opts below.
    lookup_str sw 
    151153        Just str         -> Just str
    152154        Nothing          -> Nothing     
    153155
     156lookup_all_str sw = map f $ catMaybes (map (stripPrefix sw) staticFlags) where
     157   f ('=' : str) = str
     158   f str = str
     159
    154160lookup_def_int sw def = case (lookup_str sw) of
    155161                            Nothing -> def              -- Use default
    156162                            Just xx -> try_read sw xx
    unpacked_opts = 
    189195
    190196opt_IgnoreDotGhci :: Bool
    191197opt_IgnoreDotGhci               = lookUp (fsLit "-ignore-dot-ghci")
     198 
     199opt_GhciScripts :: [String]
     200opt_GhciScripts = lookup_all_str "-ghci-script"
    192201
    193202-- debugging options
    194203-- | Suppress all that is suppressable in core dumps.
  • docs/users_guide/flags.xml

    diff --git a/docs/users_guide/flags.xml b/docs/users_guide/flags.xml
    index 43c713e..7ef9e80 100644
    a b  
    487487              <entry>-</entry>
    488488            </row>
    489489            <row>
     490              <entry><option>-ghci-script</option></entry>
     491              <entry>Load the given additional <filename>.ghci</filename> file</entry>
     492              <entry>static</entry>
     493              <entry>-</entry>
     494            </row>
     495            <row>
    490496              <entry><option>-read-dot-ghci</option></entry>
    491497              <entry>Enable reading of <filename>.ghci</filename> files</entry>
    492498              <entry>static</entry>
  • docs/users_guide/ghci.xml

    diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml
    index 72481eb..62522e8 100644
    a b Prelude> :set -fno-glasgow-exts 
    28722872      </varlistentry>
    28732873    </variablelist>
    28742874
     2875    <para>Additional <filename>.ghci</filename> files can be added
     2876    through the <option>-ghci-script</option> option. These are
     2877    loaded after the normal <filename>.ghci</filename> files.</para>
     2878
    28752879  </sect1>
    28762880
    28772881  <sect1 id="ghci-obj">
  • ghc/InteractiveUI.hs

    diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
    index 1869040..981abdf 100644
    a b runGHCi paths maybe_exprs = do 
    426426      getDirectory f = case takeDirectory f of "" -> "."; d -> d
    427427
    428428  when (read_dot_files) $ do
    429     mcfgs0 <- sequence [ current_dir, app_user_dir, home_dir ]
     429    mcfgs0 <- sequence $ [ current_dir, app_user_dir, home_dir ]
     430                         ++ map (return . Just) opt_GhciScripts
    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