Browse Source

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
Dan Davison 15 years ago
parent
commit
4eee123e17
1 changed files with 8 additions and 7 deletions
  1. 8 7
      lisp/ob-asymptote.el

+ 8 - 7
lisp/ob-asymptote.el

@@ -55,12 +55,6 @@
   '((:results . "file") (:exports . "results"))
   '((:results . "file") (:exports . "results"))
   "Default arguments when evaluating an Asymptote source block.")
   "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)
 (defun org-babel-execute:asymptote (body params)
   "Execute a block of Asymptote code.
   "Execute a block of Asymptote code.
 This function is called by `org-babel-execute-src-block'."
 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
 		  " " cmdline
 		  " " (org-babel-process-file-name in-file))))
 		  " " (org-babel-process-file-name in-file))))
     (with-temp-file 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)
     (message cmd) (shell-command cmd)
     out-file))
     out-file))
 
 
@@ -92,6 +88,11 @@ This function is called by `org-babel-execute-src-block'."
 Asymptote does not support sessions"
 Asymptote does not support sessions"
   (error "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)
 (defun org-babel-asymptote-var-to-asymptote (pair)
   "Convert an elisp value into an Asymptote variable.
   "Convert an elisp value into an Asymptote variable.
 The elisp value PAIR is converted into Asymptote code specifying
 The elisp value PAIR is converted into Asymptote code specifying