Commit graph

72 commits

Author SHA1 Message Date
Nathaniel Nicandro
cdfefd5002 Increase timeouts during testing 2019-05-09 09:41:19 -05:00
Nathaniel Nicandro
5cd1e55616 org-babel-jupyter-strip-ansi-escapes: Handle blocks without results
Fixes #112.
2019-05-08 10:36:38 -05:00
Nathaniel Nicandro
4302da35ef Shutdown kernel properly when testing 2019-05-07 22:47:22 -05:00
Nathaniel Nicandro
e948d4f705 Try to make jupyter-weak-ref test more reliable 2019-05-07 22:47:22 -05:00
Nathaniel Nicandro
1d8f28f2fc Simplify test macros
Also fix misuse of `alist-get`. `alist-get` uses `assq` for comparison by
default, but we are comparing strings. This caused issues when caching REPL
buffers and the subsequent re-use of them during testing.
2019-05-07 17:30:16 -05:00
Nathaniel Nicandro
87d078edca Add more tests
* Add tests for `jupyter-weak-ref`, `jupyter-add-finalizer`, and `jupyter-eval`
2019-05-07 17:30:16 -05:00
Nathaniel Nicandro
112769e0c6
Bump version 2019-05-04 03:31:50 -05:00
Nathaniel Nicandro
c8dd1236df Generalize tests for Windows 2019-05-04 02:33:11 -05:00
Nathaniel Nicandro
4a07dc143e
Add test for jupyter-ioloop-wait-until 2019-05-04 01:27:54 -05:00
Nathaniel Nicandro
9dc814e38a
Add test for jupyter-connect-repl 2019-04-15 21:39:55 -05:00
Nathaniel Nicandro
cdc9d1fc6f Increase timeout when cleaning up test REPLs 2019-04-11 20:13:44 -05:00
Nathaniel Nicandro
b2294dceb2 Generalize communication with a kernel
The previous mechanism to communicate with a kernel was too low level from the
perspective of a client. The client interfaced directly with the subprocess
abstraction, `jupyter-ioloop`, and had to handle all "events" that occurred in
the `jupyter-ioloop`, e.g. when a channel was started or stopped. But in
reality such events should not be the concern of a client.

A client should only care about events that are directly related to kernel
messages and not events related to the implementation details of *how*
communication occurs.

This commit abstracts out the way in which a client communicates with its
kernel by introducing a new `jupyter-comm-layer` class. The
`jupyter-comm-layer` class takes care of managing the communication channel
between a kernel and its clients as well as sending events to all registered
clients. This way, clients operate solely at the level of events on the
communication layer. All a client does is register itself to receive events on
the communication layer and send events on the layer.

* jupyter-base.el (jupyter-session-endpoints): New function.

* jupyter-client.el (jupyter-kernel-client): Remove ioloop and channels slots.
  Add kcomm slot.
(initialize-instance): Unconditionally stop channels.
(jupyter-initialize-connection): Change into a method call.
Call `jupyter-initialize-connection` on the `kcomm` slot.
(jupyter-with-client-buffer): Remove stale comment.
(jupyter-send): Call `jupyter-send` on the `kcomm` slot.
(jupyter-ioloop-handler): Remove all method definitions, replace `sent` and
`message` methods with their `jupyter-event-handler` equivalents.
(jupyter-hb-pause, jupyter-hb-unpause, jupyter-hb-beating):
(jupyter-channel-alive-p, jupyter-start-channel, jupyter-stop-channel):
(jupyter-start-channels, jupyter-stop-channels):
Replace with calls to their equivalents using the `kcomm` slot.

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

* jupyter-kernel-manager (jupyter-make-client): Set a client's `kcomm` slot to
  `jupyter-channel-ioloop-comm`.

* jupyter-messages.el (jupyter-decode-message): Use `list` directly. There
  seemed to be issues when using the new `jupyter-sync-channel-comm` due to
  using quoted lists.

* test/jupyter-test.el: Add `jupyter-comm-layer` test. Update other tests.

* test/test-helper.el: Add `jupyter-comm-layer` mock objects. Update
  `jupyter-echo-client`.
2019-04-11 20:13:44 -05:00
Nathaniel Nicandro
82ec2fb786 Handle all valid arguments in client propagating advise
Fixes #76.
2019-04-01 21:45:00 -05:00
Nathaniel Nicandro
460eba73ec
Update tests to consider changes in message handling 2019-03-29 12:57:54 -05:00
Nathaniel Nicandro
2c005cab7b
jupyter-org-insert-src-block: Find the closest language to use
If `point' is not on a source block, look near `point' for a source block with
a Jupyter language and use that one.

Closes #66.
2019-03-29 00:37:38 -05:00
Nathaniel Nicandro
580776bf58 Add org-babel-jupyter-src-block-session 2019-03-28 23:29:02 -05:00
Nathaniel Nicandro
7ea17ae492
Refactor heartbeat channel
Mainly variable re-naming and in preparation for adding in auto-restart
support.

* `jupyter-hb-consider-dead-periods` -> `jupyter-hb-max-failures`

  * Also convert to a customizable variable

* `kernel-died-cb` -> `dead-cb`
2019-03-22 20:10:22 -05:00
Nathaniel Nicandro
3f3db53527 Handle ANSI escape sequences in org-mode src-block results 2019-03-20 21:08:53 -05:00
Nathaniel Nicandro
08d974f4db jupyter-requests-pending-p: Fix issues and add test
* Use `hash-table-count`

* Fix the check on determining how many pending requests there are
2019-03-17 02:00:00 -05:00
Nathaniel Nicandro
3f55bb0def jupyter-test-with-kernel-client: Consider a shutdown kernel 2019-03-17 01:59:00 -05:00
Nathaniel Nicandro
83af335166
Bump version 2019-03-14 09:29:11 -05:00
Nathaniel Nicandro
662e983612
Don't require subr-x at runtime 2019-03-14 09:16:44 -05:00
Nathaniel Nicandro
581aab10b6
jupyter-kernel-language: Change return value to be a symbol
This avoids interning a string for every method dispatch using the
jupyter-lang method specializer.
2019-03-07 22:51:25 -06:00
Nathaniel Nicandro
8321f9c301
Preserve whitespace when wrapping result in a drawer 2019-03-03 17:55:23 -06:00
Nathaniel Nicandro
e785b97963
Consider whitespace around org-mode src-block results in tests 2019-03-03 17:12:08 -06:00
Nathaniel Nicandro
e1f5b53fbb
Don't rely on "status: starting" message in kernel restart test 2019-03-02 19:26:32 -06:00
Nathaniel Nicandro
e127e1d45b
Add jupyter-repl-cell-cond 2019-03-02 18:14:49 -06:00
Nathaniel Nicandro
1f5c7743d5
Working towards a cleaner REPL restart
See #50.
2019-03-02 18:14:49 -06:00
Nathaniel Nicandro
2a3b175f26
jupyter-repl-after-change: Maintain field membership at cell beginning
This handles an edge case where `field-end` would return the position at the
beginning of a cell even though there was text that was part of the cell code
after that position. The issue had to do with the interaction between the
sticky text properties at field boundaries. See #38.
2019-02-27 14:44:23 -06:00
Nathaniel Nicandro
ae5ed507fb
Handle prompt margin overflow in the REPL
Whenever a prompt string exceeds `jupyter-repl-prompt-margin-width`, increase
`jupyter-repl-prompt-margin-width` so that is can accommodate the string and
redisplay all prompts.
2019-02-22 20:57:42 -06:00
Nathaniel Nicandro
e0a3e09a45 Add test for :display header argument in src-blocks 2019-02-22 08:32:00 -06:00
Nathaniel Nicandro
b8067e70c8 Fix order of print format arguments 2019-02-22 08:30:00 -06:00
Nathaniel Nicandro
f7df9cb9cf Allow table results to be suppressed by ":results scalar" 2019-02-22 08:29:00 -06:00
UndeadKernel
92d1d661c9 feature: Specify mime precedence using ":display" in org source blocks (#17)
A BEGIN_SRC block can specify which mime type to display by enabling the
user to manually set the priority order of mime types.

e.g.: In the following, :text/plain will be used before considering :text/html
#+BEGIN_SRC jupyter-python :display plain html
2019-02-22 07:56:22 -06:00
Nathaniel Nicandro
9484735c06
Fix undo in the REPL
When inserting continuation prompts, extra text deletion entries where being
added in `buffer-undo-list` which caused yanked text to not be undone fully
since it would add in those entries before undoing the yank.
2019-02-21 23:21:22 -06:00
Nathaniel Nicandro
d927d3d58d
Test against the newest version of org-mode 2019-02-21 17:14:59 -06:00
Nathaniel Nicandro
70f4b1b9a3
jupyter-org--append-stream-result: Consider org-edit-src-content-indentation 2019-02-21 17:14:59 -06:00
Nathaniel Nicandro
7d72673604
Account for changes in org-mode 9.2
See #36. There were some assumptions being made on how `org-mode` interpreted
`fixed-width` elements which were changes in `org-mode` 9.2.
2019-02-21 17:14:59 -06:00
Nathaniel Nicandro
1a184403a4
Update test 2019-02-17 23:41:01 -06:00
Nathaniel Nicandro
7122b239e0
Move org-mode test setup functions to test/test-helper.el 2019-02-16 15:30:05 -06:00
Nathaniel Nicandro
57eeb3dd52
Add tests for jupyter-with-display-buffer 2019-02-16 11:27:44 -06:00
Nathaniel Nicandro
1109681475 Add tests for jupyter-repl-syntax-propertize-function 2019-02-14 23:06:00 -06:00
Nathaniel Nicandro
75f9df7d0a
jupyter-repl-history-add-input -> jupyter-repl-history-add 2019-02-14 16:42:12 -06:00
Nathaniel Nicandro
143eacc6fc
jupyter-repl-finalize-cell: Go to point-max first
The "current input cell" is intended to be the last cell in the REPL buffer so
go to `point-max` before calling `jupyter-repl-cell-beginning-position`.
2019-02-14 16:42:12 -06:00
Nathaniel Nicandro
4978c28add
Revert jupy- prefix to jupyter- for org-mode src-blocks
Closes #5.
2019-02-12 09:17:06 -06:00
Nathaniel Nicandro
ee62fafdf6
Fix #14: Undo rear-nonsticky property inserted by insert-for-yank 2019-01-25 23:59:51 -06:00
Nathaniel Nicandro
9ef7553b8a
Handle field property specially when yanking in the REPL 2019-01-23 19:45:41 -06:00
Nathaniel Nicandro
dbaf9a5524
jupyter- -> jupyter-test- for test related macros 2019-01-23 19:41:46 -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
0e6192c86e
Refactor implementation of :dir option in Jupyter src-block's 2019-01-18 23:01:57 -06:00