[erlang-patches] Shell history search

Dan Gudmundsson <>
Fri Jan 18 16:11:26 CET 2013

Switched to correct patch/thread.

On Fri, Jan 18, 2013 at 3:22 PM, Fred Hebert <> wrote:
> Hi Dan,
> In any case, the use of 'Esc' is ambiguous to exit search because the
> character used in the escape sequence is the same one used while using
> meta (\e if I recall). Because the shell handles things in a
> character-per-character basis, there is no way for me to know whether
> I'm looking at a meta sequence or if I'm getting 'Esc' on its own.
> Supporting 'Esc' to escape search then means that I may leave garbage in
> the line when what I get is actually a meta sequence.

If you can not find a better solution then my initial reaction is to
not support meta seq, jump out of search and display the garbage
because this confused me and will confuse others.

Can you not catch it higher up, i.e. in edit/5
case key_map(C, Prefix) of
   search_meta when CS =:= [] -> search_quit().


> Not sure how to work around this one.
> Regards,
> Fred.

On Tue, Jan 8, 2013 at 2:06 PM, Fredrik <> wrote:
> Great,
> I have re-fetched and building it in master-pu branch now.
> Thanks!
> BR Fredrik Gustafsson
> Erlang OTP Team
> On 01/08/2013 01:49 PM, Fred Hebert wrote:
>> Hi Fredrik,
>> It's done. From my understanding of the code, I simply needed to pass in
>> the encoding to the prompt_bytes/2 functions, and it seems to work fine.
>> Regards,
>> Fred.
>> On 01/08, Fredrik wrote:
>>> Hello Fred,
>>> You need to rebase upon 'master' branch and make changes to your
>>> patch, it fails to build on
>>> 'group.erl:536: function prompt_bytes/1 undefined'
>>> Let me know when you are done,
>>> BR Fredrik Gustafsson
>>> Erlang OTP Team
>>> On 01/04/2013 09:07 AM, Fredrik wrote:
>>>> Hello Fred,
>>>> Must have missed to reply to you, your patch has been in
>>>> 'master-pu' branch since wednesday.
>>>> Thanks for your contribution.
>>>> BR Fredrik Gustafsson
>>>> Erlang OTP Team
>>>> On 12/22/2012 11:41 PM, Fred Hebert wrote:
>>>>> Hi, the following patch adds functionality to group.erl and edlin.erl
>>>>> in
>>>>> order to allow the user to search history.
>>>>> Search mode can be entered by pressing ctrl-r. Enter terms and press
>>>>> ctrl-r again to search backwards, or ctrl-s to then search forward (if
>>>>> you terminal doesn't eat up that one). Press enter to execute the line,
>>>>> or use tab, arrow keys, or other control sequences (^D, ^K, etc.) to
>>>>> exit search mode while remaining on the last found line.
>>>>> The search mode is a simpler version of the one available in bash or
>>>>> zsh shells.
>>>>> This adds a few modes to the shell (search, on top of none and meta) in
>>>>> group.erl for history search, and a few more in edlin.erl to change the
>>>>> meaning of control sequences while searching.
>>>>> This patch has been tested on OSX and some linux variants and worked
>>>>> fine.
>>>>> I tested it on Windows, and neither do werl.exe, or erl.exe (under
>>>>> PowerShell or cmd.exe) capture the ^R and ^S sequences -- it will not
>>>>> work there, but will not break any existing functionality. As far as
>>>>> I'm
>>>>> aware, this is more likely a driver issue than an issue with the patch
>>>>> (^G is not captured in cmd.exe, ctrl+C works in none of the above, for
>>>>> example).
>>>>> git fetch git://github.com/ferd/otp.git shell_history_search
>>>>> Compare at:
>>>>> https://github.com/ferd/otp/compare/erlang:master...ferd:shell_history_search
>>>>> https://github.com/ferd/otp/compare/erlang:master...ferd:shell_history_search.patch
>>>>> Regards,
>>>>> Fred.
>>>>> _______________________________________________
>>>>> erlang-patches mailing list
>>>>> http://erlang.org/mailman/listinfo/erlang-patches
>>> _______________________________________________
>>> erlang-patches mailing list
>>> http://erlang.org/mailman/listinfo/erlang-patches
> _______________________________________________
> erlang-patches mailing list
> http://erlang.org/mailman/listinfo/erlang-patches

More information about the erlang-patches mailing list