Fixes#4. `shr` uses `libxml-parse-html-region` internally which converts all
tags and attributes to lowercase when constructing the DOM since HTML is
case-insensitive. But SVG uses XML which is a case-sensitive language. This
means that a conversion from the DOM back to an XML representation does not
restore the case of tags/attributes if `libxml-parse-html-region` is used. This
is solved by using `libxml-parse-xml-region` which preserves case.
* jupyter-repl.el (jupyter-repl-put-image): New function.
(jupyter-repl-insert-html): Temporarily bind libxml-parse-html-region to
libxml-parse-xml-region. Temporarily bind shr-put-image-function to
jupyter-repl-put-image.
* If `comment-start` is nil, using a regular expression with an empty or clause
causes an infinite loop. Ensure that we only add the or clause when
`comment-start` is non-nil in `jupyter-repl-propertize-output`.
* Copy over the `comment-start` from the REPL language buffer in
`jupyter-repl-initialize-fontification`
* 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
* 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.
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.
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.
* 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.
* 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
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.
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.
* 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.
* 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`
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.
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.