cmd, readline, and /path/filename completion

Michael Gilfix mgilfix at eecs.tufts.edu
Wed Jul 24 17:51:18 EDT 2002


On Wed, Jul 24 @ 16:27, Dave Cinege wrote:
> > More exactly, the OP needs to erase the '/' character from the delims list.
> > e.g.
> >
> > readline.set_completer_delims(' \t\n`~!@#$%^&*()-=+[{]}\\|;:\'",<>?')
> 
> Yes! Thank you. Though I don't understand why this works...at least
> I have some idea where to look in the readline docs. I began going through 
> them last night but didn't get much out of them. : P

  The readline library is sufficiently general such that it's meant
to work on completion in a wide variety of situations. That obvious
thing being said ( :) ), you need to tell readline what to consider as
special tokens that it should use when divying up and understanding
expressions.  This tells it how to best sort out of the mess that is
your expession and determine where the 'breaks' that you naturally
consider to be the atomic words are. Maybe that makes sense?

> > should work the way you want it.
> >
> > Are you implementing your own completion handler?
> 
> I don't know if I going to need to. As I said I'm toying with this now. 
> 
> One thing still 'broken' is it will not complete against executables, in the 
> curdir or path. Can you comment on doing this?
> 
> It does currently complete against builtin's, IE  def do_XXXX(self,line):
> methods.

  I once implemented an application where I wanted to complete against
files in a 'current dir'. My solution was to gobble up a list of files
in teh current directory (I assume you have that part down), and then
set an attribute of "completion words". Now I wrote this particular app
in Perl at the time, so I'm not sure if this attribute was specific
to the Perl Readline module, but check if there's some sort of function
that allows you to feed the readline module a list of words to check
against when completing. Hope that helps you look in the right place.

                           -- Mike

-- 
Michael Gilfix
mgilfix at eecs.tufts.edu

For my gpg public key:
http://www.eecs.tufts.edu/~mgilfix/contact.html




More information about the Python-list mailing list