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