diff --git a/contrib/babel/lisp/langs/org-babel-matlab.el b/contrib/babel/lisp/langs/org-babel-matlab.el index d40496e9d..4809b56f3 100644 --- a/contrib/babel/lisp/langs/org-babel-matlab.el +++ b/contrib/babel/lisp/langs/org-babel-matlab.el @@ -50,6 +50,11 @@ (defun org-babel-expand-body:matlab (body params &optional processed-params) body) +(defvar org-babel-matlab-with-emacs-link nil + "If non-nil use matlab-shell-run-region for session + evaluation. This will use EmacsLink if (matlab-with-emacs-link) + evaluates to a non-nil value.") + (defun org-babel-execute:matlab (body params) "Execute a block of matlab code with org-babel." (org-babel-execute:octave body params 'matlab)) diff --git a/contrib/babel/lisp/langs/org-babel-octave.el b/contrib/babel/lisp/langs/org-babel-octave.el index 72183a155..9a27d8f31 100644 --- a/contrib/babel/lisp/langs/org-babel-octave.el +++ b/contrib/babel/lisp/langs/org-babel-octave.el @@ -164,9 +164,18 @@ value of the last statement in BODY, as elisp." (mapconcat #'org-babel-chomp (list (format org-babel-octave-wrapper-method body tmp-file tmp-file) org-babel-octave-eoe-indicator) "\n")))) - (raw (org-babel-comint-with-output session - (if matlabp org-babel-octave-eoe-indicator org-babel-octave-eoe-output) t - (insert full-body) (comint-send-input nil t))) results) + (raw (if (and matlabp org-babel-matlab-with-emacs-link) + (save-window-excursion + (with-temp-buffer + (insert full-body) + (matlab-shell-run-region (point-min) (point-max)) + "")) ;; matlab-shell-run-region doesn't seem to + ;; make *matlab* buffer contents easily + ;; available, so :results output currently + ;; won't work + (org-babel-comint-with-output session + (if matlabp org-babel-octave-eoe-indicator org-babel-octave-eoe-output) t + (insert full-body) (comint-send-input nil t)))) results) (case result-type (value (org-babel-octave-import-elisp-from-file (org-babel-maybe-remote-file tmp-file)))