[IPython-dev] greedy completer breaks useful completions - fixable?

MinRK benjaminrk at gmail.com
Mon Apr 2 17:55:44 EDT 2012


On Mon, Apr 2, 2012 at 15:46, Zachary Pincus <zachary.pincus at yale.edu>wrote:

> Hi all,
>
> The normal ipython tab-completer is pretty useful in that one can do
> things like:
> a(b.[TAB]
> to get a list of b's attributes while writing out the function call.
> Similarly,
> open('./[TAB]
> will list the documents in the cwd.
>
> However, after enabling the "greedy completer", very useful in its own
> right, this behavior goes away. e.g.
> a(b.[TAB]
> gives nothing.
>
> This comes down to the difference between DELIMS and GREEDY_DELIMS in
> IPython/core/completer.py:183.
>
> Is there any way that the greedy completer could have a larger set of
> delimiters? Though, in some sense the current GREEDY_DELIMS is already too
> large a set, as it includes the space char, which causes the following
> problems:
> def a(b,c): return b+c
> a('a','b').[TAB] # works
> a('a', 'b').[TAB] # doesn't work -- the space breaks the completer.
>
> Is there any to make the greedy completer to be a bit smarter without it
> having to be a full python parser? Maybe some logic  about what to do with
> balanced vs. unbalanced parens/braces might be appropriate? This sort of
> thing would fix both of the problems above.
>
> If people agree this is feasible, I could look into a patch, but I'm
> curious if anyone's tried/failed at this before...
>

This should absolutely be doable, and the current behavior should be
considered a bug.  I think greedy completion should produce a strict
superset of the completions from the regular competer.  The simplest way to
guarantee that this happens might be to *not* replace the completer like we
do, but call the original completer, then call a *different* one that only
does the item-completion, and merge the results.

-MinRK



>
> Thanks,
> Zach
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20120402/fbbb21e4/attachment.html>


More information about the IPython-dev mailing list