Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 84271bb

Browse files
committed
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.]
1 parent efbb67b commit 84271bb

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

Modules/readline.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ setup_readline(void)
573573
rl_completer_word_break_characters =
574574
strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?");
575575
/* All nonalphanums except '.' */
576+
rl_completion_append_character ='\0';
576577

577578
begidx = PyInt_FromLong(0L);
578579
endidx = PyInt_FromLong(0L);

0 commit comments

Comments
 (0)