[Idle-dev] Small patch to AutoExpand.py

Guido van Rossum guido@python.org
Thu, 02 Mar 2000 08:47:27 -0500


> [Mark Hammond]
> > While using the auto-expand feature, it struck me that it really
> > should also match against builtin names.
> >
> > Eg, if I enter "Index" and select auto-complete, IndexError should
> > appear, even if it doesnt exist in the source file.
> >
> > Does anyone else agree?

[Tim]
> Guido notwithstanding <wink>, I agree.  "Complete a name" is a single
> concept in my head, not helped by Emacs-like prissy distinctions attached to
> yet another batch of key bindings.  The way to make this pleasant *and*
> useful is to (over time) increase a single function's context awareness.
> 
> BTW, I've written word-completion pkgs for several editors that lacked the
> feature, and one of the most valuable things you can do for programmers is
> to search *other* open buffers for names too (e.g., picture editing a .cpp
> file where a heavily used .h file is open in another buffer).  When it gets
> to this stage, it's also valuable to display a status msg giving the file
> name & line number of the currently-suggested completion.

Absolutely true -- Emacs' dabbrev-expand (Alt-/ for me) does this.  It
also lets you cancel the search (it can take a while to search 200
buffers).

By the way, there's a different distinction possible here.  Mark seems
to be fond of features like call-tips and attribute-tips that pop up
little yellow windows without asking.  I've met at least one user who
turned off call-tips in IDLE, and I must say that it's a mixed
blessing for me.  (Maybe it should disappear quicker?)  The completion
feature is only invoked when the user hits a key (Alt-/ or
Control-space or tab or whatever).

Assuming we have a single context-sensitive completion, that you hit
repeatedly until the right suggestion shows up (like in Emacs).  When
you exhaust the attributes of the object it thinks you are looking at,
should it continue to try other names it finds in the same buffer or
in other buffers that start with the same prefix?  Example:

I'm looking at "x.a" and I hit Alt-/.  It knows there's a global x and
it knows x has attributes 'argument' and 'alphabet', so it will
suggest these in some order.  After exhausting the list, should it try
other a-words in the same buffer?  This seems silly, but perhaps the
context is this:

class C:
  argument = 1
  alphabet = "abc"

anchor = "foo"
x = C()
x.a
   ^

Quite possibly I want to type "x.anchor = anchor"; but just as likely
I might want to display x.argument or x.alphabet...

In my design I would hit control-space to see the existing attributes,
and Alt-/ to expand from any nearby identifier.

Clearly an area where we could do some user testing...

--Guido van Rossum (home page: http://www.python.org/~guido/)