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
copy nbformat.v3 to v4
update v4 schema

use jsonschema refs, no need for jsonpointer
update v4 schema mime-type expression

fixes inappropriate JSON match
source is required in all cells
raise ValidationError in v4 validate

also only load the schema once and store it in a module global
first complete pass on v4

tests passing, notebooks validating
Use Draft4 JSON Schema for v4
no longer need separate v4.compose

put it back in nbbase, and work around circular import another way