org-babel-expand-body:octave
This commit is contained in:
parent
8e9f4eec88
commit
2759b6621d
|
@ -41,6 +41,18 @@
|
||||||
(defvar org-babel-octave-shell-command "octave -q"
|
(defvar org-babel-octave-shell-command "octave -q"
|
||||||
"Shell command to use to run octave as an external process.")
|
"Shell command to use to run octave as an external process.")
|
||||||
|
|
||||||
|
(defun org-babel-expand-body:octave (org-babel-process-params params)
|
||||||
|
(let ((vars (second (or processed-params (org-babel-process-params params)))))
|
||||||
|
(concat
|
||||||
|
;; prepend code to define all arguments passed to the code block
|
||||||
|
;; (may not be appropriate for all languages)
|
||||||
|
(mapconcat
|
||||||
|
(lambda (pair)
|
||||||
|
(format "%s=%s"
|
||||||
|
(car pair)
|
||||||
|
(org-babel-octave-var-to-octave (cdr pair))))
|
||||||
|
vars "\n") "\n" body "\n")))
|
||||||
|
|
||||||
(defun org-babel-execute:octave (body params &optional matlabp)
|
(defun org-babel-execute:octave (body params &optional matlabp)
|
||||||
"Execute a block of octave code with org-babel."
|
"Execute a block of octave code with org-babel."
|
||||||
(message (format "executing %s source code block" (if matlabp "matlab" "octave")))
|
(message (format "executing %s source code block" (if matlabp "matlab" "octave")))
|
||||||
|
@ -52,15 +64,7 @@
|
||||||
(result-params (third processed-params))
|
(result-params (third processed-params))
|
||||||
(result-type (fourth processed-params))
|
(result-type (fourth processed-params))
|
||||||
(out-file (cdr (assoc :file params)))
|
(out-file (cdr (assoc :file params)))
|
||||||
(augmented-body (concat
|
(augmented-body (org-babel-expand-body:octave body params processed-params))
|
||||||
;; prepend code to define all arguments passed to the code block
|
|
||||||
;; (may not be appropriate for all languages)
|
|
||||||
(mapconcat
|
|
||||||
(lambda (pair)
|
|
||||||
(format "%s=%s"
|
|
||||||
(car pair)
|
|
||||||
(org-babel-octave-var-to-octave (cdr pair))))
|
|
||||||
vars "\n") "\n" body "\n"))
|
|
||||||
(result (org-babel-octave-evaluate session augmented-body result-type matlabp)))
|
(result (org-babel-octave-evaluate session augmented-body result-type matlabp)))
|
||||||
(or out-file
|
(or out-file
|
||||||
(org-babel-reassemble-table
|
(org-babel-reassemble-table
|
||||||
|
|
Loading…
Reference in New Issue