Commit graph

197 commits

Author SHA1 Message Date
Nathaniel Nicandro
adcc853183 Use pcase in one place
* jupyter-org-client.el (jupyter-org--find-mime-types): Do it.
2020-04-14 12:24:42 -05:00
Nathaniel Nicandro
403c70c83c Bump version 2020-04-07 15:13:51 -05:00
Nathaniel Nicandro
5c2469dbe4 Don't set org-babel-jupyter-current-src-block-params
This variable is `let` bound by `org-babel-execute:jupyter` and its value reset
after that function has completed and therefore does not need to be set to
`nil` by `jupyter-drop-request`.

fixes #234
fixes #235

* jupyter-org-client.el: Remove duplicated `defvar` of
`org-babel-jupyter-current-src-block-params`.
(jupyter-drop-request): Remove use of
`org-babel-jupyter-current-src-block-params`.
2020-04-02 15:31:08 -05:00
Nathaniel Nicandro
bb50dfb830 Use org-element-create 2020-03-12 23:56:13 -05:00
Nathaniel Nicandro
226a14b232 Handle inline results similar to non-inline
fixes #204

* jupyter-org-client.el (jupyter-handle-execute-result): Call
`jupyter-org-result` on DATA when a code block is being evaluated inline.
2020-03-12 23:56:13 -05:00
Nathaniel Nicandro
e6e9694f94 Do more cleanup after finishing Org src-block requests
* jupyter-org-client.el (jupyter-drop-request): Reset
  `org-babel-jupyter-current-src-block-params` if its value matches the dropped
  request's `block-params`.
2020-03-12 23:13:58 -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
c1b597556b Light refactoring
* jupyter-base.el: Don't add `jupyter-server-mode--unset-client-soon` to
`server-switch-hook` at toplevel
(jupyter-server-mode-set-client): Add `jupyter-server-mode--unset-client-soon`
to `server-switch-hook` if necessary.

* jupyter-client.el: (jupyter--run-callbacks): Use `when-let`.
(jupyter--set-callback): Remove.
(jupyter--add-callback): Use `add-function`.

* jupyter-ioloop.el (jupyter-ioloop-add-arg-type): Use `setf` along with `alist-get`.
(jupyter-ioloop--replace-args): Use `pcase`.
(jupyter-ioloop--event-dispatcher): Extract out event cases into variable `user-events`.
(jupyter-ioloop--body): New function.
(jupyter-ioloop--function): Use it.

* jupyter-kernel-process-manager.el
(jupyter--kernel-died-process-sentinel)
(jupyter-stop-channels): Use `when-let`.

* jupyter-org-client.el (jupyter-org-interaction-mode): Use `cl-callf2?`.

* jupyter-server.el: Add TODO.

* jupyter-tramp.el: Remove unused function declaration.
2019-09-22 14:27:40 -05:00
Nathaniel Nicandro
198c036f51 jupyter-org-indent-inserted-region: Reduce verbosity of doc 2019-09-22 13:33:42 -05:00
Nathaniel Nicandro
afbb9b5134 jupyter-generate-request (jupyter-org-client): Handle indirect buffers
Verify that the `major-mode` of the `buffer-base-buffer` is derived from
`org-mode` if the `current-buffer` happens to be an indirect one. This should
allow `emacs-jupyter` to work better with `polymode`. See #171.
2019-09-14 17:20:52 -05:00
Nathaniel Nicandro
e1564dfc93 jupyter-org-result: Include message type in warning
When the `:display` header argument is used and a particular message type
doesn't return a mime bundle with one of the requested mime types, include the
message type in the warning that is displayed.

This should clarify the situation where an `:execute-result` and
`:display-data` message both return data to display, but one of them does not
have one of the mimetypes requested in the `:display` header argument.

Closes #144.
2019-09-12 17:30:48 -05:00
Nathaniel Nicandro
438ac0afd4 jupyter-org--image-result: Prefer when instead of if 2019-09-10 13:43:02 -05:00
Nathaniel Nicandro
79ddd9357e Add org-babel-jupyter-current-src-block-params
This is needed because `org-mode` merges many sources of source block params so
its not enough to just re-compute the parameters in `jupyter-generate-request`
using `org-babel-get-src-block-info` or `org-babel-log-get-info`.
2019-09-01 11:43:46 -05:00
Nathaniel Nicandro
a0b33a5861 jupyter-org--fixed-width-to-example-block: Preserve blank lines 2019-07-27 00:06:18 -05:00
Nathaniel Nicandro
c91861cef9 jupyter-org--delete-element -> jupyter-org-delete-element
* jupyter-org-client.el (jupyter-org--delete-element):
Do it and also adhere to documentation. Update all callers.
2019-07-27 00:04:34 -05:00
Nathaniel Nicandro
93f21b077b jupyter-org--do-insert-result: Handle control codes in stream output
* jupyter-org-client.el (jupyter-handle-stream): Remove control code handling.
(jupyter-org--handle-control-codes): New function.
(jupyter-org--do-insert-result): Do it.
2019-07-26 23:16:05 -05:00
Nathaniel Nicandro
11b293438d jupyter-generate-request (jupyter-org-client): Consider babel-call org elements
Fixes #154.
2019-07-25 03:48:18 -05:00
Nathaniel Nicandro
6650dd3588 Bump version 2019-07-24 16:03:22 -05:00
Nathaniel Nicandro
cb1efa4268 jupyter-org--image-result: Fix a few issues
* jupyter-org-client.el (jupyter-org--image-result):
Be more stringent on checking the value of `org-image-actual-width`. `listp`
returns t when passed nil, a valid value of `org-image-actual-width`.

Use absolute filenames when calling `create-image`.
2019-07-14 17:56:33 -05:00
Nathaniel Nicandro
2992e24e57 jupyter-org--image-result: Fix byte-compile warning, update documentation
* jupyter-org-client.el (jupyter-org-adjust-image-size): Cleanup documentation.
(jupyter-org--image-result): Do it.
2019-07-14 17:20:41 -05:00
Nathaniel Nicandro
1b1a55ef3f Add jupyter-org-request-at-point
* jupyter-org-client.el (jupyter-org-request-at-point): Do it.
(org-babel-jupyter-src-block-session): New declare.

* ob-jupyter.el (org-babel-jupyter-session-clients): Add doc about keys.

* test/jupyter-test.el (jupyter-org-request-at-point): New test.
2019-07-14 17:20:41 -05:00
Nathaniel Nicandro
df6651a1f1 jupyter-org-result: More informative error
* jupyter-org-client.el (jupyter-org-result): Do it.
2019-07-14 17:03:38 -05:00
Yevgnen
c5c2c84a0d Add jupyter-org-adjust-image-size (#147) 2019-07-14 12:44:31 -05:00
Nathaniel Nicandro
7c1689e33d jupyter-org-client.el: Don't assume non-empty strings 2019-07-11 16:40:37 -05:00
Nathaniel Nicandro
8f9ec15af0 Add jupyter-org-table-string 2019-06-30 12:22:26 -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
25ff5dd871 jupyter-org-client: Remove unnecessary block-params slot 2019-06-23 16:11:27 -05:00
Nathaniel Nicandro
4533246173 Fix customization type of jupyter-org-pandoc-convertable 2019-06-13 10:48:04 -05:00
Nathaniel Nicandro
08b90d48fa jupyter-org-define-key: Fix key lookup test 2019-06-13 00:32: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
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
932baad379 jupyter-org--set-current-src-block: Use org-babel-jupyter-language-p
So that we account for overriding the source block language.
2019-06-02 01:19:15 -05:00
Nathaniel Nicandro
5ea32a70f0 Change License to GPL3 2019-05-31 09:44:39 -05:00