Commit graph

753 commits

Author SHA1 Message Date
Nathaniel Nicandro
382aa9999c Absorb displaying widgets into jupyter-repl-insert-data 2018-05-30 12:50:57 -05:00
Nathaniel Nicandro
d7a064cae5 Fix read-only error when inserting into the *jupyter-repl-output* buffer 2018-05-30 12:49:29 -05:00
Nathaniel Nicandro
3c34c1f7ed Do not handle reply messages with an error status specially 2018-05-30 12:49:28 -05:00
Nathaniel Nicandro
ff54004129 Do not rely on message time when dropping requests 2018-05-30 12:49:28 -05:00
Nathaniel Nicandro
70be58129e Rename jupyter-message-parent-message-type -> jupyter-message-parent-type 2018-05-30 12:49:28 -05:00
Nathaniel Nicandro
3a95d2705b Prevent flickering when updating displayed data 2018-05-30 12:49:28 -05:00
Nathaniel Nicandro
e7f1f8307a Refactor for readability
- Be more obvious in `jupyter-repl-ret`

- Prefer shorter lines in `js/emacs-jupyter.js`

- Add `jupyter-repl-language`

- Refactor `jupyter-handle-error` for `jupyter-repl-client's

  - Include margin width when fixing traceback spacing for python kernels

  - Extract out special handling of python kernels in `jupyter-handle-error`
2018-05-30 12:49:28 -05:00
Nathaniel Nicandro
1d9f9d06ad Include customization types 2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
00923a4bfd Do not rely on status messages to update REPL buffer state 2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
6e68a622cd Handle edge cases when starting a kernel and killing a REPL buffer
- Kill the REPL buffer without asking when the channels are closed

- Only emit a message if the kernel does not respond to a startup message
2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
7e8bdb6c7c Support display_id 2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
aa509d6bee Pass the metadata to jupyter-repl-insert-data 2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
5fd7ccf74f Enable syntax highlighting when using js2-mode with an IJavascript REPL 2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
e654487b2a Allow the possibility of preempting the handler methods using message hooks 2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
f4c931d57d Avoid double encoding, document message functions, small fixes to message functions
This introduces a way of keeping track of both the encoded and decoded parts of
a message, only decoding the parts of a message when needed, and only encoding
the parts of a message when needed.

If the objects passed to `jupyter--encode` or `jupyter--decode` are lists with
the first element being the symbol `message-part`, then the second element of
the list is interpreted as being the encoded message and the third element
being the decoded part of the message. If either the encoded or the decoded
part are nil, then `jupyter--encode` or `jupyter--decode` will fill those
message parts in and on subsequent calls, passing in the same list, no work
will need to be performed.

This avoids double encoding messages when relaying messages between the channel
subprocess and the browser displaying widgets. This speeds up the communication
process. The cost is storing two representations of the same message, i.e.
speed vs memory.

Fixes:

- Use `eq` instead of `equal` in message status predicates
- Fix time string decoding
  - `parse-time-string` was returning all nil on Emacs 26
- Include validation for parent header in `jupyter--encode-message`
- Use `jupyter-message-header' to access the message header instead of `plist-get`
2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
436089d08b Prefer defun over defsubst and other miscellaneous changes
- Add missing namespace to sha256 function

  - Any function defined should have a `jupyter-` prefix

- Remove `cl-lib` dependency in `jupyter-messages.el`

- Include `subr-x` in `jupyter-base.el`

- Use `tramp-file-name-user` instead of `tramp-file-name-real-user` since the
  latter is missing in Emacs 26
2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
f315a4bab0 Store open comm state in a jupyter-kernel-client 2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
9429438370 Use a websocket for communicating with the browser displaying widgets 2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
bcf750c9a8 Handle binary buffers properly when decoding messages 2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
17596ee1c4 Be less ambiguous when encoding/decoding messages
- Do not handle nil as an empty dictionary when encoding.

- Use the default `json-array-type`
2018-05-28 01:25:09 -05:00
Nathaniel Nicandro
554e519bf0 Avoid delays during message processing
- Allow specifying a msg-id before a call to `jupyter-send`

  - This avoid sending a message to the browser displaying the widgets on every
    message send to the kernel. The previous implementation generated a new ID
    without allowing the caller to pass one in.

- Simplify message polling by sending received messages from the kernel to the
  parent Emacs process at the moment of arrival.
2018-05-28 01:25:09 -05:00
Nathaniel Nicandro
276e2a0668 Support widgets in the REPL 2018-05-28 01:25:09 -05:00
Nathaniel Nicandro
50088df2e0 Add widget support 2018-05-28 01:25:09 -05:00
Nathaniel Nicandro
82c45fc3b9 Add jupyter-message-type-as-keyword 2018-05-28 01:25:09 -05:00
Nathaniel Nicandro
e3c7cce7c2 Add jupyter-message-parent-message-type 2018-05-28 01:25:09 -05:00
Nathaniel Nicandro
c357ee9c00 Avoid unnecessary work, remove improper usage of variable in ob-jupyter
- Do not add callbacks if source code block has no results

- Remove improper use of language argument to `org-babel-insert-result`
2018-05-28 01:25:01 -05:00
Nathaniel Nicandro
49c1f29d15 Better completion support
- Strip extra prefix from completion matches if necessary

  - The python kernel returns matches like foo.bar.baz, but we just want to
    show the baz part as a completion.

- Prevent completion after '.' in floating point numbers

  - Note this may be undesirable since numbers are just objects in many
    languages and thus have methods associated with them.

- Remove unused no-cache and match cases in `company-jupyter-repl`
2018-05-28 00:50:23 -05:00
Nathaniel Nicandro
be6a6b5c4c Call destructor methods in jupyter-repl-kill-buffer-query-function 2018-05-28 00:35:58 -05:00
Nathaniel Nicandro
4edc22832b Override json-encode in jupyter--encode to take into account message types 2018-05-20 11:03:58 -05:00
Nathaniel Nicandro
2f83bfd3ae Use jupyter-message-status-starting-p where appropriate 2018-05-20 11:03:06 -05:00
Nathaniel Nicandro
ccf3633604 Do not rename the connection file after is has been used to start a kernel 2018-05-20 11:02:24 -05:00
Nathaniel Nicandro
704e6d53ce Update documentation 2018-05-20 10:58:13 -05:00
Nathaniel Nicandro
97a5003b9b Update README to take into account recent changes 2018-05-16 22:27:27 -05:00
Nathaniel Nicandro
2d68aefa6e Better wording 2018-05-16 22:20:26 -05:00
Nathaniel Nicandro
ca7ff07a23 Update src blocks in README 2018-05-16 22:02:31 -05:00
Nathaniel Nicandro
b4b2c988b3 Update src blocks in README 2018-05-16 22:01:30 -05:00
Nathaniel Nicandro
cbf8010116 Take into account invisible characters in jupyter-repl-code-context-at-point 2018-05-16 21:54:30 -05:00
Nathaniel Nicandro
3a04fcfe5b Update tests 2018-05-16 21:54:30 -05:00
Nathaniel Nicandro
0cbe7f2114 Rename jupyter-repl-client.el to jupyter-repl.el 2018-05-16 21:54:30 -05:00
Nathaniel Nicandro
39c985d65d Validate jupyter-inhibit-handlers before sending a message 2018-05-16 21:54:30 -05:00
Nathaniel Nicandro
94171eba4a Update documentation 2018-05-16 21:54:29 -05:00
Nathaniel Nicandro
d74a28bc0c Validate the output of jupyter kernelspec list 2018-05-16 21:54:29 -05:00
Nathaniel Nicandro
4dd295cb2c Update README 2018-05-16 21:54:26 -05:00
Nathaniel Nicandro
1841e49b5d Be consistent with message types
Only use the message symbol's as defined in `jupyter-message-types` and switch
to the string representation only when sending a message.
2018-05-16 20:46:10 -05:00
Nathaniel Nicandro
1226c938fe Refactor jupyter-repl-kill-buffer-query-function for readability 2018-05-16 20:46:10 -05:00
Nathaniel Nicandro
8a2468973e Fix wrong order of variable names 2018-05-16 20:46:10 -05:00
Nathaniel Nicandro
3b3fe9c43f jupyter-<type> -> jupyter-send-<type> where appropriate 2018-05-16 12:25:57 -05:00
Nathaniel Nicandro
07ee759f90 Introduce jupyter-tunnel-connection 2018-05-15 23:43:33 -05:00
Nathaniel Nicandro
d93b7d7099 Add jupyter-read-plist 2018-05-15 23:43:32 -05:00
Nathaniel Nicandro
211a6a377b Do not unbind when collecting ports 2018-05-15 23:43:32 -05:00