summaryrefslogtreecommitdiffstats
path: root/Modules/readline.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-05-30 15:41:56 (GMT)
committerGuido van Rossum <guido@python.org>2002-05-30 15:41:56 (GMT)
commit84271bb34fa2a0d4609caade9b07f06cc83a8626 (patch)
tree84ddc80f0647b1794337c37f179aba5b0ab5c475 /Modules/readline.c
parentefbb67b1a7ab918e5f1a279e3461a28d774a5068 (diff)
downloadcpython-84271bb34fa2a0d4609caade9b07f06cc83a8626.zip
cpython-84271bb34fa2a0d4609caade9b07f06cc83a8626.tar.gz
cpython-84271bb34fa2a0d4609caade9b07f06cc83a8626.tar.bz2
SF #558432: Prevent Annoying ' ' from readline (Holker Krekel).
readline in all python versions is configured to append a 'space' character for a successful completion. But for almost all python expressions 'space' is not wanted (see coding conventions PEP 8). For example if you have a function 'longfunction' and you type 'longf<TAB>' you get 'longfunction ' as a completion. note the unwanted space at the end. The patch fixes this behaviour by setting readline's append_character to '\0' which means don't append anything. This doesn't work with readline < 2.1 (AFAIK nowadays readline2.2 is in good use). An alternative approach would be to make the append_character accessable from python so that modules like the rlcompleter.py can set it to '\0'. [Ed.: I think expecting readline >= 2.2 is fine. If a completer wants another character they can append that to the keyword in the list.]
Diffstat (limited to 'Modules/readline.c')
-rw-r--r--Modules/readline.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/Modules/readline.c b/Modules/readline.c
index 2d75ace..6850b01 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -573,6 +573,7 @@ setup_readline(void)
rl_completer_word_break_characters =
strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?");
/* All nonalphanums except '.' */
+ rl_completion_append_character ='\0';
begidx = PyInt_FromLong(0L);
endidx = PyInt_FromLong(0L);