summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2008-10-31 14:52:27 +0000
committerIan Lynagh <igloo@earth.li>2008-10-31 14:52:27 +0000
commitff8799ef2c8d0ab976fa9fc00fc4bc94e1ca5af9 (patch)
treebe14a357690b6136c2eedfe759ce32b1f43d72c0
parent2dce32ca5188120ca220a36139ff216b852b389e (diff)
downloadhaskell-ff8799ef2c8d0ab976fa9fc00fc4bc94e1ca5af9.tar.gz
:set prompt now understand Haskell String syntax; trace #2652
-rw-r--r--compiler/ghci/InteractiveUI.hs11
-rw-r--r--docs/users_guide/ghci.xml4
2 files changed, 10 insertions, 5 deletions
diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs
index 268f05e305..4db8900a2b 100644
--- a/compiler/ghci/InteractiveUI.hs
+++ b/compiler/ghci/InteractiveUI.hs
@@ -1499,10 +1499,13 @@ setPrompt value = do
st <- getGHCiState
if null value
then io $ hPutStrLn stderr $ "syntax: :set prompt <prompt>, currently \"" ++ prompt st ++ "\""
- else setGHCiState st{ prompt = remQuotes value }
- where
- remQuotes ('\"':xs) | not (null xs) && last xs == '\"' = init xs
- remQuotes x = x
+ else case value of
+ '\"' : _ -> case reads value of
+ [(value', xs)] | all isSpace xs ->
+ setGHCiState (st { prompt = value' })
+ _ ->
+ io $ hPutStrLn stderr "Can't parse prompt string. Use Haskell syntax."
+ _ -> setGHCiState (st { prompt = value })
setOptions wds =
do -- first, deal with the GHCi opts (+s, +t, etc.)
diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml
index 402c7cb58c..d9295484c8 100644
--- a/docs/users_guide/ghci.xml
+++ b/docs/users_guide/ghci.xml
@@ -2386,7 +2386,9 @@ bar
Inside <replaceable>prompt</replaceable>, the sequence
<literal>%s</literal> is replaced by the names of the
modules currently in scope, and <literal>%%</literal> is
- replaced by <literal>%</literal>.</para>
+ replaced by <literal>%</literal>. If <replaceable>prompt</replaceable>
+ starts with &quot; then it is parsed as a Haskell String;
+ otherwise it is treated as a literal string.</para>
</listitem>
</varlistentry>