Rick Frankel <r...@rickster.com> writes:

[...]

> I (sort of) disagree. I think specifying required arguments as header 
> vars makes the calling requirements clearer. Perhaps:
>
> #+HEADER: :var nodes='() graph='()
>
> would be better...
>
> rick
>

For Karl's benefit, the following is the latest version of the
graph-from-tables source code block including the above suggestion from
Rick and also the addition of an options variable.

#+begin_src org
  ,#+name: graph-from-tables
  ,#+header: :var options="" :var nodes='() graph='()
  ,#+BEGIN_SRC emacs-lisp :colnames yes 
    (org-babel-execute:dot
     (concat
          "digraph {\n"
          options "\n"   ;; "//rankdir=LR;\n" ;; remove comment characters '//' 
for horizontal layout; add for vertical layout
          (mapconcat
           (lambda (x)
             (format "%s [label=\"%s\" shape=%s style=\"filled\" 
fillcolor=\"%s\"]"
                             (car x)
                             (nth 1 x)
                             (if (string= "" (nth 2 x)) "box" (nth 2 x))
                             (if (string= "" (nth 3 x)) "none" (nth 3 x))
                             )) nodes "\n")
          "\n"
          (mapconcat
           (lambda (x)
             (format "%s -> %s [taillabel=\"%s\"]"
                             (car x) (nth 1 x) (nth 2 x))) graph "\n")
          "}\n") params)
  ,#+END_SRC
#+end_src

I can update the tutorial on Worg if desired.

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.50.1, Org release_8.0.6-341-g338603


Reply via email to