Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions Doc/library/readline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,32 @@ made using this module affect the behaviour of both the interpreter's
interactive prompt and the prompts offered by the built-in :func:`input`
function.

Readline keybindings may be configured via an initialization file, typically
``.inputrc`` in your home directory. See `Readline Init File
<https://cnswww.cns.cwru.edu/php/chet/readline/rluserman.html#SEC9>`_
in the GNU Readline manual for information about the format and
allowable constructs of that file, and the capabilities of the
Readline library in general.

.. note::

The underlying Readline library API may be implemented by
the ``libedit`` library instead of GNU readline.
On MacOS X the :mod:`readline` module detects which library is being used
On macOS the :mod:`readline` module detects which library is being used
at run time.

The configuration file for ``libedit`` is different from that
of GNU readline. If you programmatically load configuration strings
you can check for the text "libedit" in :const:`readline.__doc__`
to differentiate between GNU readline and libedit.

Readline keybindings may be configured via an initialization file, typically
``.inputrc`` in your home directory. See `Readline Init File
<https://cnswww.cns.cwru.edu/php/chet/readline/rluserman.html#SEC9>`_
in the GNU Readline manual for information about the format and
allowable constructs of that file, and the capabilities of the
Readline library in general.
If you use *editline*/``libedit`` readline emulation on macOS, the
initialization file located in your home directory is named
``.editrc``. For example, the following content in ``~/.editrc`` will
turn ON *vi* keybindings and TAB completion::

python:bind -v
python:bind ^I rl_complete


Init file
Expand Down
2 changes: 2 additions & 0 deletions Doc/tools/susp-ignored.csv
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ library/profile,,:lineno,filename:lineno(function)
library/pyexpat,,:elem1,<py:elem1 />
library/pyexpat,,:py,"xmlns:py = ""http://www.python.org/ns/"">"
library/random,,:len,new_diff = mean(combined[:len(drug)]) - mean(combined[len(drug):])
library/readline,,:bind,"python:bind -v"
library/readline,,:bind,"python:bind ^I rl_complete"
library/smtplib,,:port,method must support that as well as a regular host:port
library/socket,,::,'5aef:2b::8'
library/socket,,:can,"return (can_id, can_dlc, data[:can_dlc])"
Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,7 @@ Gabriel de Perthuis
Tim Peters
Benjamin Peterson
Joe Peterson
Zvezdan Petkovic
Ulrich Petri
Chris Petrilli
Roumen Petrov
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The .editrc file in user's home directory is now processed correctly during
the readline initialization through editline emulation on macOS.
4 changes: 3 additions & 1 deletion Modules/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,9 @@ setup_readline(readlinestate *mod_state)
Py_FatalError("not enough memory to save locale");
#endif

/* The name must be defined before initialization */
rl_readline_name = "python";

#ifdef __APPLE__
/* the libedit readline emulation resets key bindings etc
* when calling rl_initialize. So call it upfront
Expand All @@ -1099,7 +1102,6 @@ setup_readline(readlinestate *mod_state)

using_history();

rl_readline_name = "python";
/* Force rebind of TAB to insert-tab */
rl_bind_key('\t', rl_insert);
/* Bind both ESC-TAB and ESC-ESC to the completion function */
Expand Down