Commit graph

69 commits

Author SHA1 Message Date
Nathaniel Nicandro
4e2e8642ed
Update a few comments 2019-01-22 18:39:17 -06:00
Nathaniel Nicandro
d709b31a64
Add jupyter-message-lambda
This simplifies the writing of message callbacks.
2019-01-22 18:39:17 -06:00
Nathaniel Nicandro
9560af95b2
jupyter-with-message-data: Add debug spec 2019-01-19 15:27:19 -06:00
Nathaniel Nicandro
1c6a5e4363
jupyter--decode-message-part: Return nil when MSG is nil 2019-01-17 18:59:41 -06:00
Nathaniel Nicandro
916b2cf912 jupyter-with-message-content: Fix debug declaration 2018-11-26 12:37:37 -06:00
Nathaniel Nicandro
50ac28910a Remove usage of deprecated when-let
This was deprecated in Emacs 26.1
2018-11-16 04:59:09 -06:00
Nathaniel Nicandro
ca44a3922d Use universal time when encoding time values
* jupyter-messages.el (jupyter--encode-time): Do it.

* test/jupyter-test.el (jupyter-messages): Update test.
2018-11-16 04:49:43 -06:00
Nathaniel Nicandro
081f329da1 v0.6.0 2018-11-16 00:27:47 -06:00
Nathaniel Nicandro
a4e7fbf7ba Use defsubst for some message functions
* jupyter-messages.el (jupyter-message-id, jupyter-message-parent-id):
(jupyter-message-type, jupyter-message-session, jupyter-message-parent-type):
(jupyter-message-get, jupyter-message-data, jupyter-message-status-idle-p): Do it.
2018-11-15 23:04:27 -06:00
Nathaniel Nicandro
4dc229935b jupyter-messages.el: Update commentary 2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
1371947785 jupyter-message-type-as-keyword: Simplify loop
* jupyter-messages.el (jupyter-message-type-as-keyword): Do it.
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
d3dc23d2b1 jupyter--decode: Simplify post processing of :msg_type key
* jupyter-messages.el (jupyter--decode): Do it.
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
0fb39492e3 jupyter-encode-message: Refactor
* jupyter-messages.el (jupyter-encode-message): Do it.
(jupyter--message-header): Require MSG-ID argument. Given by
`jupyter-encode-message'.
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
344e7b72ce jupyter--split-identities: Simplify loop
* jupyter-messages.el (jupyter--split-identities): Do it.
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
d124ea2d64 jupyter-decode-message: Remove unnecessary quoting
* jupyter-messages.el (jupyter-decode-message): Do it.
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
8c870cf592 jupyter-sign-message: Simplify loop
* jupyter-messages.el (jupyter-sign-message): Do it.
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
7aa43f6464 Decode :date fields on demand
* jupyter-messages.el (jupyter--decode): Remove handling of :date field.
(jupyter-message-time): Decode :date field if necessary.
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
a93f38608c Allow a SIGNER argument to message encode, decode, and signing functions
* jupyter-messages.el: (jupyter--sign-message)
(jupyter--decode-message, jupyter--encode-message):
Promote to public functions. Update all callers.
(jupyter-sign-message): Add optional SIGNER argument.
(jupyter-decode-message, jupyter-encode-message): Add SIGNER key argument.
SIGNER argument defaults to `jupyter-hmac-sha256`
2018-11-13 17:46:07 -06:00
Nathaniel Nicandro
348541dfe7 Update documentation and commentary 2018-11-08 21:30:32 -06:00
Nathaniel Nicandro
becddfc9ea Fix requires
`jupyter-channels.el` depends on the `jupyter-send` method defined in
`jupyter-messages.el` whereas `jupyter-messages.el` does not depend on any
functions in `jupyter-channels.el`.

* jupyter-channel.el: Require `jupyter-messages`

* jupyter-messages.el: Remove `jupyter-channels` require
2018-11-08 21:30:32 -06:00
Nathaniel Nicandro
c30357badb jupyter-with-message-content: Allow debugging inside the macro 2018-10-31 18:49:37 -05:00
Nathaniel Nicandro
1697f44761 jupyter-with-message-content: Reword documentation 2018-10-27 22:16:54 -05:00
Nathaniel Nicandro
e06e61e9fd jupyter-messages.el: Small documentation changes 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
e43c6597ad Add convenience macros for working with messages 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
c070f2d04d Update documentation and comments 2018-10-25 22:57:23 -05:00
Nathaniel Nicandro
0bf30538e6 Refactor encoding/decoding of message-part lists for readability 2018-10-16 13:55:57 -05:00
Nathaniel Nicandro
7b3e4f9f84 Fix encoding/decoding time objects
* Handle the case of no time specification by defaulting to midnight when
  decoding time

* Properly handle fractions in `jupyter--decode-time`

* Implement `jupyter--encode-time`

* Consider a time object to be a length 4 list of integers and encode the
  object using `jupyter--encode-time` when encoding in `jupyter--encode`

* Add tests for time decoding/encoding
2018-10-16 13:55:30 -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
70be58129e Rename jupyter-message-parent-message-type -> jupyter-message-parent-type 2018-05-30 12:49:28 -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
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
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
4edc22832b Override json-encode in jupyter--encode to take into account message types 2018-05-20 11:03:58 -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
7d7b7650b9 Mainly code style changes 2018-05-15 16:45:24 -05:00
Nathaniel Nicandro
53ebf1ad35 Ensure a unibyte representation when signing messages 2018-05-06 03:16:47 -05:00
Nathaniel Nicandro
9ddec6c469 Decode date fields into time objects in jupyter--decode 2018-05-05 23:16:01 -05:00
Nathaniel Nicandro
24eb475443 Cleanup comments 2018-02-12 10:25:13 -06:00
Nathaniel Nicandro
255247788c Remove uses of seq functions
Since this is an emacs 25 dependency and there were not many uses of these
functions, remove them.
2018-02-09 09:11:57 -06:00
Nathaniel Nicandro
3170a2305f Add documentation for jupyter-message convenience functions 2018-01-18 23:02:24 -06:00
Nathaniel Nicandro
5d9244b17b Rename jupyter--encode-object -> jupyter--encode, jupyter-decode-string -> jupyter--decode` 2018-01-09 00:44:35 -06:00
Nathaniel Nicandro
a7539dc37b Fix checkdoc warnings 2018-01-09 00:44:34 -06:00