fancier prompts for ghci
It'd be nice to put newlines in a GHCi prompt using standard escape sequences.
It is really unnecessary to support anything more than %s
as a formatting directive.
Trac metadata
Trac field | Value |
---|---|
Version | 6.8.3 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |
- Show closed items
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- jsnx changed weight to 5
changed weight to 5
- jsnx added Tfeature request Trac import labels
added Tfeature request Trac import labels
- Ian Lynagh <igloo@earth.li> changed milestone to %6.10 branch
changed milestone to %6.10 branch
Trac metadata
Trac field Value Component Compiler → GHCi - Author
I've integrated this with GHC 6.8.3 sources. There's not much to it.
--- 0/compiler/ghci/InteractiveUI.hs 2008-06-16 10:27:16.000000000 -0700 +++ 1/compiler/ghci/InteractiveUI.hs 2008-10-28 02:57:03.000000000 -0700 @@ -1447,11 +1447,19 @@ 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 } + then io $ hPutStrLn stderr $ + "syntax: :set prompt <prompt>, currently \"" ++ prompt st ++ "\"" + else setGHCiState st{ prompt = read . handleQuotes $ value } where - remQuotes ('\"':xs) | not (null xs) && last xs == '\"' = init xs - remQuotes x = x + -- the prompt can be input with quote marks and string escaping, or + -- with plain character escaping. + handleQuotes s | length s > 2 && last s == '"' && head s == '"' = s + | otherwise = wrap . escapeQuotes $ s + wrap = ("\"" ++) . (++ "\"") + escapeQuotes ('\\':'"':r) = '\\' : '"' : escapeQuotes r + escapeQuotes ('"':r) = '\\' : '"' : escapeQuotes r + escapeQuotes (c:r) = c : escapeQuotes r + escapeQuotes [ ] = [ ] setOptions wds = do -- first, deal with the GHCi opts (+s, +t, etc.)
With quotes, it uses string escapes and retains spaces:
Prelude> :set prompt "{- %s\n -} " {- Prelude -}
Without quotes, it uses only character escapes:
Prelude> :set prompt {-\SP\SP%s\n\SP-}\SP {- Prelude -}
- Author
Attached file
rubbish
(download).this is the diff mentioned in comment 3 (turns out the diff is not extractable in this version of trac)
- Ian Lynagh <igloo@earth.li> assigned to @trac-igloo
assigned to @trac-igloo
- Ben Gamari mentioned in commit ff8799ef
mentioned in commit ff8799ef
- Ian Lynagh <igloo@earth.li> closed
closed
Thanks for the patch! I've applied a slightly different version: Prompt strings starting with " are treated as Haskell strings; otherwise they are treated as literal strings.
Trac metadata
Trac field Value Resolution Unresolved → ResolvedFixed - jsnx reopened
reopened
- Author
Replying to [ticket:2652#comment:29920 igloo]:
Thanks for the patch! I've applied a slightly different version: Prompt strings starting with " are treated as Haskell strings; otherwise they are treated as literal strings.
Is this going to be in 6.12? I've noticed it's not included in 6.10.
Trac metadata
Trac field Value Resolution ResolvedFixed → Unresolved Yes, this patch is only in the HEAD (which will become 6.12):
Fri Oct 31 14:52:27 GMT 2008 Ian Lynagh <igloo@earth.li> * :set prompt now understand Haskell String syntax; trace #2652
- Ian Lynagh <igloo@earth.li> closed
closed
Trac metadata
Trac field Value Resolution Unresolved → ResolvedFixed - Ben Gamari added Pnormal label
added Pnormal label