Adds `jupyter-repl--syntax-propertize` which generalizes the old
`syntax-propertize-function` to handle regions containing both cell code and
cell output.
In particular, file link objects. When an object (in the sense of the
`org-element` API) is inserted by `org-element-interpret-data` it does not
insert a newline since objects are entities that can appear inline with a
paragraph. But for our purposes, we need the newline.
Previously we handled this by wrapping `result` in a list with a newline as the
second element before calling `org-element-interpret-data`, but this interfered
with what `jupyter-org-babel-result-p` (called by
`jupyter-org--wrap-result-maybe`) expected as its argument. With this commit,
the result is never wrapped in a list.
In Emacs, the end position of a region is exclusive. So functions like
`delete-region` will delete the entire region specified excluding the end
position. Follow this convention with the cell code position.
This fixes issues when adding syntax properties to a cell's code. See
`jupyter-repl-initialize-fontification`.
Better support for completions in the Jupyter org-mode source blocks
A line context is often insufficient. For example, the Julia kernel will parse
up to the current point and return dictionary keys as completions or method
arguments. Similarly a Python kernel may use Jedi for completion which does
static analysis of the code block to resolve import paths for completion
results.
Change the behavior of `jupyter-org-sync-results` to return the org formatted
result string and modify the result parameters in `org-babel-execute:jupyter`
to add the "raw" result parameter so that the result string is directly
inserted into the buffer.
This is to work towards better support for in-lined code blocks.
This ensures that org-element objects are always returned by the functions like
`jupyter-org-file-link`. Previously functions that returned org objects would
return the object wrapped in a list.
Previously stream results would be placed directly inside the RESULTS drawer.
The issue with this is that sometimes the stream results can be represented as
org syntax.
Instead of inserting stream results directly into a RESULTS drawer, insert them
as either fixed-width or example-block org elements depending on
`org-babel-min-lines-for-block-output`. In addition, coalesce all stream
results so that multiple stream messages in succession produces only one
fixed-width or example-block element.
This may still not be the best place to put buffer modifications, but it
"spreads out the logic" a little more and simplifies
`jupyter-org--append-result`.