Ticket #14687: trac_14687.patch

File trac_14687.patch, 4.2 KB (added by klee, 8 years ago)

To sage library

  • sage/misc/all.py

    # HG changeset patch
    # User Kwankyu Lee <ekwankyu@gmail.com>
    # Date 1370400844 -32400
    # Node ID d85b9c16f8754c908da46af835bf1a7993a06789
    # Parent  9b3e6b467313a8df84543e4cbc882580a9fc0678
    Trac #14687: fixes the broken readline extra commands
    
    diff --git a/sage/misc/all.py b/sage/misc/all.py
    a b  
    178178
    179179from unknown import Unknown
    180180
    181 from readline_extra_commands import *
    182181##########################################################################
    183182def benchmark(n=-1):
    184183    """
  • sage/misc/readline_extra_commands.pyx

    diff --git a/sage/misc/readline_extra_commands.pyx b/sage/misc/readline_extra_commands.pyx
    a b  
    1212
    1313The ``history-search-backward-and-save`` command searches backward in the history
    1414for the string of characters from the start of the input line to the current cursor
    15 position, and fetches the line found. If the cursor is at the start of the line, the previous line
    16 is fetched. The position of the fetched line is saved internally.
     15position, and fetches the first line found. If the cursor is at the start of the line, the previous line
     16is fetched. The position of the fetched line is saved internally, and the next search begins at the
     17saved position.
    1718
    18 The ``history-search-forward-and-save`` command behaves similarly but forward. This
    19 command is useful to fetch a block of lines from the history by first searching the first
    20 line of the block and then issuing this command as many times as needed.
     19The ``history-search-forward-and-save`` command behaves similarly but forward.
    2120
    22 The previous two commands is best used in tandem. They are intended to replace the
    23 ``history-search-backward`` command and the ``history-search-forward`` command provided by
    24 the GNU readline library used in Sage.
     21The previous two commands is best used in tandem to fetch a block of lines from the history,
     22by searching backward the first line of the block and then issuing the forward command as many times as needed.
     23They are intended to replace the ``history-search-backward`` command and the ``history-search-forward`` command
     24provided by the GNU readline library used in Sage.
    2525
    26 To bind these commands with keys, insert the relevant lines into the ``$DOT_SAGE/ipython/ipythonrc``
    27 file. Note that ``$DOT_SAGE`` is ``$HOME/.sage`` by default. For example,
    28 
     26To bind these commands with keys, insert the relevant lines into the IPython configuration file
     27``$DOT_SAGE/ipython-0.12/profile_sage/ipython_config.py``.  Note that ``$DOT_SAGE`` is ``$HOME/.sage``
     28by default. For example,
    2929::
    3030
    31     readline_parse_and_bind "\C-o": operate-and-get-next
    32     readline_parse_and_bind "\e[A": history-search-backward-and-save
    33     readline_parse_and_bind "\e[B": history-search-forward-and-save
     31    c = get_config()
     32
     33    c.InteractiveShell.readline_parse_and_bind = [
     34        '"\C-o": operate-and-get-next',
     35        '"\e[A": history-search-backward-and-save',
     36        '"\e[B": history-search-forward-and-save'
     37        ]
    3438
    3539binds the three commands with the control-o key, the up arrow key, and the down arrow key,
    36 respectively. Warning: Sometimes, these keys may be bound to do other actions by the terminal and does not
     40respectively. *Warning:* Sometimes, these keys may be bound to do other actions by the terminal and does not
    3741reach to the readline properly (check this by running ``stty -a`` and reading the ``cchars`` section). Then
    3842you may need to turn off these bindings before the new readline commands work fine . A prominent case is when
    39 control-o is bound to discard by the terminal. You can turn this off by running ``stty discard undef``.
     43control-o is bound to ``discard`` by the terminal. You can turn this off by running ``stty discard undef``.
    4044
    4145AUTHORS:
    4246
    4347    - Kwankyu Lee (2010-11-23): initial version
     48    - Kwankyu Lee (2013-06-05): updated for the new IPython configuration format.
    4449"""
    4550
    4651#*****************************************************************************
     
    254259rl_add_defun("operate-and-get-next", &operate_and_get_next, -1)
    255260rl_add_defun("history-search-backward-and-save", &history_search_backward_and_save, -1)
    256261rl_add_defun("history-search-forward-and-save", &history_search_forward_and_save, -1)
     262