Commit graph

351 commits

Author SHA1 Message Date
Nathaniel Nicandro
2ae8c6a7c1 Associate pending requests with a client
Previously pending requests were associated with the ioloop process itself, but
pending requests are a particular feature of the client and used only for a
client's purpose.
2018-11-08 21:21:23 -06:00
Nathaniel Nicandro
22796ad4cd jupyter-client.el: Add jupyter-clients
* jupyter-client.el: Add the function

* jupyter-repl.el (jupyter-repl-available-repl-buffers): Use it. Ensure REPL
buffers are still live.
2018-11-08 21:15:22 -06:00
Nathaniel Nicandro
0a1ffa66a0 jupyter--ioloop: Complain if ZMQ does not have draft API 2018-11-05 00:00:11 -06:00
Nathaniel Nicandro
05bbe0414d Rename jupyter-startup-timeout to jupyter-long-timeout 2018-11-05 00:00:08 -06:00
Nathaniel Nicandro
57f262c2e3 Implement option to show a progress reporting message in jupyter-wait-until* functions 2018-11-01 19:20:25 -05:00
Nathaniel Nicandro
2f3f910598 Replace deprecated destructor method with jupyter-finalizer 2018-10-25 23:59:47 -05:00
Nathaniel Nicandro
4c710ed235 jupyter-load-language-support: Fix assertion 2018-10-25 23:59:47 -05:00
Nathaniel Nicandro
8896e88476 Move language support definitions to their own files
* Define `jupyter-load-language-support` which takes a client and loads the
  language support definitions of the client's kernel language.

* Call `jupyter-load-language-support` when initializing a REPL buffer in
  `jupyter-repl-mode`. Note this also takes care of loading the kernel support
  for a `jupyter-org-client' since a REPL buffer is setup before evaluating any
  `org-mode` source code blocks.

* Move language specific methods to their own files named `jupyter-LANGUAGE.el`
2018-10-25 23:59:46 -05:00
Nathaniel Nicandro
ecd6a3098b Move jupyter-eval from jupyter-repl.el to jupyter-client.el 2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
67a3f997bd Allow jupyter-inhibit-handlers to be inverted
That is, give a way to only run handlers for the message types in the list
instead of inhibiting them.
2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
842c920760 Be more robust when checking the jupyter-lang method specializer 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
56477b2eae jupyter-client.el: Add jupyter-startup-timeout 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
288fb17ece Update comments 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
673747dc03 Add kill-emacs-hook functions for cleaning up clients and managers
If `kill-emacs` is called while the kernel process or client channel processes
are still alive, the process sentinels do not run and thus the cleanup of the
clients and managers does not happen. Thus we need to explicitly do this
cleanup when `kill-emacs` is called.
2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
c3690eb2ea Use accept-process-output 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
a7023078cc jupyter-code-context: Update documentation 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
7d824f4915 Add new :input-request message type
This replaces the behavior of the `:input-reply` message
type. A kernel sends an `:input-request` to the frontend
and the client sends an `:input-reply`.
2018-10-25 23:17:26 -05:00
Nathaniel Nicandro
84fce2cd08 Silence byte compiler about undefined variables 2018-10-25 23:17:26 -05:00
Nathaniel Nicandro
2841753bad Consider the active region when obtaining the jupyter-code-context 2018-10-25 23:17:26 -05:00
Nathaniel Nicandro
6ab44867d1 Fix code position in jupyter-line-context
The cursor position is 1 relative, I think. At least this
gives the right results using the Julia kernel.
2018-10-25 23:17:26 -05:00
Nathaniel Nicandro
5f091d972a Remove unused dependency 2018-10-25 23:17:26 -05:00
Nathaniel Nicandro
39382227e7 Take into account newer versions of zmq 2018-10-25 23:17:25 -05:00
Nathaniel Nicandro
a9246fcecb Rename with-jupyter-* to jupyter-with
Ensure that all functions and macros have the same
pseudo-namespace
2018-10-25 23:17:25 -05:00
Nathaniel Nicandro
34e52de1d4 Simplify inspect requests
* Rename `jupyter-repl-inspect-at-point` -> `jupyter-inspect-at-point`

* Refactor inspection
2018-10-25 23:17:25 -05:00
Nathaniel Nicandro
1198965d57 Documentation changes 2018-10-25 23:17:25 -05:00
Nathaniel Nicandro
ac812a8599 Add a custom method generalizer for a kernel language 2018-10-25 23:17:25 -05:00
Nathaniel Nicandro
14ef40acd4 Reduce priority of jupyter-land method context 2018-10-25 23:17:25 -05:00
Nathaniel Nicandro
19abd9a5c6 Define and use the jupyter-lang method context specializer
* Define the `jupyter-lang` method context specializer that
  specializes against the kernel language of
  `jupyter-current-client`

* Remove the kernel support API

* Replace the kernel support API with methods that can be
  specialized using the `jupyter-lang` context specializer.
2018-10-25 23:17:09 -05:00
Nathaniel Nicandro
2492ce3143 Use buffer-substring-no-properties to avoid copying properties 2018-10-25 23:07:46 -05:00
Nathaniel Nicandro
a8231db79b Rename jupyter-repl-current-client to jupyter-current-client
Also move `jupyter-current-client` to `jupyter-client.el`
2018-10-25 23:07:46 -05:00
Nathaniel Nicandro
8bb43e6c68 Rename jupyter-repl-language to jupyter-kernel-language
Also move `jupyter-kernel-language` to `jupyter-client.el`
2018-10-25 23:07:46 -05:00
Nathaniel Nicandro
34aaaf2a66 Update documentation of jupyter-start-channels 2018-10-25 22:57:33 -05:00
Nathaniel Nicandro
44d1af31bb Generalize retrieving the code context
* Rename `jupyter-code-context-at-point` to `jupyter-code-context`

* Use `cl-defmethod` and specializers to handle the
  different kinds of contexts

* Move the newly defined code context methods to their
  appropriate locations
2018-10-25 22:57:33 -05:00
Nathaniel Nicandro
883197074e Move the kernel-info slot of jupyter-repl-client' to jupyter-kernel-client'
* Define new method `jupyter-kernel-info` which takes care
  of caching the result of a kernel info request. All
  access of the kernel info plist should happen through
  this method.

* Do not return the kernel info plist in
  `jupyter-start-new-kernel`, callers should access the
  kernel info through `jupyter-kernel-info`
2018-10-25 22:57:33 -05:00
Nathaniel Nicandro
c070f2d04d Update documentation and comments 2018-10-25 22:57:23 -05:00
Nathaniel Nicandro
b706e63d97 Minimize use of cl functions 2018-10-25 22:57:23 -05:00
Nathaniel Nicandro
6a60250940 Add lock file mechanism to cleanup channel subprocess on Emacs crash
If Emacs crashes while a channel subprocess is still alive, the subprocess is
not cleaned up properly. Fix this by creating a file lock in the parent Emacs
process, then ensure that the file lock exists in the channel subprocess. If it
doesn't exist anymore, the channel subprocess will exit.
2018-10-25 22:57:23 -05:00
Nathaniel Nicandro
9c664b4c36 Abstract out the operations in jupyter--ioloop 2018-10-25 22:57:23 -05:00
Nathaniel Nicandro
250af96ea2 Remove jupyter-request--id, replace with jupyter-request-id
Since IDs of requests are generated in the parent Emacs process, there is no
need to pass back the ID of a request from the child process that send
messages.
2018-10-25 22:57:23 -05:00
Nathaniel Nicandro
a0a9ac2910 Update documentation, purge stale comments 2018-10-16 13:55:50 -05:00
Nathaniel Nicandro
de9f85cc2e Update documentation, cleanup comments
* Remove implementation details in documentation strings

* Canonicalize documentation of functions which perform similar operations.
2018-10-16 13:55:30 -05:00
Nathaniel Nicandro
c3681bdb8c Add methods to hook into request creation/deletion
- Add the method `jupyter-generate-request` to allow subclasses to initialize
  their own request objects with extra fields in addition to those of
  `jupyter-request`.

- Add the method `jupyter-drop-request` to allow subclasses to do any cleanup
  once a request is complete.
2018-10-16 13:55:30 -05:00
Nathaniel Nicandro
aab35e6eed Include missing status field in execute-reply handler 2018-10-16 13:55:30 -05:00
Nathaniel Nicandro
22b1e809a0 Update documentation, cleanup comments 2018-08-30 18:02:13 -05:00
Nathaniel Nicandro
3c34c1f7ed Do not handle reply messages with an error status specially 2018-05-30 12:49:28 -05:00
Nathaniel Nicandro
ff54004129 Do not rely on message time when dropping requests 2018-05-30 12:49:28 -05:00
Nathaniel Nicandro
e654487b2a Allow the possibility of preempting the handler methods using message hooks 2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
436089d08b Prefer defun over defsubst and other miscellaneous changes
- Add missing namespace to sha256 function

  - Any function defined should have a `jupyter-` prefix

- Remove `cl-lib` dependency in `jupyter-messages.el`

- Include `subr-x` in `jupyter-base.el`

- Use `tramp-file-name-user` instead of `tramp-file-name-real-user` since the
  latter is missing in Emacs 26
2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
f315a4bab0 Store open comm state in a jupyter-kernel-client 2018-05-28 01:25:33 -05:00
Nathaniel Nicandro
554e519bf0 Avoid delays during message processing
- Allow specifying a msg-id before a call to `jupyter-send`

  - This avoid sending a message to the browser displaying the widgets on every
    message send to the kernel. The previous implementation generated a new ID
    without allowing the caller to pass one in.

- Simplify message polling by sending received messages from the kernel to the
  parent Emacs process at the moment of arrival.
2018-05-28 01:25:09 -05:00