On Tue, 17 Mar 2015 11:22 pm, Oscar Benjamin wrote: > On 17 March 2015 at 08:10, Steven D'Aprano > <steve+comp.lang.pyt...@pearwood.info> wrote: >> On Tuesday 17 March 2015 03:23, candide wrote: >> >> You might like my tab completion and command history module: >> >> http://code.google.com/p/tabhistory/ >> >> I've been using it on Linux for about three or four years, and although I >> don't promise it is bug-free, it shouldn't blow up your computer :-) > > Good work Steven. I just gave it a try and it works great.
Thank you! >> It supports module completion in `import` and `from ... import` >> statements. It even supports module attribute completion if the module is >> already cached. >> >> E.g. if the re module is cached, typing >> >> from re import ma[TAB} >> >> will compete the "ma" to "match". > > BTW ipython does this and goes one step further. It basically imports > the module while tab completion is ongoing so that you can complete > "from ...import" without needing to import the module first. In > principle that could be problematic but in practice I find it useful > and it has never caused me any actual problems. I thought about that, but I decided against it because of the security risk: from evil_module_of_doom import something Just tab-completing the name "something" shouldn't run the evil module. I suppose I could add it as an optional feature, defaulting to off. Or try parsing the source code. >> By default, the tabhistory module: >> >> * indents at the start of the line > > Any reason for using 8 spaces for a tab? Or is that just my terminal > (gnome-terminal)? By default, it should indent with an actual tab character, which most terminals treat as 8-spaces wide. But you can change that by setting completer.indent to whatever string you want. Are you sure it is using actual spaces? >> * completes on module names in `import` and `from` statements >> * completes on file names inside strings > > I'm not sure what causes this but I have a symlink in my user > directory called "current" that just takes me to the things I'm > currently working on. When I tab complete it it puts in a quote > character: > >>>> with open('current' > > I think it thinks that "current" is a complete filename when it's > actually a symlink to a directory containing other things. If I delete > the quote and add a slash then it continues to complete normally. Weird. It shouldn't be adding a close quote. Mind you, there appears to be at least one other bug in the file name completion, so I need to work on that soon. However, I can reproduce the bug, so I'll work on that too. Thank you for the report! -- Steven -- https://mail.python.org/mailman/listinfo/python-list