Commit graph

28 commits

Author SHA1 Message Date
Nathaniel Nicandro
42a9765897 Fix typo
Change `target-name` to `target_name`
2022-01-05 13:43:26 -06:00
Nathaniel Nicandro
7786d30468 Refactor message sending/receiving
`jupyter-handle-*` methods now only take an argument list like

    (client req msg)

instead of each method being passed an expanded list of arguments
unpacked from a message contents. Not sure why the unpacking was done
in the first place. The strategy now is to use
`jupyter-with-message-contents` when accessing the contents of a
message.

* jupyter-client.el
(define-jupyter-client-handler)
(define--jupyter-client-sender): New macros.
(jupyter-send-execute-request)
(jupyter-send-inspect-request)
(jupyter-send-complete-request)
(jupyter-send-history-request)
(jupyter-send-is-complete-request)
(jupyter-send-comm-info-request)
(jupyter-send-comm-open)
(jupyter-send-comm-msg)
(jupyter-send-comm-close)
(jupyter-send-kernel-info-request)
(jupyter-send-shutdown-request): Use `define--jupyter-client-sender`.
(jupyter-handle-input-request)
(jupyter-handle-execute-reply)
(jupyter-handle-inspect-reply)
(jupyter-handle-complete-reply)
(jupyter-handle-history-reply)
(jupyter-handle-is-complete-reply)
(jupyter-handle-comm-info-reply)
(jupyter-handle-kernel-info-reply)
(jupyter-handle-shutdown-reply)
(jupyter-handle-comm-open)
(jupyter-handle-comm-close)
(jupyter-handle-stream)
(jupyter-handle-execute-input)
(jupyter-handle-execute-result)
(jupyter-handle-error)
(jupyter-handle-status)
(jupyter-handle-clear-output)
(jupyter-handle-display-data)
(jupyter-handle-update-display-data): Use
`define-jupyter-client-handler`.

* jupyter-org-client.el
(jupyter-handle-stream)
(jupyter-handle-error)
(jupyter-handle-execute-result)
(jupyter-handle-display-data)
(jupyter-handle-execute-reply): Update to take into account changes in
the argument lists of `jupyter-handle-*` methods.

* jupyter-python.el
(jupyter-handle-error): Ditto.

* jupyter-repl.el
(jupyter-handle-execute-reply)
(jupyter-handle-execute-result)
(jupyter-handle-clear-output)
(jupyter-handle-display-data)
(jupyter-handle-update-display-data)
(jupyter-handle-status)
(jupyter-handle-stream)
(jupyter-handle-error):
(jupyter-handle-history-reply)
(jupyter-handle-shutdown-reply): Ditto.

* jupyter-widget-client.el
(jupyter-handle-comm-open)
(jupyter-handle-comm-close)
(jupyter-handle-comm-msg): Ditto.
2021-04-03 12:22:58 -05:00
Nathaniel Nicandro
403c70c83c Bump version 2020-04-07 15:13:51 -05:00
Nathaniel Nicandro
7ffc27ed2e jupyter-widgets-client.el: Refactor jupyter-handle-comm-open
* jupyter-widget-client.el (jupyter-widgets-start-websocket-server)
(jupyter-widgets--initialize-client): New functions.
(jupyter-handle-comm-open): Use them.
2020-03-12 23:22:57 -05:00
Nathaniel Nicandro
0e68f0f2f4 Remove a call to cons
* jupyter-widget-client.el (jupyter-widgets-on-message): Do it.
2020-03-12 23:22:57 -05:00
Nathaniel Nicandro
68afaab9b5 jupyter-widgets-sanitize-comm-msg -> jupyter-widgets-normalize-comm-msg
* jupyter-widget-client.el (jupyter-widgets-sanitize-comm-msg): Do it. Update
  all callers.
2020-03-12 23:22:56 -05:00
Nathaniel Nicandro
16176b197a Remove some code duplication
* jupyter-widget-client.el (jupyter-widgets--send-deferred): New function.
(jupyter-widgets-on-message, jupyter-widgets-send-message) Use it.
2020-03-12 23:22:56 -05:00
conao3
fb8c2c75fd two spaces after a period 2020-03-12 18:20:15 -05:00
conao3
1546a72f57 clean header 2020-03-10 23:39:35 -05:00
Nathaniel Nicandro
6650dd3588 Bump version 2019-07-24 16:03:22 -05:00
Nathaniel Nicandro
08a4723c0b jupyter-widgets-on-message: Fix wrong argument to jupyter-send 2019-07-10 12:02:13 -05:00
Nathaniel Nicandro
5ea32a70f0 Change License to GPL3 2019-05-31 09:44:39 -05:00
Nathaniel Nicandro
112769e0c6
Bump version 2019-05-04 03:31:50 -05:00
Nathaniel Nicandro
83af335166
Bump version 2019-03-14 09:29:11 -05:00
Nathaniel Nicandro
d4969cbfcc CHANGELOG.org: Add function to change version numbers 2019-02-14 23:05:00 -06:00
Nathaniel Nicandro
63717b9e39
Bump version 2019-02-12 09:17:06 -06:00
Nathaniel Nicandro
0a34860707
Fix package-lint errors 2019-02-07 11:17:24 -06:00
Nathaniel Nicandro
081f329da1 v0.6.0 2018-11-16 00:27:47 -06:00
Nathaniel Nicandro
75abea913d Update tests 2018-11-15 23:04:27 -06:00
Nathaniel Nicandro
a2fb08c99f jupyter-widgets-on-message: Error if a message gives an unsupported channel 2018-10-31 18:49:37 -05:00
Nathaniel Nicandro
089e0b7f17 jupyter-widget-client.el: Fix documentation wording 2018-10-31 18:49:37 -05:00
Nathaniel Nicandro
3d8049da6d Reduce the use of deprecated functions 2018-10-25 23:17:25 -05:00
Nathaniel Nicandro
d03270c7ed Update commentary 2018-10-25 22:57:33 -05:00
Nathaniel Nicandro
c070f2d04d Update documentation and comments 2018-10-25 22:57:23 -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
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
9429438370 Use a websocket for communicating with the browser displaying widgets 2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
50088df2e0 Add widget support 2018-05-28 01:25:09 -05:00