Commit graph

1547 commits

Author SHA1 Message Date
Nathaniel Nicandro
58b715a4e8 Break up jupyter-channels.el to further decouple zmq
* jupyter-channel-ioloop.el (jupyter-zmq-channel): Require.
(jupyter-channel-ioloop-add-start-channel-event): `sync` -> `zmq`

* jupyter-comm-layer (jupyter-comm--channel): Moved from `jupyter-channels.el`.

* jupyter-kernel-manager.el: `sync` -> `zmq`

* jupyter-zmq-channel-comm.el: New file.

* jupyter-channels.el: Mostly renamed to jupyter-zmq-channel.el. The
`jupyter-channel` class was moved to `jupyter-channel.el`. All that remains are
those classes dependent on `zmq`.

* test/jupyter-test.el: `sync` -> `zmq` where appropriate.

Extract `jupyter-channel` class from `jupyter-zmq-channel.el` into its own file
2019-06-29 14:11:04 -05:00
Nathaniel Nicandro
b40b7de837 Do not depend strongly on zmq
Having the `jupyter-comm-layer` abstraction means we do not need to do so.

* jupyter-base.el (zmq): Un-require.
(jupyter-socket-types): Move to `jupyter-channels.el`.
(jupyter-session): Don't mention zmq in doc string.
(jupyter-available-local-ports, jupyter-make-ssh-tunnel): New functions.
(jupyter-tunnel-connection): Use them.

* jupyter-channel-ioloop-comm.el: New file.

* jupyter-channels.el (jupyter-messages): Un-require.
(jupyter-comm-layer, zmq): New requires.
(jupyter-socket-types): Moved from `jupyter-base.el`.
(jupyter-send, jupyter-recv):
Implementations for `jupyter-session` moved from `jupyter-messages.el`.
(jupyter-sync-channel-comm): `jupyter-comm-layer` implementation for
`jupyter-sync-channel` objects moved from `jupyter-comm-layer.el`.

* jupyter-comm-layer.el (jupyter-channel-ioloop): Un-require.
(jupyter-sync-channel-comm): Move implementation to `jupyter-channels.el`.
(jupyter-ioloop-comm): Move implementation to new file `jupyter-ioloop-comm.el`.
(jupyter-channel-ioloop-comm):
Move implementation to new file `jupyter-channel-ioloop-comm.el`.

* jupyter-ioloop-comm.el: New file.

* jupyter-ioloop.el (zmq): Require.

* jupyter-kernel-manager.el
(jupyter-make-client): Ensure `jupyter-channel-ioloop-comm` is required.

* jupyter-messages.el (jupyter-send)
(jupyter-recv): Moved to `jupyter-channels.el`

* jupyter-repl.el
(jupyter-connect-repl): Ensure `jupyter-channel-ioloop-comm` is required.

* test/jupyter-test.el (jupyter-available-local-ports): New test.

* test/test-helper.el (jupyter-channel-ioloop-comm): New require.
2019-06-29 10:29:55 -05:00
Nathaniel Nicandro
9dd8e8d9ec Localize functions defined in jupyter-base.el to their call sites
Fixes #137

* jupyter-base.el (jupyter-kernelspec): Un-require.
(jupyter-command, jupyter-locate-python)
(jupyter-runtime-directory): Move to new file `jupyter-env.el`
(jupyter-include-other-output, jupyter-iopub-message-hook)
(jupyter-shell-message-hook)
(jupyter-stdin-message-hook): Move to `jupyter-client.el`
(jupyter-sha256, jupyter-hmac-sha256):
(jupytern-new-uuid): Move to `jupyter-messages.el`. Add declaration of
`jupyter-new-uuid` to account for its removal.
(jupyter-create-connection-info)
(jupyter-write-connection-file): Move to `jupyter-kernel-manager.el`
(jupyter-connect-endpoint, jupyter-connect-channel): Move to `jupyter-channels.el`

* jupyter-channels.el: Accept moved functions.

* jupyter-client.el: Accept moved variables.

* jupyter-kernel-manager.el: Accept moved functions.
(jupyter-env, jupyter-kernelspec): New requires.

* jupyter-kernelspec (jupyter-env): New require.
(jupyter-command): Remove declaration.
(jupyter-read-plist-from-string): New declaration.

* jupyter-messages.el: Accept moved functions.
(hmac-def, json): New requires.

* jupyter-org-extensions.el (jupyter-kernelspec): New require.

* jupyter-repl.el (jupyter-kernelspec): New require.

* jupyter-env.el: New file.

* ob-jupyter.el (jupyter-env, jupyter-kernelspec): New requires.

* test/jupyter-test.el (jupyter-env): New require.
2019-06-29 10:29:55 -05:00
Nathaniel Nicandro
030c3e2d0c Fix issues with undo in the REPL
Related to let binding `buffer-undo-list` improperly and making text read-only
when it shouldn't be.

Fixes #139

* jupyter-repl.el (jupyter-repl-with-single-undo)
(jupyter-repl-inhibit-undo-when): New macros.
(jupyter-repl-insert): Inhibit undo only when insertions are `read-only`
(jupyter-repl-insert-prompt): Don't make continuation prompts `read-only`
(jupyter-repl-replace-cell-code): Allow the argument to be a `buffer`. Use
`replace-buffer-contents` in this case. Avoids unnecessary undo information.
(jupyter-handle-is-complete-reply): Don't insert a `read-only` newline on
incomplete cell code.
(jupyter-repl-indent-line): Pass buffer to `jupyter-repl-replace-cell-code`
(jupyter-repl-insert-continuation-prompts): Don't inhibit undo

* test/jupyter-test.el (jupyter-repl-undo): Add more tests.
2019-06-29 10:29:55 -05:00
Nathaniel Nicandro
d0518be10c Add jupyter-line-count-greater-p
Speeds up the line count test associated with
`jupyter-eval-short-result-max-lines` by an order of magnitude for somewhat
large strings. The byte compiled versions are not that different.
2019-06-28 20:13:24 -05:00
Nathaniel Nicandro
95b985e8d6 jupyter-repl-clear-cells: Move to cell code beginning 2019-06-28 20:13:24 -05:00
Jamie Forth
05d01ee1e5 jupyter-org-client.el: Check for tables when mime type is text/org
This allows for better integration with backends that can generate
org-format tables.
2019-06-28 20:12:52 -05:00
Nathaniel Nicandro
a4d95aab80 jupyter-handle-message: Drop idle messages less frequently
This accounts for idle messages being dropped before a request's reply message.
In such a case, the request is dropped from the client's request table before
the handlers/callbacks of the request get a chance to handle the reply message.
2019-06-25 09:58:14 -05:00
Nathaniel Nicandro
b7a7c31422 Add jupyter-kernel-managers 2019-06-25 09:35:02 -05:00
Nathaniel Nicandro
25ff5dd871 jupyter-org-client: Remove unnecessary block-params slot 2019-06-23 16:11:27 -05:00
Nathaniel Nicandro
19bcf2bba2 jupyter-hb--send-ping: Handle a closed socket 2019-06-23 16:11:27 -05:00
Nathaniel Nicandro
5bf04d24de jupyter-interrupt-kernel: Fix typo 2019-06-22 22:02:00 -05:00
Nathaniel Nicandro
d7b8719126 jupyter-ioloop--make-filter: Handle important events always
Previously events like start or quit would only get handled if
`jupyter-ioloop-handler` was called, but those events need to get handled
regardless.
2019-06-22 22:01:00 -05:00
Nathaniel Nicandro
34a4c8edf2 .travis.yml: Explicitly request trusty distribution
GCC in Xenial is buggy.
2019-06-22 22:00:00 -05:00
Nathaniel Nicandro
897183d11a Show Jupyter version info during CI tests 2019-06-22 21:59:00 -05:00
Nathaniel Nicandro
c73a597a48 jupyter-wait-until: Suspend timeouts when already waiting 2019-06-22 21:58:00 -05:00
Nathaniel Nicandro
44c3c1a9ea Add jupyter-comm-id
Used to get an identification string of the connection that a kernel client is
using.
2019-06-22 21:57:00 -05:00
Nathaniel Nicandro
1e84b42f42 Silence byte compile warning 2019-06-22 21:56:00 -05:00
Nathaniel Nicandro
3580228b6b jupyter-ioloop-post-hook: Adhere to the documentation 2019-06-22 21:55:00 -05:00
Nathaniel Nicandro
f023339a85 jupyter-org-insert-src-block: Respect the element under point 2019-06-22 21:54:00 -05:00
Nathaniel Nicandro
e87f26dee3 jupyter-code-context: Handle all values of parser state 2019-06-13 16:09:18 -05:00
Nathaniel Nicandro
4533246173 Fix customization type of jupyter-org-pandoc-convertable 2019-06-13 10:48:04 -05:00
Nathaniel Nicandro
74a6cfd541 Add test for jupyter-org-define-key 2019-06-13 10:46:19 -05:00
Nathaniel Nicandro
08b90d48fa jupyter-org-define-key: Fix key lookup test 2019-06-13 00:32:26 -05:00
Nathaniel Nicandro
1913da83fa org-babel-jupyter-scratch-buffer: Don't switch buffers when inside edit buffer 2019-06-12 23:22:20 -05:00
Nathaniel Nicandro
f3b94bab39 jupyter-start-kernel: Do nothing if kernel is already alive 2019-06-12 23:03:05 -05:00
Nathaniel Nicandro
23ad05fd64 jupyter-kill-kernel: Don't unbind the session slot of a kernel
Not really sure why this was done in the first place, but a kernel can be
forcibly killed and then asked to started up again, e.g. when restarting the
kernel.
2019-06-12 23:02:45 -05:00
Nathaniel Nicandro
b96a9c5b6a Update CHANGELOG 2019-06-12 21:10:26 -05:00
Nathaniel Nicandro
e7d80cf399 Add test for #126 2019-06-12 21:10:26 -05:00
Nathaniel Nicandro
99986e5978 jupyter-org-client.el: More robustly handle async insertion
Make less assumptions about where `point` is at when inserting results and
about the insertion context by relying only on
`org-babel-where-is-src-block-result` to move `point`. Centralize handling of
`point` to `jupyter-org--do-insert-result`.

* jupyter-org-client.el
(jupyter-org--first-result-context-p): Handle more cases.
(jupyter-org--append-stream-result-p): New function.
(jupyter-org--prepare-append-result): New function, abstracted from
`jupyter-org--insert-result`.
(jupyter-org--normalized-insertion-context): New function.
(jupyter-org--do-insert-result): New function.
(jupyter-org--insert-result): Move the bulk of the work to
`jupyter-org--do-insert-result`.
(jupyter-org--add-result): Use it.
2019-06-12 14:24:59 -05:00
Nathaniel Nicandro
fda5f0b414 jupyter-org-font-lock-ansi-escapes: Fix regexp for fixed-width blocks 2019-06-11 22:12:58 -05:00
Nathaniel Nicandro
9f15db7133 jupyter-org--append-to-example-block: Fix edge case
Fix the case when appending to a line without inserting a newline and adding
indentation.

Also add tests for `jupyter-org--append-to-example-block`
2019-06-11 22:12:58 -05:00
Nathaniel Nicandro
66f806f478 Add test for jupyter-org-indent-inserted-region 2019-06-11 22:12:58 -05:00
Nathaniel Nicandro
945c60b7cd Revert "jupyter-org--append-to-example-block: Remove indentation handling"
This reverts commit a24e984b68.
2019-06-11 22:12:58 -05:00
Nathaniel Nicandro
eda7e6dcc6 jupyter-org--insert-result: Fix indentation to that of the #+RESULTS line 2019-06-11 22:12:58 -05:00
Nathaniel Nicandro
878b323594 jupyter-org--append-to-fixed-width: Fix edge case 2019-06-11 20:17:06 -05:00
Nathaniel Nicandro
047746eeae Fix checkdoc warning 2019-06-11 17:54:36 -05:00
Nathaniel Nicandro
6005177537 Add jupyter-org--first-result-context-p
Makes the code read better.
2019-06-11 15:23:49 -05:00
Nathaniel Nicandro
44e3823a93 jupyter-org--wrap-result-maybe: Use cond 2019-06-11 15:22:27 -05:00
Nathaniel Nicandro
87bd83c99b jupyter-org--clear-request-id: Check if clearing should be done first 2019-06-11 15:21:08 -05:00
Nathaniel Nicandro
74f83393ff jupyter-org-font-lock-ansi-escapes: Consider indentation 2019-06-10 23:08:14 -05:00
Nathaniel Nicandro
782b4a8a52 Remove jupyter-org--delete-unwrapped-result
Move its functionality directly into `jupyter-org--insert-result`.
2019-06-10 22:52:41 -05:00
Nathaniel Nicandro
a3c5494926 jupyter-org-request-async -> jupyter-org-request-async-p 2019-06-10 19:32:30 -05:00
Nathaniel Nicandro
a24e984b68 jupyter-org--append-to-example-block: Remove indentation handling
This is now handled by `jupyter-org--insert-result`.
2019-06-10 19:32:30 -05:00
Nathaniel Nicandro
9839a29c7c jupyter-org-client.el: Refactor async insertion
Also consider indentation when inserting results. This was fairly easy to do
and didn't seem to warrant a separate commit.

* jupyter-org-client.el
(jupyter-org--insert-element): Remove. Update all callers.
(jupyter-org-delete-blank-line): New function.
(jupyter-org--delete-element): Use it.
(jupyter-org--stream-context-p): Consider indentation.
(jupyter-org--fixed-width-append): Remove. Update all callers.
(jupyter-org--append-to-fixed-width): Move example block promotion to
`jupyter-org--append-stream-result`.
(jupyter-org--append-to-example-block): New function.
(jupyter-org--append-stream-result): Use it.
(jupyter-org-indent-inserted-region): New macro.
(jupyter-org--insert-result): New method that splits the bulk of the old
function `jupyter-org--append-result` into a more manageable structure. Uses
new macro.
(jupyter-org--append-result): Remove it. Update all callers.
(jupyter-org--add-result): Refactor to consider above changes.
2019-06-10 19:32:30 -05:00
Nathaniel Nicandro
f5499c614a Silence checkdoc warning 2019-06-10 16:11:11 -05:00
Nathaniel Nicandro
195576bdbf jupyter-org--ansi-color-apply-on-region: Use cond 2019-06-10 16:11:11 -05:00
Nathaniel Nicandro
d6393d8e51 jupyter-org-define-key: Only bind KEY once in the top-level map 2019-06-09 15:49:50 -05:00
Nathaniel Nicandro
e370769636 jupyter-completion-at-point: Use sit-for
The completion at point functions are called several times in the course of a
single completion attempt so we get multiple chances to receive a completion
result. This means there is no need to wait for it to be received once and for
all on the first time completions are requested.
2019-06-09 15:13:07 -05:00
Nathaniel Nicandro
f491936928 jupyter-browse-url-in-temp-file: Prevent browsing file multiple times quickly
See https://github.com/dzop/emacs-jupyter/pull/121#issuecomment-495472406
2019-06-08 13:47:13 -05:00