Commit graph

619 commits

Author SHA1 Message Date
Nathaniel Nicandro
ed793fc183 Use string-match-p instead of string-match 2018-10-16 13:55:30 -05:00
Nathaniel Nicandro
bbb677c573 Pop up traceback buffer on errors when executing code blocks 2018-10-16 13:55:30 -05:00
Nathaniel Nicandro
892ab84148 Silence byte compiler warnings 2018-10-16 13:55:30 -05:00
Nathaniel Nicandro
23cecb9c0f [WIP] Widget support in ob-jupyter 2018-10-16 13:55:30 -05:00
Nathaniel Nicandro
10a56c2f54 Refactor widget implementation
* Use the `target-name` argument in `jupyter-handle-comm-open`

* Remove hard-coded URL format and use the new variable
  `jupyter-widgets-url-format` instead

* Add `jupyter-widgets-supported-targets` to explicitly state which widget
  targets are supported

* Rename `widget-proc` to `widget-sock` in a `jupyter-widget-client`

* Initialize the widget socket only when opening a valid comm

  * Previously it was initialized when the client was initialized, but a client
    may not even create any widgets so the widget socket would be unused.

* Use `pcase` in `jupyter-widgets-on-message`

* Update documentation and commentary of `jupyter-widget-client`
2018-08-30 18:12:18 -05:00
Nathaniel Nicandro
2552b4ff99 Add notes on how EmacsJupyter works 2018-08-30 18:12:18 -05:00
Nathaniel Nicandro
c207bea8d4 Fix indentation 2018-08-30 18:02:25 -05:00
Nathaniel Nicandro
c7c50f4908 Better error reporting when the kernel process dies in jupyter-start-kernel 2018-08-30 18:02:25 -05:00
Nathaniel Nicandro
22b1e809a0 Update documentation, cleanup comments 2018-08-30 18:02:13 -05:00
Nathaniel Nicandro
ce3d9a377c Refactor jupyter--sign-message 2018-05-30 12:54:55 -05:00
Nathaniel Nicandro
122748b25e Do not pass the signature when signing message parts 2018-05-30 12:54:55 -05:00
Nathaniel Nicandro
7c218b233c Ensure that parts of a message that need to be dictionaries are encoded as such 2018-05-30 12:54:55 -05:00
Nathaniel Nicandro
81e3ebb44c Use jupyter-repl-language 2018-05-30 12:54:55 -05:00
Nathaniel Nicandro
8976a1d59e Remove special behavior of jupyter-repl-cell-count 2018-05-30 12:54:37 -05:00
Nathaniel Nicandro
04ecedd320 Only inhibit handlers when necessary
This ensures that any bookkeeping done in the handlers is actually performed.
2018-05-30 12:50:59 -05:00
Nathaniel Nicandro
d875ce7116 Do not display colon in prompts 2018-05-30 12:50:59 -05:00
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