Commit graph

204 commits

Author SHA1 Message Date
Nathaniel Nicandro
d86eea253b jupyter-handle-status: Force a mode line update after changing status 2018-11-04 23:56:42 -06:00
Nathaniel Nicandro
bd2333a432 Only consider the REPL buffer modified when editing an input cell 2018-11-04 23:56:42 -06:00
Nathaniel Nicandro
983ccf6ec7 Add jupyter-with-control-code-handling
This macro takes care of any ANSI control codes that the kernel output may
produce.
2018-11-04 23:56:42 -06:00
Nathaniel Nicandro
6c6712bb0a jupyter-with-output-buffer: Refactor
* Rename `jupyter-repl-output-buffer-marker` to `jupyter-output-buffer-marker`

* Rename `jupyter-repl-output-buffer-last-request-id` to
  `jupyter-output-buffer-request-id`

* Add `jupyter--reset-output-buffer-p` which returns non-nil if the current
  input buffer should be reset.

* Simplify the `jupyter-with-output-buffer` macro
2018-11-04 23:56:42 -06:00
Nathaniel Nicandro
4cfa8b19fc jupyter-repl-eval-string: Simplify conditional 2018-11-04 23:56:42 -06:00
Nathaniel Nicandro
28d4390a1f jupyter-repl-eval-string: Use jupyter-with-message-content 2018-11-04 17:05:44 -06:00
Nathaniel Nicandro
4f40b050df Simplify working with buffers to insert kernel output
* Rename `jupyter-repl-with-output-buffer` to `jupyter-with-output-buffer`.

* Replace uses of `jupyter-repl-with-doc-buffer` with
  `jupyter-with-output-buffer`. The difference between the two was that
  `jupyter-repl-with-doc-buffer` always reset the buffer before inserting new
  output.
2018-11-04 17:05:44 -06:00
Nathaniel Nicandro
55b5f680ec Enable undo in a REPL input cell 2018-11-02 09:14:29 -05:00
Nathaniel Nicandro
b4cdf9de0b jupyter-repl-propertize-output: Also suppress fontification of comments 2018-11-02 09:10:17 -05:00
Nathaniel Nicandro
58e1515e75 Fix beginning-of-buffer error 2018-11-01 21:12:59 -05:00
Nathaniel Nicandro
4f78ef34a2 Add jupyter-repl-insert-message
This function is essentially the same as `jupyter-repl-insert-data` but also
allows different kernel languages to do post-processing to the inserted data.

This is done by defining a new method, `jupyter-repl-after-insert-message`
which is called with the buffer narrowed to the inserted data.

One of its uses is to fontify documentation strings of Python kernels when
making inspect requests.
2018-10-31 18:49:37 -05:00
Nathaniel Nicandro
01be7be844 jupyter-inspect: Ensure the right client is used for `help-setup-xref' 2018-10-31 18:49:37 -05:00
Nathaniel Nicandro
589bfecdb0 jupyter-handle-display-data: Only inhibit redisplay if debug-on-error is nil 2018-10-27 22:16:54 -05:00
Nathaniel Nicandro
b1bbfd0e1a Move python specific traceback handling to jupyter-python.el 2018-10-27 22:16:54 -05:00
Nathaniel Nicandro
cc95092797 jupyter-handle-status: Don't error if a REPL cell is not found
This change is required because when evaluating code in other contexts than the
REPL, the convention is to set `jupyter-inhibit-handlers` to `(not :status)` so
that the `execution-state` can be updated for the mode-line construct.
2018-10-27 22:16:54 -05:00
Nathaniel Nicandro
23caa99670 jupyter-repl-insert-data: Remove code duplication when inserting images 2018-10-27 22:16:54 -05:00
Nathaniel Nicandro
890f5ab3cb Silence byte compiler
* Declare undeclared external functions

* Add ext: prefix to filename of external packages that may not be present on
  every system

* Remove `company-grab-symbol-cons` function declaration since this function is
  no longer used.
2018-10-27 22:16:54 -05:00
Nathaniel Nicandro
2f2ac53851 jupyter-repl-after-change: Mention that cl-call-next-method needs to be called 2018-10-27 22:16:54 -05:00
Nathaniel Nicandro
77aad6630c jupyter-repl-initialize-fontification: Fix string syntax in output
* Previously any odd number of quote characters in the output of a cell messes
  up fontification of the next input cell since it will consider the input as
  part of a string. I had mistakenly thought that changing the syntax of the
  quote characters when inserting cell output fixed the problem but did not
  realize that as a part of fontification, the region being fontified is
  unfontified first by `font-lock-unfontify-region` whose default
  `font-lock-default-unfontify-region` removes the `syntax-table` property if
  `font-lock-syntactic-keywords` is non-nil for a major mode which means the
  `syntax-table` property that we add in the cell output gets removed.

  * The solution is to add our own `syntax-propertize-function` which calls
    `jupyter-repl-propertize-output` when attempting to fontify a region that
    is not cell code and calls the REPL languages `syntax-propertize-function`
    if available.

* In `jupyter-repl-propertize-output`, also change the syntax of ' characters
2018-10-27 22:15:49 -05:00
Nathaniel Nicandro
a3f4cf5d70 jupyter-repl-with-output-buffer: Fix misspelled documentation 2018-10-25 23:59:47 -05:00
Nathaniel Nicandro
2f3f910598 Replace deprecated destructor method with jupyter-finalizer 2018-10-25 23:59:47 -05:00
Nathaniel Nicandro
a5a20cad04 Unmark REPL cell as busy in jupyter-handle-status
Since evaluation functions like `jupyter-repl-eval-string` inhibit handlers
except the status handler it makes more sense to do this in the status handler
as well.
2018-10-25 23:59:47 -05:00
Nathaniel Nicandro
795c9b2542 Add jupyter-load-file-code 2018-10-25 23:59:47 -05:00
Nathaniel Nicandro
7efea4d582 Add note about moving output insertion and inspection functions to jupyter-client.el 2018-10-25 23:59:47 -05:00
Nathaniel Nicandro
4949e7f3bc jupyter-repl-markdown-mouse-map: Add documentation 2018-10-25 23:59:47 -05:00
Nathaniel Nicandro
60eed5b773 jupyter-repl-eval-string: Better condition for when to show the traceback buffer 2018-10-25 23:59:46 -05:00
Nathaniel Nicandro
50d1f395f6 jupyter-completion--arg-extract-1: Fix documentation 2018-10-25 23:59:46 -05:00
Nathaniel Nicandro
e243b9f496 jupyter-repl-after-init: Fix documentation 2018-10-25 23:59:46 -05:00
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