Readline and unwanted filename completion
simon at ping-pong.budig
Sat Feb 2 16:09:58 EST 2002
In article <3c5b2c1f at si-nic.hrz.uni-siegen.de>, Simon Budig wrote:
> Michael Hudson <mwh at python.net> wrote:
>> Simon Budig <Simon.Budig at unix-ag.org> writes:
>>> Something is broken with the completion of readline:
>> Well, I knew about it. I don't regard it as a huge problem.
> Hmm. Imagine you are writing an interactive interpreter of a
> custom language to manipulate something non-file'ishes and
> suddenly the commandline starts completing *filenames*. I
> think this is a good showstopper...
>>> Is there an evil hack to avoid this?
>> Dunno. Doubt it, somehow. You'll need to look at the documentation
>> for readline, though.
> Well - I looked at the documentation for the readline-module, but that
> doesn't say anything about it. Maybe I should read the sources.
Ok, did that. Here is the Patch to fix this behaviour. It is against
Modules/readline.c from Python 2.1.2.
--- readline.c.orig Sat Feb 2 21:44:09 2002
+++ readline.c Sat Feb 2 22:01:16 2002
@@ -346,6 +346,9 @@
lock released! */
save_tstate = PyThreadState_Swap(NULL);
+ /* Don't use the default filename completion if we
+ have a custom completion function... */
+ rl_attempted_completion_over = 1;
r = PyObject_CallFunction(completer, "si", text, state);
if (r == NULL)
I really would appreciate, if this gets incorporated in the regular
Python releases. Unfortunately I don't have an account at sourceforge
to submit this the proper way.
Simon.Budig at unix-ag.org http://www.home.unix-ag.org/simon/
More information about the Python-list