diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2010-07-14 16:39:19 -0700 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2010-07-14 16:39:19 -0700 |
commit | fb72ef7809f0acc098b02c77f75c80a0c98ca156 (patch) | |
tree | c349c53f54e1a78635485f6b1e476ea25c2b32f8 | |
parent | aad9ce99ab64e08c2bdb3d9ec57af1314b35a9dc (diff) | |
download | org-mode-fb72ef7809f0acc098b02c77f75c80a0c98ca156.tar.gz |
ob-dot: can handle arguments
* lisp/ob-dot.el (org-babel-expand-body:dot): now inserts variable
arguments rather than ignoring them
(org-babel-execute:dot): making use of org-babel-expand-body:dot
-rw-r--r-- | lisp/ob-dot.el | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lisp/ob-dot.el b/lisp/ob-dot.el index edf8f90..751d2e5 100644 --- a/lisp/ob-dot.el +++ b/lisp/ob-dot.el @@ -47,17 +47,32 @@ "Default arguments to use when evaluating a dot source block.") (defun org-babel-expand-body:dot (body params &optional processed-params) - "Expand BODY according to PARAMS, return the expanded body." body) + "Expand BODY according to PARAMS, return the expanded body." + (let ((vars (nth 1 (or processed-params + (org-babel-process-params params))))) + (mapc + (lambda (pair) + (let ((name (symbol-name (car pair))) + (value (cdr pair))) + (setq body + (replace-regexp-in-string + (concat "\$" (regexp-quote name)) + (if (stringp value) value (format "%S" value)) + body)))) + vars) + body)) (defun org-babel-execute:dot (body params) "Execute a block of Dot code with org-babel. This function is called by `org-babel-execute-src-block'." - (let ((result-params (split-string (or (cdr (assoc :results params)) ""))) + (let ((processed-params (org-babel-process-params params)) + (result-params (split-string (or (cdr (assoc :results params)) ""))) (out-file (cdr (assoc :file params))) (cmdline (cdr (assoc :cmdline params))) (cmd (or (cdr (assoc :cmd params)) "dot")) (in-file (make-temp-file "org-babel-dot"))) - (with-temp-file in-file (insert body)) + (with-temp-file in-file + (insert (org-babel-expand-body:dot body params processed-params))) (org-babel-eval (concat cmd " " in-file " " cmdline " -o " out-file) "") out-file)) |