Hi,

On Fri, Jan 31, 2014 at 06:25:59AM -0800, dwakar wrote:
> I have installed Racket in my home folder. The path to the drracket 
> executable is added to the PATH environment variable, but the tab 
> completions in the prompt widget doesn't work for drracket executable.
> 
> However the CommandCompleter class and its complete seems to be working 
> fine.
> Here's a little test I did.
> 
> > import os
> > import glob
> > class CommandCompleter:
> >     DEFAULTPATH = "/bin:/usr/bin:/usr/local/bin"
> >
> >     def __init__(self, qtile, _testing=False):
> >         """
> >         _testing: disables reloading of the lookup table
> >                   to make testing possible.
> >         """
> >         self.lookup, self.offset = None, None
> >         self.thisfinal = None
> >         self._testing = _testing
> >
> >     def actual(self):
> >         """
> >             Returns the current actual value.
> >         """
> >         return self.thisfinal
> >
> >     def executable(self, fpath):
> >         return os.access(fpath, os.X_OK)
> >
> >     def reset(self):
> >         self.lookup = None
> >         self.offset = -1
> >
> >     def complete(self, txt):
> >         """
> >         Returns the next completion for txt, or None if there is no 
> > completion.
> >         """
> >         if not self.lookup:
> >             if not self._testing:
> >                 # Lookup is a set of (display value, actual value) tuples.
> >                 self.lookup = []
> >                 if txt and txt[0] in "~/":
> >                     path = os.path.expanduser(txt)
> >                     if os.path.isdir(path):
> >                         files = glob.glob(os.path.join(path, "*"))
> >                         prefix = txt
> >                     else:
> >                         files = glob.glob(path + "*")
> >                         prefix = os.path.dirname(txt)
> >                     prefix = prefix.rstrip("/") or "/"
> >                     for f in files:
> >                         if self.executable(f):
> >                             display = os.path.join(prefix, 
> > os.path.basename(f))
> >                             if os.path.isdir(f):
> >                                 display += "/"
> >                             self.lookup.append((display, f))
> >                 else:
> >                     dirs = os.environ.get("PATH", 
> > self.DEFAULTPATH).split(":")
> >                     for didx, d in enumerate(dirs):
> >                         try:
> >                             for cmd in glob.glob(os.path.join(d, "%s*" % 
> > txt)):
> >                                 if self.executable(cmd):
> >                                     self.lookup.append(
> >                                         (
> >                                             os.path.basename(cmd),
> >                                             cmd
> >                                         ),
> >                                     )
> >                         except OSError:
> >                             pass
> >             self.lookup.sort()
> >             self.offset = -1
> >             self.lookup.append((txt, txt))
> >         self.offset += 1
> >         if self.offset >= len(self.lookup):
> >             self.offset = 0
> >         ret = self.lookup[self.offset]
> >         self.thisfinal = ret[1]
> >         return ret[0]
> >
> > if __name__ == "__main__":
> >     cc = CommandCompleter("qtile")
> >     print cc.complete("dr") # gives "drracket"
> >     print cc.complete("dr") # and the 'lookup' list contains the tuple 
> > with "drracket" and its path.

Your login shell evaluates ~/.bashrc, but your X shell probably won't,
unless you explicitly tell it to. How are you starting qtile? If it's
via a ~/.xsession file, you can just source your bashrc there (or just
modify the path as needed), and things should work fine.

\t

-- 
You received this message because you are subscribed to the Google Groups 
"qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to