Discretion in quote-closing a completed dict key

This pertains to #5304 and the issue [noted there](https://github.com/ipython/ipython/pull/5304#issuecomment-42062566) by @takluyver. It takes a fairly maximal approach to solving it, while Thomas suggested something minimal.

This PR distinguishes a completion request from a readline frontend to those triggered otherwise. It avoids an explicit endquote in the readline case.

I have managed to test it with:
* local console with readline
* `--existing` console with readline
* notebook

I do not have qt set up to test there.

@takluyver, WDYT?

(I am yet to add a unit test with `from_readline=True`.)