Commit graph

191 commits

Author SHA1 Message Date
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
Nathaniel Nicandro
b715ada492 Always name method arguments
If method arguments are not named it gives rise to errors like

    `Args out of range: "", 0`

that originate in `help-function-arglist` when calling `describe-function` on
those methods.
2019-05-09 13:32:45 -05:00
Nathaniel Nicandro
112769e0c6
Bump version 2019-05-04 03:31:50 -05:00
jackkamm
748598b7be Add pandoc conversion of rich outputs (#97) 2019-04-28 15:17:19 -05:00
Nathaniel Nicandro
80c623ab40
jupyter-org--set-current-src-block: Simplify calculation of block end
This also fixes an edge case when there is only one blank line after the source
block. The previous version would consider the beginning of the last line of
the code block as the end instead of the beginning of the `#+end_src` line in
that case.
2019-03-31 10:40:09 -05:00
Nathaniel Nicandro
9ff1722293
jupyter-org-with-src-block-client: Macro hygiene 2019-03-27 22:26:26 -05:00
Nathaniel Nicandro
3f3db53527 Handle ANSI escape sequences in org-mode src-block results 2019-03-20 21:08:53 -05:00