Merge branch 'octave-matlab'

This commit is contained in:
Dan Davison 2010-04-30 18:26:37 -04:00
commit 1a43a5939b
2 changed files with 19 additions and 4 deletions

View File

@ -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))

View File

@ -104,7 +104,8 @@ then create. Return the initialized session."
(let ((session (or session (if matlabp "*Inferior Matlab*" "*Inferior Octave*"))))
(if (org-babel-comint-buffer-livep session) session
(save-window-excursion
(if matlabp (matlab-shell) (run-octave))
(if matlabp (unless org-babel-matlab-with-emacs-link (matlab-shell))
(run-octave))
(rename-buffer (if (bufferp session) (buffer-name session)
(if (stringp session) session (buffer-name)))) (current-buffer))))))
@ -164,9 +165,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)))