[ESS] executing Julia from org: error in ess-eval-region
Stephen Eglen
@je30 @end|ng |rom c@m@@c@uk
Mon Aug 15 14:21:01 CEST 2022
couple of other quick points:
1. The *julia* repl gets poluted with these 'eoe' end-of-expression markers
which may be necessary, but feel clunky.
julia> print("org_babel_julia_eoe")
org_babel_julia_eoe
2. this is using *ESS* machinery to evaluate julia. I'm not yet
proficient enough in Julia, but feel that it might be time that a few of
us get together to think about which is the most suitable emacs
interface for a REPL in julia. I'm not convinced it is ESS, given how
much can be done in a regular julia repl that our comint interface
cannot cope with. there are a few others around that are based on
ansi-term or vterm that might be more appropriate.
e.g.
https://github.com/shg/julia-vterm.el
which also has this for org-babel
https://github.com/shg/ob-julia-vterm.el
as well as
https://github.com/tpapp/julia-repl
Stephen
On Mon, Aug 15 2022, Stephen Eglen wrote:
> ok... some progress...
>
> a workaround is that you will need to use the following in your
> .emacs -- it is simply the version from ob-julia.el with one linne added
> (search for SJE). I do not know why this alist is needed, but with
> this, I can confirm that :session now works.
>
> Can you please check?
>
> I did however need to add two Julia Packages, DataFrames and CSV, before
> it would work. This could be better documented as it was not obvious in
> the debugger.
>
> Stephen
>
>
> (defun org-babel-julia-evaluate-session
> (session body result-type result-params column-names-p)
> "Evaluate BODY in SESSION.
> If RESULT-TYPE equals `output' then return standard output as a
> string. If RESULT-TYPE equals `value' then return the value of the
> last statement in BODY, as elisp."
> (cl-case result-type
> (value
> (with-temp-buffer
> (setq ess-local-customize-alist t) ;; SJE --- addition here.
> (insert (org-babel-chomp body))
> (let ((ess-local-process-name
> (process-name (get-buffer-process session)))
> (ess-eval-visibly-p nil))
> (ess-eval-buffer nil)))
> (let ((tmp-file (org-babel-temp-file "julia-")))
> (org-babel-comint-eval-invisibly-and-wait-for-file
> session tmp-file
> (format org-babel-julia-write-object-command
> "ans"
> (org-babel-process-file-name tmp-file 'noquote)
> (if column-names-p "true" "false")
> ))
> (org-babel-julia-process-value-result
> (org-babel-result-cond result-params
> (with-temp-buffer
> (insert-file-contents tmp-file)
> (buffer-string))
> (org-babel-import-elisp-from-file tmp-file '(4)))
> column-names-p)))
> (output
> (mapconcat
> #'org-babel-chomp
> (butlast
> (delq nil
> (mapcar
> (lambda (line) (when (> (length line) 0) line))
> (mapcar
> (lambda (line) ;; cleanup extra prompts left in output
> (if (string-match
> "^\\([>+.]\\([ ][>.+]\\)*[ ]\\)"
> (car (split-string line "\n")))
> (substring line (match-end 1))
> line))
> (org-babel-comint-with-output (session org-babel-julia-eoe-output)
> (insert (mapconcat #'org-babel-chomp
> (list body org-babel-julia-eoe-indicator)
> "\n"))
> (inferior-ess-send-input))))))
> "\n"))))
>
>
> On Mon, Aug 15 2022, Stephen Eglen wrote:
>
>> ok, thanks.
>>
>> In the meantime, I can now replicate your error. I'll see what I can
>> debug.
>>
>>
>> On Mon, Aug 15 2022, Fraga, Eric wrote:
>>
>>> On Monday, 15 Aug 2022 at 12:20, Stephen Eglen wrote:
>>>> thanks. Do you know why 'results output' is needed for Julia chunks,
>>>> but not R?
>>>
>>> The implementation of ob-julia distributed with org, unfortunately, is
>>> not complete. There is a work-in-progress version [1] that promises to
>>> fix a few things but it's not quite ready to replace the current
>>> version, I believe.
>>>
>>> eric
>>>
>>> Footnotes:
>>> [1] https://github.com/nico202/ob-julia
More information about the ESS-help
mailing list