babel: asymptote: New variable assignment scheme

* ob-asymptote.el (org-babel-execute:asymptote): Use generic
	expansion function
	(org-babel-expand-body:asymptote): Delete function
	(org-babel-variable-assignments:asymptote): New function
This commit is contained in:
Dan Davison 2010-10-21 11:37:02 +01:00
parent e3d9d21802
commit 4eee123e17
1 changed files with 8 additions and 7 deletions

View File

@ -55,12 +55,6 @@
'((:results . "file") (:exports . "results"))
"Default arguments when evaluating an Asymptote source block.")
(defun org-babel-expand-body:asymptote (body params)
"Expand BODY according to PARAMS, return the expanded body."
(let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
(concat (mapconcat 'org-babel-asymptote-var-to-asymptote vars "\n")
"\n" body "\n")))
(defun org-babel-execute:asymptote (body params)
"Execute a block of Asymptote code.
This function is called by `org-babel-execute-src-block'."
@ -83,7 +77,9 @@ This function is called by `org-babel-execute-src-block'."
" " cmdline
" " (org-babel-process-file-name in-file))))
(with-temp-file in-file
(insert (org-babel-expand-body:asymptote body params)))
(insert (org-babel-expand-body:generic
body params
(org-babel-variable-assignments:asymptote params))))
(message cmd) (shell-command cmd)
out-file))
@ -92,6 +88,11 @@ This function is called by `org-babel-execute-src-block'."
Asymptote does not support sessions"
(error "Asymptote does not support sessions"))
(defun org-babel-variable-assignments:asymptote (params)
"Return list of asymptote statements assigning the block's variables"
(mapcar #'org-babel-asymptote-var-to-asymptote
(mapcar #'cdr (org-babel-get-header params :var))))
(defun org-babel-asymptote-var-to-asymptote (pair)
"Convert an elisp value into an Asymptote variable.
The elisp value PAIR is converted into Asymptote code specifying