diff options
author | niksaz <nikitasazanovich@gmail.com> | 2016-05-01 13:34:45 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-05-01 23:29:49 +0200 |
commit | 533037cc58a7c50e1c014e27e8b971d53e7b47bd (patch) | |
tree | 6bdc053c60cc3b8d2254a0cc14569c2207c317f8 /docs/users_guide | |
parent | 18676a4a0dfe79e2704e48be5c8716a656825efe (diff) | |
download | haskell-533037cc58a7c50e1c014e27e8b971d53e7b47bd.tar.gz |
Greater customization of GHCi prompt
This patch is trying to redesign the :set prompt option to take not a
String but a Haskell function, like [String] -> Int -> IO String, where
[String] is the list of the names of the currently loaded modules and
Int is the line number. Currently you may set prompt function with
**:set promt-function [String] -> Int -> IO String** option and old
version is also available - :set prompt String.
So, it looks like I've almost completed this patch:
1) Now we have a lot of escape sequences - 13 to be exact. Most of them
are similar to bash prompt escape sequences. Thus they are quite handy.
2) We may use the special escape sequence to call shell functions, for
example "%call(ls -l -a)".
3) We may use :set prompt-function to set PFunction to handle prompt.
It is just [String] -> Int -> IO String.
Reviewers: erikd, austin, mpickering, bgamari
Reviewed By: mpickering, bgamari
Subscribers: mpickering, thomie
Differential Revision: https://phabricator.haskell.org/D2084
GHC Trac Issues: #5850
Diffstat (limited to 'docs/users_guide')
-rw-r--r-- | docs/users_guide/ghci.rst | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/docs/users_guide/ghci.rst b/docs/users_guide/ghci.rst index a29f94cfdb..5404701898 100644 --- a/docs/users_guide/ghci.rst +++ b/docs/users_guide/ghci.rst @@ -2469,17 +2469,51 @@ commonly used commands. single: GHCi prompt; setting Sets the string to be used as the prompt in GHCi. Inside ⟨prompt⟩, - the sequence ``%s`` is replaced by the names of the modules - currently in scope, ``%l`` is replaced by the line number (as - referenced in compiler messages) of the current prompt, and ``%%`` - is replaced by ``%``. If ⟨prompt⟩ starts with ``"`` then it is parsed as - a Haskell String; otherwise it is treated as a literal string. - -.. ghci-cmd:: :set prompt2; ⟨prompt⟩ + the next sequences are replaced: + + - ``%s`` by the names of the modules currently in scope. + - ``%l`` by the line number (as referenced in compiler messages) of the + current prompt. + - ``%d`` by the date in "Weekday Month Date" format (e.g., "Tue May 26") . + - ``%t`` by the current time in 24-hour HH:MM:SS format. + - ``%T`` by the current time in 12-hour HH:MM:SS format. + - ``%@`` by the current time in 12-hour am/pm format. + - ``%A`` by the current time in 24-hour HH:MM format. + - ``%u`` by the username of the current user. + - ``%w`` by the current working directory. + - ``%o`` by the operating system. + - ``%a`` by the machine architecture. + - ``%N`` by the compiler name. + - ``%V`` by the compiler version. + - ``%call(cmd [args])`` by the result of calling ``cmd args``. + - ``%%`` by ``%``. + + If ⟨prompt⟩ starts with ``"`` then it is parsed as a Haskell String; + otherwise it is treated as a literal string. + +.. ghci-cmd:: :set prompt-cont; ⟨prompt⟩ Sets the string to be used as the continuation prompt (used when using the :ghci-cmd:`:{` command) in GHCi. +.. ghci-cmd:: :set prompt-function; <prompt-function> + + .. index:: + single: GHCi prompt function; setting + + Sets the function to be used for the prompt displaying in GHCi. The + function should be of the type ``[String] -> Int -> IO String``. This + function is called each time the prompt is being made. The first argument + stands for the names of the modules currently in scope(the name of the + "topmost" module will begin with a ``*``; see :ref:`ghci-scope` for + more information). The second arguments is the line number (as referenced + in compiler messages) of the current prompt. + +.. ghci-cmd:: :set prompt-cont-function; <prompt-function> + + Sets the function to be used for the continuation prompt (used when + using the :ghci-cmd:`:{` command) displaying in GHCi. + .. ghci-cmd:: :set stop; ⟨num⟩ ⟨cmd⟩ Set a command to be executed when a breakpoint is hit, or a new item |