Re: readline problems

Guido van Rossum <[email protected]> Sun, 29 Dec 2002 17:47:31 -0500
Newsgroups gmane.comp.python.snake-farm.user
Message-ID <[email protected]>
> > If you want to write the autoconf deterction code for this, be my
> > guest.
> 
> I don't really know autoconf/readline well enough for this, I think.

It would be a good learning experience. :-)

> > GNU readline makes it impossible to detect at compile-time
> > which version you have, otherwise I would have used #ifdef in the
> > source.
> 
> I see.
> 
> Just out of curiosity: What is lost in using the old API?
> Won't it work with more recent readline versions? Is there some
> functionality/performance loss?

There's some functionality that's only available in the new APIs.

Here's the CVS entry.

----------------------------
revision 2.49
date: 2002/05/30 15:41:56;  author: gvanrossum;  state: Exp;  lines: +1 -0
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.]
----------------------------

--Guido van Rossum (home page: http://www.python.org/~guido/)