Commit graph

176 commits

Author SHA1 Message Date
Nathaniel Nicandro
2911ac34bf Add jupyter-repl-propertize-output
Currently this function changes the syntax of " characters in inserted output
so that they do not get recognized for syntactic fontification. Syntactic
fontification should only happen for cell code.
2018-10-25 23:59:46 -05:00
Nathaniel Nicandro
8b75a8b2e2 jupyter-repl-initialize-fontification: Refactor and update
* Move the setting of `parse-sexp-lookup-properties` to
  `jupyter-repl-initialize-fontification` from `jupyter-repl-mode`

* Use the language mode's `syntax-propertize-function`, but only propertize
  regions that contain cell code.
2018-10-25 23:59:46 -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
af6dc4e5f3 jupyter-repl-add-font-lock-properties: Remove improper use of font-lock-multiline 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
ab44407fdf Add jupyter-completion-post-completion method
This way kernel languages can override the default behavior. The default
implementation expands the candidate snippet if one is available.
2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
8ccd41fe89 jupyter-repl-display-kernel-buffer: Guard against a dead kernel 2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
82a7031325 jupyter-repl-append-output: Explicitly disable jit-lock-mode
Sometimes when inserting output in the REPL buffer, JIT font-locking takes
place before we are able to add the text properties preventing it from running
on cell output. This happens, for example, when inserting HTML output in a
Haskell kernel. Since cell output should never be font-locked by the REPL
buffer, explicitly disable it when inserting output.
2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
30608f89a1 jupyter-eval: Reword documentation 2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
95a44ae08b jupyter-repl-propagate-client: Update documentation 2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
ec79fa668a Use the default input-request handler for REPL clients
Previously if the kernel asked for non-password input, the input sent to the
kernel would be echoed to the REPL buffer. This behavior interferes with any
output generated by the kernel in response to the input. For example calling
the license() function in a Python kernel would have the sent input
interspersed with the output generated by the license() function. Instead of
echoing the sent input, don't do anything with it.
2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
509495b7aa jupyter-markdown-follow-link: Handle links to the Julia manual for Julia kernels 2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
5179c4215c jupyter-repl-eval-string: Inhibit all handlers except for the status handler
This allows for the `execution-state` of the REPL to be updated and the
mode-line string of `jupyter-repl-interation-mode` to be properly updated.
2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
1242d05972 Add a better mode-line string for jupyter-repl-interaction-mode 2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
6d4efb9823 jupyter-repl-eval-string: Fix out of place else condition in if 2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
19c8d9c58c Emulate REPL mode prompts for the Julia kernel
If the first character of input cell is one of ']', ';', or '?', the underlying
Julia kernel treats the input specially as a REPL "mode", different from the
regular code input.
2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
1047257269 Add jupyter-eval
A simplified code evaluation function that waits for the result of the executed
code.
2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
a4fab1ff3b Add jupyter-repl-after-change method
* Rename `jupyter-repl-after-buffer-change` to `julia-repl-do-after-change`

* Add the method `jupyter-repl-after-change` which gets called in
  `jupyter-repl-do-after-change` so that kernel languages can modify the input
  cell after buffer changes. The default implementation of the method does the
  work that was previously done in `jupyter-repl-after-buffer-change`
2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
13b92d7d33 Remove jupyter-repl-filter-substring
This was previously used to remove invisible characters from the cell input due
to invisible characters previously added by continuation prompts. These
characters are no longer inserted so there is no need for this function. Also,
there are situations where invisible characters should still be a part of the
cell code, for example when hiding the REPL mode character for the Julia
kernel.
2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
cab40bf692 Change REPL prompt modifications
* Add `jupyter-repl-prompt-string` to get the text of the current REPL prompt

* Allow `jupyter-repl-cell-prompt` to be given a face to use for the prompt
  string

* Only mark and unmark a cell prompt as busy, if the current cell prompt looks
  like it can be marked or unmarked, i.e. is the standard input prompt

These changes are in preparation for emulating REPL modes that some languages
implement such as Julia, which updates the prompt to indicate which mode it is
in.
2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
15268c59ca Ensure that parse-sexp-lookup-properties is non-nil in REPL buffers
This is so that output that inserts string delimiters does not mess up font
lock in the REPL cell code.
2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
60510453b3 Define variables as buffer local instead of using setq-local 2018-10-25 23:17:28 -05:00
Nathaniel Nicandro
66c3fc4eb7 jupyter-repl-ret: Don't block the status handler while waiting for an is-complete-reply 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
5395d4d44a Rename connect-jupyter-repl -> jupyter-connect-repl, run-jupyter-repl -> jupyter-run-repl 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
67e8844e31 jupyter-completion-prefix: Include \ in completion prefix for Julia kernels 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
4c6fee45b9 jupyter-completion-at-point: Check for a non-nil `jupyter-current-client' later
Since, as a hack, the `jupyter-org-client' sets the `jupyter-current-client'
based on the source code block at `point' in its `jupyter-completion-prefix`
function, check for it after calling `jupyter-completion-prefix`.
2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
5a4e50266c Move defvar to top-level 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
43c34ddffc jupyter-handle-input-request: Do not display the prompt and value 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
288fb17ece Update comments 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
0807fd7b83 jupyter-repl-associate-buffer: Fix interactive spec 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
7b68acbe69 Small refactoring to REPL evaluation functions
* Ensure that a REPL result is displayed correctly if it contains format
  specifiers in `jupyter-repl-eval-string`

* Use `jupyter-with-message-data` in `jupyter-repl-eval-line-or-region` and
  ensure that ANSI color codes are not shown when displaying results.

* Add a `C-x C-e` binding to `jupyter-repl-interaction-map`
2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
8247714cb5 jupyter-repl-associate-buffer: Verify the client after ensuring its a client 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
09951544ed jupyter-completion-grab-symbol-cons: Handle edge case 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
c66ff6e943 Enable font-lock-mode in the company-doc-buffer 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
6d48406eb5 jupyter-repl-client: Fix class hierarchy 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
c1248442f6 jupyter-repl-interaction-map: A more convenient jupyter-inspect-at-point binding 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
5505bc2532 Add jupyter-repl-eval-defun 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
4f53240e24 Use the default jupyter-code-context' for jupyter-repl-mode` buffers
Previously an invisible character would be added in the
buffer to prevent the margin from inheriting any text
properties but this is unneeded since the default margin
does not contain any text that can inherit the properties.
2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
c7ec4613be jupyter-repl-insert-banner: Use font-lock-fontified to avoid syntactic fontification 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
799c9ea2aa jupyter-repl-eval-string: Add stream and error handlers 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
3bfa393596 jupyter-repl-eval-string: Allow a custom callback when evaluating results 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
f6698d8bc1 Add convenience macro jupyter-repl-with-output-buffer 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
948fa6adfc Rename jupyter-with-doc-buffer to jupyter-repl-with-doc-buffer
Also rename `jupyter-get-doc-buffer` to `jupyter-repl-get-special-buffer`
2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
e43c6597ad Add convenience macros for working with messages 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
4374d9dd2c jupyter-repl-eval-string: Don't store history when evaluating silently
We still want to display the results so we can't pass the
silent key to the kernel.
2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
56a90717a1 Add jupyter-repl-display-traceback 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
ed8603f845 jupyter-completion-prefix: Remove type specifier
This is not needed and it seems to create issues when the
method is called without arguments.
2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
6dc9f0cc89 run-jupyter-repl, connect-jupyter-repl: Allow specifying a new REPL name with a prefix argument 2018-10-25 23:17:27 -05:00
Nathaniel Nicandro
f0c5f002c4 jupyter-repl-propagate-client: Propagate clients regardless of the current-buffer 2018-10-25 23:17:26 -05:00
Nathaniel Nicandro
4a7e95eb18 jupyter-repl-available-repl-buffers: Refactor
Also give an option to return the first found REPL buffer
that can be used for a major mode.
2018-10-25 23:17:26 -05:00