emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org-babel Matlab (session) output is malformed
@ 2020-04-10  5:48 Karthik Chikmagalur
  2020-09-04 15:39 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Karthik Chikmagalur @ 2020-04-10  5:48 UTC (permalink / raw)
  To: emacs-orgmode

I'm trying to evaluate some Matlab code using org-babel in a session:

#+BEGIN_SRC matlab :session :results output
a = 4;
b = a + 3
c = a - 3
#+END_SRC

And following the org-babel documentation, (something like) this is the output I expect:

#+RESULTS:
#+begin_example
b =

     7

c =

     1
#+end_example

But this is the output I get:

#+RESULTS:
#+begin_example
a = 4;
b = a + 3

b =

     7
c = a - 3

c =

     1
'org_babel_eoe'

ans =

    'org_babel_eoe'
#+end_example

(Including the =#+begin_example= etc)

After going through the source of the function =org-babel= calls, here is what's supposed to happen:

1. =org-babel-octave-evaluate-session= copies the code into the Matlab REPL (calling =matlab-shell= if necessary) and the shell runs it.
2. It then copies the result back as a string up to the end-of-evaluation token, and then removes the original code from the output string.

it looks like =org-babel-octave-evaluate-session= is not reading the end-of-evaluation token (='org_babel_eoe'=) correctly, and not removing the input code from the resulting string either. This looks like it should be an easy fix, but I couldn't figure it out.

Any ideas how to fix this?

Notes:

1. The relevant function(s) are in =/usr/share/emacs/27.0.90/lisp/org/ob-octave.el= or equivalent location. I am using Emacs 27.0.90.

2. The same org-babel module pulls double duty for Octave and Matlab with a flag to distinguish between uses, hence the name. When I run the same test as an Octave source block it runs correctly:
   
#+BEGIN_SRC octave :session :results output
a = 4;
b = a + 3
c = a - 3
#+END_SRC

#+RESULTS:
: 
: b =  7
: c =  1

3. This issue regards evaluation of source blocks with the =:results output= option, where org-babel includes in the results block everything that the REPL prints to stdout. (This is different from the default =:results value= option where only the return value of the block is considered as a result.)


- Karthik


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Org-babel Matlab (session) output is malformed
  2020-04-10  5:48 Org-babel Matlab (session) output is malformed Karthik Chikmagalur
@ 2020-09-04 15:39 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2020-09-04 15:39 UTC (permalink / raw)
  To: Karthik Chikmagalur; +Cc: emacs-orgmode

Hi Karthik Chikmagalur,

sorry I cannot help on this issue.  I hope someone can help
maintaining ob-octave.el (perhaps you?) and replying such issues.

All best,

-- 
 Bastien


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-04 15:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-10  5:48 Org-babel Matlab (session) output is malformed Karthik Chikmagalur
2020-09-04 15:39 ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).