Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Alex D
GHC
Commits
76bde331
Commit
76bde331
authored
Apr 11, 2012
by
pcapriotti
Browse files
Add support for additional .ghci files in GHCi (#5265)
Patch by Sam Anklesaria <amsay@amsay.net>
parent
ab52df86
Changes
4
Hide whitespace changes
Inline
Side-by-side
compiler/main/DynFlags.hs
View file @
76bde331
...
...
@@ -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
...
...
docs/users_guide/flags.xml
View file @
76bde331
...
...
@@ -492,6 +492,12 @@
<entry>
static
</entry>
<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>
...
...
docs/users_guide/ghci.xml
View file @
76bde331
...
...
@@ -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>
...
...
ghc/InteractiveUI.hs
View file @
76bde331
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment