[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] process diagrams with dot and some glue using org
From: |
Eric S Fraga |
Subject: |
Re: [O] process diagrams with dot and some glue using org |
Date: |
Sat, 20 Jul 2013 12:02:18 +0100 |
Rick Frankel <address@hidden> 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