Commit graph

1719 commits

Author SHA1 Message Date
Nathaniel Nicandro
1c45c3226b Mass rename of jupyter-comm-layer related functions
The following changes are made:

    `jupyter-initialize-connection` -> `jupyter-comm-initialize`
    `jupyter-connect-client` -> `jupyter-comm-add-handler`
    `jupyter-disconnect-client` -> `jupyter-comm-remove-handler`
    `jupyter-comm-client-loop` -> `jupyter-comm-handler-loop`

* README.org: Do it.

* jupyter-channel-ioloop-comm: Do it.

* jupyter-client.el: Do it.

* jupyter-comm-layer.el: Do it.
(jupyter-comm-layer): Rename `clients` slot to `handlers`. Update all uses.

* jupyter-kernel-process-manager.el: Do it.

* jupyter-repl.el: Do it.

* jupyter-server.el: Do it.

* jupyter-zmq-channel-comm.el: Do it.

* test/jupyter-server-test.el: Do it.

* test/jupyter-test.el: Do it.
2020-03-29 03:08:53 -05:00
Nathaniel Nicandro
b66ddf50eb Fix missing argument in call to tramp-run-real-handler
* jupyter-tramp.el (jupyter-tramp-expand-file-name): Do it.
2020-03-17 17:39:54 -05:00
Nathaniel Nicandro
de7af256a9 Add missing half of test
* test/jupyter-test.el (org-babel-jupyter-inline-blocks): Do it.
2020-03-16 01:00:23 -05:00
Nathaniel Nicandro
045f2b8b42 Fix recursive loading caused by autoload in jupyter-tramp.el
fixes #172
fixes #215

* jupyter-tramp.el (jupyter-tramp-file-name-p): Change to `defsubst`.
2020-03-14 14:39:35 -05:00
Nathaniel Nicandro
2e0b74c588 Remove unnecessary uses of ZMQ
* test/test-helper.el (jupyter-test-conn-info-plist)
(jupyter-test-ensure-notebook-server): Do it.
2020-03-14 14:39:35 -05:00
Nathaniel Nicandro
be8ee2c482 Remove unused function
That also happens to use a ZMQ function.

* jupyter-rest-api.el (jupyter-api-upload-large-file): Do it.

* jupyter-tramp.el: Remove mention of `jupyter-api-upload-large-file` in a
  comment.
2020-03-13 19:14:32 -05:00
Nathaniel Nicandro
308a4779d8 Handle variations in kernelspec language names more smoothly
* README.org: Add notes on behavior when a kernel's language name has spaces
  and uppercase characters.

* jupyter-base.el (jupyter-canonicalize-language-string): New function.

* jupyter-client.el (jupyter-kernel-info): Use it.

* jupyter-kernelspec.el (jupyter-available-kernelspecs): Use it.

* ob-jupyter.el (org-babel-jupyter-aliases-from-kernelspecs): Use it.

* test/jupyter-test.el (jupyter-canonicalize-language-string): New test.
2020-03-13 00:09:28 -05:00
Nathaniel Nicandro
5883bad935 Remove extra quote in jupyter-repl-interaction-modes :lighter
* jupyter-repl.el (jupyter-repl-interaction-mode): Do it.
2020-03-12 23:56:13 -05:00
Nathaniel Nicandro
bb50dfb830 Use org-element-create 2020-03-12 23:56:13 -05:00
Nathaniel Nicandro
cff20a5a6a Avoid an unnecessary error condition in jupyter-wait-until-idle
`jupyter-wait-until-idle` can return immediately if an idle message has already
been received, but the function `jupyter-wait-until` will eventually raise an
error in that case. Avoid the error by checking
`jupyter-request-idle-received-p` before calling `jupyter-wait-until`.

* jupyter-client.el (jupyter-wait-until-idle): Do it.

* ob-jupyter.el (org-babel-execute:jupyter): Account for changes in
  `jupyter-wait-until-idle`.
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
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
Nathaniel Nicandro
a4683d1a14 Deactivate REPL interaction buffers in kill-buffer-hook
* jupyter-repl.el (jupyter-repl--deactivate-interaction-buffers): New function.
(jupyter-repl-kill-buffer-query-function): Extract code that deactivates
`jupyter-repl-interaction-mode` in connected buffers to the new function.
(jupyter-repl-mode): Add the new function to `kill-buffer-hook`.
2020-03-12 23:13:58 -05:00
Nathaniel Nicandro
c26978baf8 Simplify doc of org-babel-jupyter-current-src-block-params
* ob-jupyter.el (org-babel-jupyter-current-src-block-params): Do it.
2020-03-12 23:13:58 -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
Nathaniel Nicandro
4a899deddc jupyter-repl.el: Prefer evaluate to run in documentation 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
conao3
6426e12578 ignore .cask folder 2020-03-10 23:39:35 -05:00
astoff
d4b06c54d3 jupyter-repl-traceback face: use a light background on light themes
The previous value of this face used a dark background even on light themes, making
error messages hard to read.
2020-03-05 18:42:07 -06:00
Arthur Colombini Gusmão
9e3c163358 fix: show pop-up buffer when REPL not visible
The described behavior for when `jupyter-repl-echo-eval-p` is `t` and the REPL buffer is not visible was not working, i.e., no pop-up buffer was being show.
2019-10-19 10:19:58 -05:00
Kevin Foley
8fdc3ae95b Preserve content in current cell when set to echo eval (#188)
* Preserve content in current cell when set to echo eval
2019-10-17 10:37:13 -05:00
Arthur Colombini Gusmão
7d5f978328 Move whitespace to overlay prefix
Move the whitespace that was originally concatenated to the prefix variable `jupyter-eval-overlay-prefix` to the variable itself, so that it can be easily customized. For instance, in the case where one does not want any prefix, with the changes, it can be easily removed by setting the prefix variable to the empty string. Originally one would have to also modify the function `jupyter-eval-ov--propertize` to achieve the same result.
2019-10-16 13:03:56 -05:00
Jack Kamm
7f82e5db8c ob-jupyter: fixes #185 relative path to remote :session json 2019-10-16 13:03:02 -05:00
Nathaniel Nicandro
53da538b66 jupyter-org-hydra/body: Add scratch buffer binding 2019-09-23 20:43:39 -05:00
Nathaniel Nicandro
e92d265869 jupyter-server-kernel-list-mode: Sort list by activity
* jupyter-server.el (jupyter-server--kernel-list-entries):
Add missing jupyter-time text property to activity string.
(jupyter-server-list-kernels): Set `tabulated-list-sort-key`.
2019-09-23 20:40:39 -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
dcf80d51db Remove jupyter-comm--channel
Since we are using keyword to represent channels on the client level, use a
plist of channels on the comm layer level instead of channel slots. This allows
us to remove `jupyter-comm-channel` and simplify the relevant code somewhat.
2019-09-17 11:42:21 -05:00
Nathaniel Nicandro
470521dac5 jupyter-current-server: Signal an error for non-existent servers
Only do so when asking the user for a URL and no server exists at the URL
provided. See #183.

* jupyter-server.el (jupyter-server-non-existent): New error.
(jupyter-current-server): Signal `jupyter-server-non-existent` when asking the
user for a server URL and a server doesn't exist at URL.
2019-09-15 20:26:54 -05:00
Nathaniel Nicandro
29b3a3d79f .travis.yml: Use nix-emacs-ci instead of evm 2019-09-15 19:01:16 -05:00
Nathaniel Nicandro
8fd5d8d95e Fix error handling in TRAMP functions for Emacs >= 27
TRAMP sets its own value of `signal-hook-function` which interferes with
`signal` data when handling errors in `condition-case` so unbind
`signal-hook-function` until we have a chance to look at `signal` data.

* jupyter-server.el (jupyter-kernel-alive-p): Use `nth`

* jupyter-tramp.el (jupyter-tramp--get-directory-or-file-model)
(jupyter-tramp-delete-directory): Unbind `signal-hook-function`.
2019-09-15 19:00:18 -05:00
Nathaniel Nicandro
aee4d39449 jupyter-decode-time: Remove fractional times before calling parse-iso8601-time-string
Emacs 27 seems not to be able to handle this case, maybe never has been able to
handle it properly.
2019-09-15 16:33:30 -05:00
Nathaniel Nicandro
8cca30aea3 Fix ert--print-backtrace being undefined during tests on Emacs >= 27
This is a workaround until `ert-runner` supports Emacs 27
2019-09-15 16:33:24 -05:00
Nathaniel Nicandro
a149107e2a Don't depend on libjpeg being installed during tests 2019-09-15 16:29:57 -05:00
Nathaniel Nicandro
49ad1eef83 jupyter-comm-id (jupyter-server-kernel-comm): Return kernel alias if available 2019-09-15 14:50:43 -05:00
Nathaniel Nicandro
2245d66b0f org-babel-execute:jupyter: Use "???" as a placeholder when inline results are pending
Closes #175.
2019-09-14 18:20:28 -05:00
Nathaniel Nicandro
774036e378 Update CHANGELOG 2019-09-14 17:49:57 -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
Yuji Nakao
f5560e56f6 Fix minor typo 2019-09-14 13:09:38 -05:00
Nathaniel Nicandro
2df28f2d9c README.org: Update TOC 2019-09-13 01:36:13 -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
c5fd3edc85 jupyter-available-kernelspecs: Clarify documentation 2019-09-12 17:24:54 -05:00
Nathaniel Nicandro
438ac0afd4 jupyter-org--image-result: Prefer when instead of if 2019-09-10 13:43:02 -05:00
Nathaniel Nicandro
4de01643c8 jupyter-eval: Revert back to not using jupyter-eval-string
`jupyter-eval-string` adds unwanted callbacks to the request. `jupyter-eval` is
meant to evaluate code without any changes occurring in the buffer.
2019-09-03 18:09:16 -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
aa9b634e7b jupyter-eval-string-command: Fix wrong number of arguments 2019-08-28 15:43:54 -05:00