Hi
Thanks for the feedback. See updated org-matlab.patch. Note code evaluation will now error out when using an out-of-date matlab-mode (rather than generating a warning) because when using an older matlab-mode, code block evaluation doesn't work. We need to wait for the matlab-shell to be ready. Without that capability found in newer matlab-mode, the errors are very hard to understand. I also added tests. Using steps outlined in the ob-matlab-test.el comment to setup for MATLAB testing, I get on Linux:
matlab-mode, version 6.3
Detected MATLAB R2024b (24.2) -- Loading history file
matlab-shell: starting server with name server-2055614
passed 127/1250 ob-matlab/results-file-graphics (9.712776 sec)
passed 128/1250 ob-matlab/results-file-graphics-with-space (0.332004 sec)
passed 129/1250 ob-matlab/results-output (0.013681 sec)
passed 130/1250 ob-matlab/results-output-latex (0.459980 sec)
passed 131/1250 ob-matlab/results-output-preserve-whitespace (0.281001 sec)
passed 132/1250 ob-matlab/results-output-reuse-a (0.039130 sec)
passed 133/1250 ob-matlab/results-output-reuse-b (0.043762 sec)
passed 134/1250 ob-matlab/results-output-reuse-clear (0.301597 sec)
passed 135/1250 ob-matlab/results-verbatim (0.172567 sec)
You mentioned that we should expect org users to understand sessions, however the doc on sessions is a bit light. Searching
https://orgmode.org/org.html for "session", we see it used two different ways "Emacs session" and babel code block evaluations sessions described in "Using sessions". What is there is okay, but doesn't really help one understand when they should/shouldn't use babel code block evaluation sessions. What would be nice is if "Using sessions" were titled "Babel code block evaluation sessions" containing the existing content minus the "Only languages that provide interactive evaluation ..." paragraph because this is vague. In addition, each language should have a way of describing what :session means to them, perhaps by extracting this info from ob-LANGUAGE.el or maybe ob-LANGUAGE.org, or maybe something else that inserts the language specific into the org manual.
With good MATLAB integration in org-mode, we'll see scientists and engineers who have limited programming background leverage org-mode for their scientific papers. Not having to worry about more advanced concepts like sessions is nice, so thanks for letting us default the :session for MATLAB to make it work as one would expect.
Here's the commit info:
ob-matlab.el: improve MATLAB support
* lisp/ob-matlab.el (header): Update URL for MATLAB
* lisp/ob-octave.el (org-babel-octave-evaluate): Fixed MATLAB support
- Deprecate variables related to MATLAB Emacs Link and removed the code.
Emacs Link capability was removed from MATLAB release R2009a, 15 years ago.
- Fixed the following type of org block evaluation:
1) #+begin_src matlab :results verbatim
2) #+begin_src matlab :results output
3) #+begin_src matlab :results output latex
4) #+begin_src matlab :results file graphics
which aid in writing scientific papers.
- Minor point, the correct spelling of MATLAB when referencing the product is
all upper case.
* lisp/ob-comint.el: enhanced org-babel-comint-with-output
- The META argument of org-babel-comint-with-output now supports an optional
STRIP-REGEXPS which can be used to remove content from the returned output.
* lisp/org.el
- Add MATLAB as one of the options for org-babel-load-languages
* mk/default.mk
- Add support for testing matlab code blocks.
* testing/examples/ob-matlab-test.org, testing/lisp/test-ob-matlab.el
- Test for matlab code block.
* testing/org-test.el
- Added org-test-get-code-block which is for use by testing/lisp/test*.el files
to extract code blocks from testing/examples/*.org files for on-the-fly
testing using org-test-with-temp-text.
* etc/ORG-NEWS (New functions and changes in function arguments):
Added entry "ob-octave: improved MATLAB support"
Thanks
John