Hello, wang jinjian <wjj1...@gmail.com> writes:
> Use case is call dot babel from elisp code block. refer to > http://orgmode.org/worg/org-tutorials/org-dot-diagrams.html > > Below is a more minimal example: > > #+NAME: nodes > | From | To | Weight | > > |------+----+--------| > | A | B | 3 | > | A | C | 2 | > | B | D | 4 | > | B | E | 5 | > | C | F | 10 | > > #+BEGIN_SRC elisp :file a.png :var nodes=nodes > (defun rowfun(x) > (format "%s -> %s [label=%s];" (nth 0 x) (nth 1 x) (nth 2 x)) > ) > (defun dotgen(nodes) > (let ((dotbegin "digraph {\nnode [shape=circle]\n") > (dotend "\n}")) > (concat dotbegin > (mapconcat #'rowfun nodes "\n") > dotend))) > (setq params (nth 2 (org-babel-get-src-block-info))) > (org-babel-execute:dot (dotgen nodes) params) > #+END_SRC > > If run this block with C-c C-c, it will generate a image a.png with > "nil" string in it. so it's a invalid image file. I can achieve the desired effect with: #+name: nodes | From | To | Weight | |------+----+--------| | A | B | 3 | | A | C | 2 | | B | D | 4 | | B | E | 5 | | C | F | 10 | #+begin_src elisp :file /tmp/a.png :var nodes=nodes :results file (defun rowfun (x) (format "%s -> %s [label=%s];" (nth 0 x) (nth 1 x) (nth 2 x))) (defun dotgen (nodes) (format "digraph {\nnode [shape=circle]\n%s\n}" (mapconcat #'rowfun nodes "\n"))) (dotgen nodes) #+end_src I don't see why you would need to call `org-babel-execute:dot'. Does it fix your issue? Regards, -- Nicolas Goaziou 0x80A93738