ipython/ipython — pull request #1417 by Carreau (2012-02-19 16:03:59+00:00)
Title: Notebook Completer Class

I've try to reimplement the completer (almost) from scratch, in a different class.
If you would like to test and tell me if you come through strange behavior/bad completion/regression from previous completions..

I've added at the end of the completion list completion based on the `words` of the current cell. With `words` that still need to be better parsed ... :

```
def myplot():
xlmax = 10;
plot(range(10))
xlabel("hi xlxl")
xl
```
proposes as before (in order):

* `xlabel`
* `xlim`

but also now ( in order below the previous ) :

* `xlmax` (a)
* `xlabel("hi ` (b)
* `xlxl")` (b)

(a) it's really cool, to have local variable completion
(b) This still really dumb, and need to be tweeked , but i'm not a god in CodeMirror, neither in regexp. I'm sure there should be a way to use the coloration parser to give more accurate results, or a better list of `tokens` than just splitting the cell's text on `\n`and `.`

If someone want to take a shot at writing something that give better `context` completion, you _just_ have to write a JS function, that given an editor instance return a list of tokens...

This also add a `IPython.utils.keycodes` with some common values used here and there making this :

```js
else if (event.which === key.enter && event.shiftKey)
```

slightly more readable and less error-prone than

```js
else if (event.which === 13 && event.shiftKey)
```