Ticket #8047: ticket-8047-line-subst.patch

File ticket-8047-line-subst.patch, 1.8 KB (added by hvr, 2 years ago)
  • docs/users_guide/ghci.xml

    commit b345d2b4089e0abdae0c57fc72b7213b5013bde0
    Author: Herbert Valerio Riedel <[email protected]>
    Date:   Wed Jul 10 10:01:31 2013 +0200
    
        GHCi: Implement `%l` substitution for line-number
        
        See #8047 for more details
    
    diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml
    index 9d7fa6c..df483e8 100644
    a b bar 
    27872787          <para>Sets the string to be used as the prompt in GHCi.
    27882788          Inside <replaceable>prompt</replaceable>, the sequence
    27892789          <literal>%s</literal> is replaced by the names of the
    2790           modules currently in scope, and <literal>%%</literal> is
    2791           replaced by <literal>%</literal>. If <replaceable>prompt</replaceable>
     2790          modules currently in scope, <literal>%l</literal> is replaced
     2791          by the line number (as referenced in compiler messages) of the
     2792          current prompt, and <literal>%%</literal> is replaced by
     2793          <literal>%</literal>.  If <replaceable>prompt</replaceable>
    27922794      starts with &quot; then it is parsed as a Haskell String;
    27932795      otherwise it is treated as a literal string.</para>
    27942796        </listitem>
  • ghc/InteractiveUI.hs

    diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
    index 9a28480..36335cd 100644
    a b fileLoop hdl = do 
    608608
    609609mkPrompt :: GHCi String
    610610mkPrompt = do
     611  st <- getGHCiState
    611612  imports <- GHC.getContext
    612613  resumes <- GHC.getResumeContext
    613614
    mkPrompt = do 
    638639
    639640        deflt_prompt = dots <> context_bit <> modules_bit
    640641
     642        f ('%':'l':xs) = ppr (1 + line_number st) <> f xs
    641643        f ('%':'s':xs) = deflt_prompt <> f xs
    642644        f ('%':'%':xs) = char '%' <> f xs
    643645        f (x:xs) = char x <> f xs
    644646        f [] = empty
    645647
    646   st <- getGHCiState
    647648  dflags <- getDynFlags
    648649  return (showSDoc dflags (f (prompt st)))
    649650