don't pick up tokens right of cursor

inspection of `foo(|a` was picking up 'a'
instead of 'foo' due to an off by one error
Handle some tricky Comm lifecycle issues

* If the comm was a primary comm, but there was an error opening it, _closed was False, which is wrong
* If Comm.close() was called, but an error happened, it still appeared to be open

This change makes the _closed attribute more conservative.  If _closed is False, the comm is definitely open for messages.  If _closed is True, we either didn't initialize correctly, or we tried to close at some point.
Unregister comm if there is an error in publishing the comm open message
only sort small dicts and sets in lib.pretty

The sorting caused performance problems when displaying large collections,
even when the result would be truncated.
Merge pull request #6775 from jasongrout/comm-lifecycle

Handle some tricky Comm lifecycle issues
Fixed "data" to "text" change in message spec

This fix was accidentally omitted when the message spec recently changed.
Merge pull request #6788 from dsblank/patch-2

Fixed "data" to "text" change in message spec
Correct the example notebook link to What is the IPython Notebook?
Fix bad JSON link and inconsistent link formatting.
Merge pull request #6794 from PhillipNordwall/example_dev

Example dev
Merge pull request #6777 from minrk/pretty-big-set

only sort small dicts and sets in lib.pretty
Merge pull request #6774 from minrk/token-boundary

don't pick up tokens right of cursor
only complete on current line

completion messages are multi-line,
but IPython completer code assumes single-line.

For now, just pass the current line to the underlying completer.
Merge pull request #6797 from minrk/qt-complete-request

only complete on current line
cache kernel_info reply for protocol adaptation

WebSocket connections will not open until kernel_info is retrieved,
removing a race condition waiting for the reply to indicate adaptation,
which could result in a v5 message being sent to a v4 kernel.
The reply is cached, so that it need not be requested on each new connection.
add websocket workarounds for tornado 3

WebSocketHandler.get is new in tornado 4
Don't resend kernel info requests if a bad reply is received