From mboxrd@z Thu Jan 1 00:00:00 1970 From: Karl Voit Subject: Re: Process diagrams with dot and some glue using Org-mode Date: Thu, 27 Jun 2013 08:47:14 +0200 Message-ID: <2013-06-27T08-37-17@devnull.Karl-Voit.at> References: <2013-06-26T17-08-48@devnull.Karl-Voit.at> <5b90a6852c7b87d077016cbb0479ff23@mail.rickster.com> <2013-06-26T18-59-53@devnull.Karl-Voit.at> <4c174089656ce0b08177f464325c4bf9@mail.rickster.com> Reply-To: news1142@Karl-Voit.at Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Us5zM-0002Wa-24 for emacs-orgmode@gnu.org; Thu, 27 Jun 2013 02:47:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Us5zK-0007GR-I8 for emacs-orgmode@gnu.org; Thu, 27 Jun 2013 02:47:27 -0400 Received: from plane.gmane.org ([80.91.229.3]:50031) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Us5zK-0007G5-5m for emacs-orgmode@gnu.org; Thu, 27 Jun 2013 02:47:26 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Us5zI-000722-KV for emacs-orgmode@gnu.org; Thu, 27 Jun 2013 08:47:24 +0200 Received: from mail.michael-prokop.at ([88.198.6.110]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 27 Jun 2013 08:47:24 +0200 Received: from news1142 by mail.michael-prokop.at with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 27 Jun 2013 08:47:24 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org * Rick Frankel wrote: > On 2013-06-26 13:03, Karl Voit wrote: >> * Rick Frankel wrote: >> >> However, the header information seems to get lost. This requires >> hard-coded column content which is a minor drawback of this method. > > Just use `:colnames no': I love Org-mode :-) > Regardless, here's a hack which does what you want. Note to things: > - it executes the dot code directly and uses the :file > header argument for output, because you need the > colnames of the graph table but not of the node table. Got it. > - It requires you to specify the range on the node table Sorry, I did not understand this since I could not locate any range specification below except that one for foobar-node-table in the header. Is this the thing you mentioned? If so, I do not consider this as an issue at all because [2:-1] is right for any number of rows. > #+HEADER: :var nodes=foobar-node-table[2:-1] > #+HEADER: :var graph=foobar-graph-table > #+BEGIN_SRC emacs-lisp :results file :file "./t.png" > (org-babel-execute:dot > (concat > " digraph {" > (mapconcat > (lambda (x) > (format "%s [label=\"%s\" shape=%s 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" > (let* ((to-nodes (car graph)) (len (length to-nodes))) > (mapconcat > (lambda (x) > (let ((name (car x))) > (mapconcat > 'identity > (loop with result = '() > for i from 1 to len > do > (when (> (length (nth i x)) 0) > (add-to-list 'result > (format "%s -> %s [label=\"%s\"]\n" > name > (nth i to-nodes) > (substring (nth i x) 0 -1)))) > finally > return result) "\n"))) (cdr graph) "")) > "}") params) > #+END_SRC I'll have to take a look at this. > And here's a simplier version which uses a graph table in the > following format: > > #+name: foobar-graph > | from | to | label | > |------------+------------+-------| > | S_start | S_fill | | > | S_fill | S_send | | > | S_send | S_complete | | > | S_complete | S_fill | N | > | S_complete | S_do | Y | > | S_do | S_end | | > > #+HEADER: :var nodes=foobar-node-table graph=foobar-graph > #+BEGIN_SRC emacs-lisp :file ./t2.png :colnames yes > (org-babel-execute:dot > (concat > "digraph {\n" > (mapconcat > (lambda (x) > (format "%s [label=\"%s\" shape=%s 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 Wow, this looks great to me! Most likely, I will stick to this simpler version. Thank you very much for your effort! And thank you for the ELISP example I will try to fully understand. I love this community :-) Where should I place this method? Org-tutorials? [1] probably? New section in [2]? 1. http://orgmode.org/worg/org-tutorials/#sec-3-2 2. http://orgmode.org/worg/org-tutorials/#sec-4 -- mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode: > get Memacs from https://github.com/novoid/Memacs < https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github