customizing the readline module

Huaiyu Zhu huaiyu at gauss.almadan.ibm.com
Tue Aug 20 14:28:29 EDT 2002


holger krekel <pyth at devel.trillke.net> wrote:
>
>What you need is to issue
>
>    readline.set_completer_delims('')
>
>to prevent readline from giving you just a part of the line. This way you get
>the complete line and can anaylize yourself (splitting into words etc.).
>Of course your completer function then has to pass back completion
>strings which represent a whole line.  But that's not hard.

Thanks.  This partially solved the problem.  However, passing back the whole
line clutters up the completion choices offered by readline.  For example,
suppose I want to choose from

aaa bbb1
aaa bbb2

After 'aaa', if the completer returns ('bbb1', 'bbb2'), then when the first
letter 'b' is pressed the partial line 'aaa' disappears.  If instead the
completer returns ('aaa bbb1', 'aaa bbb2'), then the choices given are 'aaa
bbb1 aaa bbb2', which is hard to read for long lines.

Is there a way to tweak the protocol for readline to allow the semantics of
passing back [aaa] as the accepted words and [bbb1, bbb2] as possible
completions?  That would allow the command line to remain 'aaa ' while the
completions be 'bbb1 bbb2'.

BTW, why readline is so designed that it needs to make a sequence of calls
terminated by an exception to obtain a list of completions, instead of just
accepting a list of completions with a single call?

I do not quite understand the other two problems you warned.  Maybe I
haven't got to that stage yet.

Huaiyu



More information about the Python-list mailing list