TAB completion 
Author Message
 TAB completion

Hi!

I have a application with a builtin interactive shell. I use the
readline module for command completion and history browsing. The
following code enables filename completion:

try:
    import readline
except ImportError:
    self.printErr("Could not import readline.\nHistory browsing " \
                  "and tab completion will not be available.")
else:
    readline.parse_and_bind("tab: complete")

I also want to have command completion, but I don't want to write a
complete function for the filename completion (because it's already
there). I thought something like

def complete(text, state):
    if text seems like a command:
        myCmdCompletion(text, state)
    else:
        pythonsBuiltinCompletion(text, state)  

could do the job.

My problem is: How can I call the default completion function that
comes with the python distribution?

thanks for helping  
   Stefan



Thu, 13 Jan 2005 18:19:36 GMT  
 TAB completion

Quote:
> My problem is: How can I call the default completion function that
> comes with the python distribution?

I think you should use the rcompleter module.

YDD
--
.sigmentation fault



Thu, 13 Jan 2005 20:58:54 GMT  
 TAB completion

Hi!

Quote:

>> My problem is: How can I call the default completion function that
>> comes with the python distribution?

> I think you should use the rcompleter module.

No. The library manual says:

The rlcompleter module defines a completion function for the readline
module by completing valid Python identifiers and keywords.

I don't want to complete valid Python identifiers and keywords. I want
to complete the builting commands of my shell.

Bye Stefan



Thu, 13 Jan 2005 23:49:35 GMT  
 TAB completion

Quote:
> Hi!

> I have a application with a builtin interactive shell. I use the
> readline module for command completion and history browsing. The
> following code enables filename completion:

Is your work based on the cmd module?

Dave

--
The time is now 22:48 (Totalitarian)  -  http://www.ccops.org/



Fri, 14 Jan 2005 08:52:06 GMT  
 TAB completion

Quote:


>> Hi!

>> I have a application with a builtin interactive shell. I use the
>> readline module for command completion and history browsing. The
>> following code enables filename completion:

> Is your work based on the cmd module?

No it is not. I have looked at the cmd module, but its completion
function does not contain filename completion.

Bye Stefan



Fri, 14 Jan 2005 17:11:38 GMT  
 TAB completion

Quote:


> >> Hi!

> >> I have a application with a builtin interactive shell. I use the
> >> readline module for command completion and history browsing. The
> >> following code enables filename completion:

> > Is your work based on the cmd module?

> No it is not. I have looked at the cmd module, but its completion
> function does not contain filename completion.

Not true. Please see
http://mail.python.org/pipermail/python-list/2002-July/thread.html#11...
http://mail.python.org/pipermail/python-list/2002-July/114824.html

--
The time is now 22:48 (Totalitarian)  -  http://www.ccops.org/



Fri, 14 Jan 2005 21:06:24 GMT  
 TAB completion

Quote:




>> >> Hi!

>> >> I have a application with a builtin interactive shell. I use the
>> >> readline module for command completion and history browsing. The
>> >> following code enables filename completion:

>> > Is your work based on the cmd module?

>> No it is not. I have looked at the cmd module, but its completion
>> function does not contain filename completion.

> Not true. Please see
> http://mail.python.org/pipermail/python-list/2002-July/thread.html#11...
> http://mail.python.org/pipermail/python-list/2002-July/114824.html

Ah, ok thanks! I am developing with python 2.1 and this feature of the
cmd class is not available in that version.

Is it corrrect, that readline's default filename completion is applied
when the function set with set_completer(completionFun) returns
`None'?

That seems to be the point I did not understand.

Thanks for helping!

Bye Stefan



Fri, 14 Jan 2005 22:10:44 GMT  
 TAB completion

Quote:

> Ah, ok thanks! I am developing with python 2.1 and this feature of the
> cmd class is not available in that version.

Hmmm...I don't know. I've only been playing with cmd the last few days, and
only with Python2.2. Ahh yes...I'm looking at both now and as of 2.2:

7. If completion is enabled, completing commands will be done automatically,
   and completing of commands args is done by calling complete_foo() with
   arguments text, line, begidx, endidx.  text is string we are matching
   against, all returned matches must begin with it.  line is the current
   input line (lstripped), begidx and endidx are the beginning and end
   indexes of the text being matched, which could be used to provide
   different completion depending upon which position the argument is in.

Quote:
> Is it corrrect, that readline's default filename completion is applied
> when the function set with set_completer(completionFun) returns
> `None'?

You got me. Wrapping readline in python, then in a another class (cmd)
is a bit confusing, especially if you're not readline savy (I'm not and
don't want to be  : >)

I'd say get a hold of Python 2.2 and begin reviewing the cmd module
itself.

--
The time is now 22:48 (Totalitarian)  -  http://www.ccops.org/



Fri, 14 Jan 2005 22:24:21 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Interactive Console Program with Tab-Completion

2. tab completion in cmd

3. CLISP tab completion problem

4. tab completion on clisp

5. rlcompleter2 <TAB> interactive completion

6. completion on tab?

7. rlcompleter2 <TAB> interactive completion

8. Tabs, Tabs, Tabs!!

9. Detecting the current tab in a tab panel

10. Tabs within Tabs

11. Win95 Tab/TabStrip - Want to use keyboard navigation between tabs

12. Selecting TAB sheet by pressing TAB key

 

 
Powered by phpBB® Forum Software