Remember to cover the basics, that is, what you expected to happen and what in fact did happen. You don't know how to make a good report? See https://orgmode.org/manual/Feedback.html#Feedback Your bug report will be posted to the Org mailing list. ------------------------------------------------------------------------ Org-babel's handling of MATLAB block output with the =:results session= argument is broken. Here is some sample code along with the expected result: #+begin_src matlab :results output :session *MATLAB* a = 3; b = 4; c = a + b #+end_src #+RESULTS: : c = : : 7 However here is the actual result: #+begin_src matlab :results output :session *MATLAB* a = 3; b = 4; c = a + b #+end_src #+RESULTS: #+begin_example a = 3; b = 4; c = a + b c = 7 'org_babel_eoe' ans = 'org_babel_eoe' #+end_example There are two separate problems: 1. The =org-babel-octave-eoe-indicator= is not being stripped. 2. The comint input is being echoed in the output. #1 is easy to fix. The problem is in the function =org-babel-octave-evaluate-session=, in the line: #+begin_src emacs-lisp (cdr (reverse (delq "" (mapcar #'org-strip-quotes (mapcar #'org-trim raw))))) #+end_src Where empty lines in the output are being removed with =delq=. =delq= compares with =eq= instead of =equal=, which fails on blank lines. Replacing this with =delete= works fine. #2 is a much trickier problem to solve. Here is the body of the input as it appears in the MATLAB session: #+begin_example >> a = 3; b = 4; c = a + b 'org_babel_eoe' a = 3; >> b = 4; >> c = a + b c = 7 >> 'org_babel_eoe' ans = 'org_babel_eoe' >> #+end_example Here `>>' is the shell prompt, which is absent from the raw comint output as given to org by comint-mode. =matlab-shell= does not work like other comint shells in that it doesn't echo bulk (/i.e./ multi-line) input all at once. Instead, it echoes each line of input and follows it with its output. This interspersal of input and output is causing =org-babel-comint-with-output=, the function (actually macro) responsible for removing the comint input echo text from the raw comint output, to fail. This macro assumes that the raw comint output looks like #+begin_example <> <> #+end_example as you can see from this code from =org-babel-comint-with-output=: #+begin_src emacs-lisp (when (and ,remove-echo ,full-body (string-match (replace-regexp-in-string "\n" "[\r\n]+" (regexp-quote (or ,full-body ""))) string-buffer)) (setq string-buffer (substring string-buffer (match-end 0)))) #+end_src To fix this, either =org-babel-octave-evaluate-session= or =org-babel-comint-with-output= needs to be modified. This problem is local to MATLAB, it does not happen with GNU Octave, which shares most of its org-babel code with MATLAB's. So I wrote a patch to the former that does additional line-by-line processing on the raw comint output to detect and remove the echoed input. (Patch is attached.) However while this fixes the problem it's not a robust solution. -Karthik