]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport 2.49:
authorRaymond Hettinger <python@rcn.com>
Sun, 6 Oct 2002 05:43:47 +0000 (05:43 +0000)
committerRaymond Hettinger <python@rcn.com>
Sun, 6 Oct 2002 05:43:47 +0000 (05:43 +0000)
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.]

Modules/readline.c

index 9a2be051bd67788b0b012dc8d7b4f30b4b3ac223..8d324cf8aa8730ab20b1bfb3c0a3473572d0a7d1 100644 (file)
@@ -520,6 +520,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);