emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Process diagrams with dot and some glue using Org-mode
@ 2013-06-26 15:23 Karl Voit
  2013-06-26 15:41 ` Karl Voit
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Karl Voit @ 2013-06-26 15:23 UTC (permalink / raw)
  To: emacs-orgmode

Hi!

I was looking for a reasonable simple method to define processes and
work-flows within Org-mode. My research did not result in anything
existing I found useful. Therefore, I started to read about dot[1]
and found [2].

I would like to define my diagram with the following two tables: one
for the node definitions and one for the interconnections between
notes. The syntax should be pretty self-explanatory (or at least I
hope so):

  #+name: foobar-node-table
  | *node*     | *label*        | *shape* | *fillcolor* |
  |------------+----------------+---------+-------------|
  | S_start    | start          | ellipse | green       |
  | S_fill     | fill form      |         |             |
  | S_send     | send form      |         |             |
  | S_complete | form complete? | diamond | yellow      |
  | S_do       | do task        |         | red         |
  | S_end      | end            | ellipse |             |
  
  #+name: foobar-graph-table
  |            | S_start | S_fill | S_send | S_complete | S_do | S_end |
  | S_start    |         | -      |        |            |      |       |
  | S_fill     |         |        | >      |            |      |       |
  | S_send     |         |        |        | >          |      |       |
  | S_complete |         | N>     |        |            | Y>   |       |
  | S_do       |         |        |        |            |      | >     |
  | S_end      |         |        |        |            |      |       |

Some (still missing) glue should use these two tables and
automatically generate the dot script:

  #+BEGIN_SRC dot :file ~/test-dot.png :exports results
    digraph {
      //rankdir=LR;
      S_start [label ="start", shape = "ellipse", style=filled, fillcolor="green"];
      S_fill [label ="fill form", shape = "box"];
      S_send [label ="send form", shape = "box"];
      S_complete [label ="form complete?", shape = "diamond", style=filled, fillcolor="yellow"];
      S_do [label ="do task", shape = "box", style=filled, fillcolor="red"];
      S_end [label ="end", shape = "ellipse"];
      S_start -- S_fill;
      S_fill -> S_send;
      S_send -> S_complete;
      S_complete -> S_do [taillabel = "Y"];
      S_do -> S_end;
      S_complete -> S_fill [taillabel = "N"];
    }
  #+END_SRC

The question is: is somebody with decent ELISP knowledge able to
implement the missing method? :-)

I (not an ELISP hacker) would have to use Python and write a table
parsing class which will get too complicated for my taste :-(
However, my guess is that this could be implemented in ELISP with
much less effort.

I would be happy to document this method and provide it on Worg. In
my opinion, this would be very handy for many Org-mode users.

Thanks!

  1. https://en.wikipedia.org/wiki/DOT_language
  2. http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-dot.html
-- 
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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-06-26 15:23 Process diagrams with dot and some glue using Org-mode Karl Voit
@ 2013-06-26 15:41 ` Karl Voit
  2013-06-26 15:44 ` Rick Frankel
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 18+ messages in thread
From: Karl Voit @ 2013-06-26 15:41 UTC (permalink / raw)
  To: emacs-orgmode

Sorry, minor mistake: I could not find out why dot is not able to
mix directed and not directed graphs in one diagram. Therefore I had
to replace th "-" in the node table with ">" and the corresponding
results as well:

>   #+name: foobar-node-table
>  | *node*     | *label*        | *shape* | *fillcolor* |
>  |------------+----------------+---------+-------------|
>  | S_start    | start          | ellipse | green       |
>  | S_fill     | fill form      |         |             |
>  | S_send     | send form      |         |             |
>  | S_complete | form complete? | diamond | yellow      |
>  | S_do       | do task        |         | red         |
>  | S_end      | end            | ellipse |             |
>   
>   #+name: foobar-graph-table
>  |            | S_start | S_fill | S_send | S_complete | S_do | S_end |
>  | S_start    |         | >      |        |            |      |       |
>  | S_fill     |         |        | >      |            |      |       |
>  | S_send     |         |        |        | >          |      |       |
>  | S_complete |         | N>     |        |            | Y>   |       |
>  | S_do       |         |        |        |            |      | >     |
>  | S_end      |         |        |        |            |      |       |
>
>   #+BEGIN_SRC dot :file ~/test-dot.png :exports results
>     digraph {
>       //rankdir=LR;
>       S_start [label ="start", shape = "ellipse", style=filled, fillcolor="green"];
>       S_fill [label ="fill form", shape = "box"];
>       S_send [label ="send form", shape = "box"];
>       S_complete [label ="form complete?", shape = "diamond", style=filled, fillcolor="yellow"];
>       S_do [label ="do task", shape = "box", style=filled, fillcolor="red"];
>       S_end [label ="end", shape = "ellipse"];
>       S_start -> S_fill;
>       S_fill -> S_send;
>       S_send -> S_complete;
>       S_complete -> S_do [taillabel = "Y"];
>       S_do -> S_end;
>       S_complete -> S_fill [taillabel = "N"];
>     }
>   #+END_SRC

This results in a diagram as shown in: http://qr.cx/wEFr

-- 
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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-06-26 15:23 Process diagrams with dot and some glue using Org-mode Karl Voit
  2013-06-26 15:41 ` Karl Voit
@ 2013-06-26 15:44 ` Rick Frankel
  2013-06-26 17:03   ` Karl Voit
  2013-06-26 16:40 ` Eric S Fraga
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 18+ messages in thread
From: Rick Frankel @ 2013-06-26 15:44 UTC (permalink / raw)
  To: news1142; +Cc: emacs-orgmode

On 2013-06-26 11:23, Karl Voit wrote:
> Hi!
> 
> I would like to define my diagram with the following two tables: one
> for the node definitions and one for the interconnections between
> notes. The syntax should be pretty self-explanatory (or at least I
> hope so):
> I (not an ELISP hacker) would have to use Python and write a table
> parsing class which will get too complicated for my taste :-(
> However, my guess is that this could be implemented in ELISP with
> much less effort.
> 

Two things:

	1. You don't need to write table parsing code, as passing in a
	   table as an argument to a code block will convert it to an
	   array. For example:

	   #+name: ptable
| head1 | head2 |
|-------+-------|
| a     |     1 |
| b     |     2 |

	   #+BEGIN_SRC python :var t=ptable :results value
	     return t
	   #+END_SRC

	   #+RESULTS:
| a | 1 |
| b | 2 |

	   and the python code generated (view w/
	   `org-babel-expand-src-block'):

		   t=[["a", 1], ["b", 2]]
		   return t

	2. You can also use the pydot or pygraphviz libraries for
	   generating the graph directly from python instead of generating
	   dot code.

rick

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-06-26 15:23 Process diagrams with dot and some glue using Org-mode Karl Voit
  2013-06-26 15:41 ` Karl Voit
  2013-06-26 15:44 ` Rick Frankel
@ 2013-06-26 16:40 ` Eric S Fraga
  2013-06-27  6:56   ` Karl Voit
  2013-06-26 16:54 ` Thorsten Jolitz
  2013-07-03 19:18 ` Karl Voit
  4 siblings, 1 reply; 18+ messages in thread
From: Eric S Fraga @ 2013-06-26 16:40 UTC (permalink / raw)
  To: Karl Voit; +Cc: news1142, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1112 bytes --]

Hi Karl,

Karl Voit <devnull@Karl-Voit.at> writes:
> I was looking for a reasonable simple method to define processes and
> work-flows within Org-mode. My research did not result in anything
> existing I found useful. Therefore, I started to read about dot[1]
> and found [2].
>
> I would like to define my diagram with the following two tables: one
> for the node definitions and one for the interconnections between
> notes. The syntax should be pretty self-explanatory (or at least I
> hope so):

[...]

> The question is: is somebody with decent ELISP knowledge able to
> implement the missing method? :-)

I did something simple for generating graphs but without an adjacency
type of matrix as you have defined and without the special types of
edges.  So, quite limited with respect to what you want.  In any case,
I've attached what I played with a while ago in the hope that maybe some
of it proves useful.  What I did taxed my abilities in emacs lisp so I
won't be able to help much in adapting it to what you want...

eric
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.50.1, Org release_8.0.3-193-g334581

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: businessprocess.org --]
[-- Type: text/x-org, Size: 3897 bytes --]

* preamble
#+TITLE:     businessprocess.org
#+AUTHOR:    Eric S Fraga
#+EMAIL:     e.fraga@ucl.ac.uk
#+DATE:      2010-11-15 Mon
#+DESCRIPTION: cf. 
#+KEYWORDS: 
#+LANGUAGE:  en
#+OPTIONS:   H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
#+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js
#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
#+LINK_UP:   
#+LINK_HOME: 
#+XSLT: 

* The problem

Look at [[gnus:nnmaildir%2BUCL:lists#87bp5sacnf.fsf@bunting.net.au][this email]].

* the table

#+tblname: processtable 
| Step        | Description                                                             | Next Steps  |       |
|-------------+-------------------------------------------------------------------------+-------------+-------|
| Begin       | Begin the process                                                       | Choice1     |       |
| Choice1     | Decide if we are big or small.                                          | Big         | Small |
| Big         | If we are big then do big things                                        | End         |       |
| Small       | If we are small then figure out if we are really small or possibly big. | ReallySmall | Big   |
| ReallySmall | Yes we are really small                                                 | End         |       |
| End         | The end.                                                                |             |       |
|-------------+-------------------------------------------------------------------------+-------------+-------|

* the elisp code

#+source: esf/business-process
#+begin_src emacs-lisp :results value raw :exports results
(defun esf/generate-business-process-graph (table name file)
  (let ((entries (nthcdr 2 table))
	(output (format "digraph %s {" name))
	)
    (message "Initial: %s\n" table)
    (message "Entries: %s\n" entries)
    ;; we need to do two iterations through the table, one to define
    ;; the nodes and then one to connect them.
    (setq savedentries entries)		;for second iteration
    (while entries
      (let ((entry (first entries)))
	(if (listp entry)
	    (let ((step (first entry))
		  (description (nth 1 entry)) )
	      (setq output  (format "%s\n  %s [label=\"%s\"];" output step description))
	      )
	  )
	(setq entries (cdr entries))
	)
      )
    (setq entries savedentries)
    (while entries
      (let ((entry (first entries)))
	(if (listp entry)
	    (let ((from (first entry))
		  (nextsteps (cdr (cdr entry))) )
	      (message "Nextsteps: %s\n" nextsteps)
	      (while nextsteps
		(let ((to (first nextsteps)))
		  (if to 
		      (if (not (string= to ""))
			  (setq output (format "%s\n  %s -> %s;" output from to))))
		  (setq nextsteps (cdr nextsteps))
		  )
		)
	      )
	  )
	(setq entries (cdr entries))
	)
      ) ; end while entries left
    (format "#+begin_src dot :results file :file %s :exports results
%s
}
,#+end_src\n" file output)
    )
  )
(esf/generate-business-process-graph table name file)
#+end_src

* the graph
#+call: esf/business-process(table=processtable, file="business.pdf", name="process") :results value raw

#+results: esf/business-process(table=processtable, file="business.pdf", name="process")
#+begin_src dot :results file :file business.pdf :exports results
digraph process {
  Begin [label="Begin the process"];
  Choice1 [label="Decide if we are big or small."];
  Big [label="If we are big then do big things"];
  Small [label="If we are small then figure out if we are really small or possibly big."];
  ReallySmall [label="Yes we are really small"];
  End [label="The end."];
  Begin -> Choice1;
  Choice1 -> Big;
  Choice1 -> Small;
  Big -> End;
  Small -> ReallySmall;
  Small -> Big;
  ReallySmall -> End;
}
#+end_src

#+results:
[[file:business.pdf]]


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-06-26 15:23 Process diagrams with dot and some glue using Org-mode Karl Voit
                   ` (2 preceding siblings ...)
  2013-06-26 16:40 ` Eric S Fraga
@ 2013-06-26 16:54 ` Thorsten Jolitz
  2013-06-27  6:36   ` Karl Voit
  2013-07-03 19:18 ` Karl Voit
  4 siblings, 1 reply; 18+ messages in thread
From: Thorsten Jolitz @ 2013-06-26 16:54 UTC (permalink / raw)
  To: emacs-orgmode

Karl Voit <devnull@Karl-Voit.at> writes:

Hi, 

> I was looking for a reasonable simple method to define processes and
> work-flows within Org-mode. My research did not result in anything
> existing I found useful. Therefore, I started to read about dot[1]
> and found [2].

[...]

> Some (still missing) glue should use these two tables and
> automatically generate the dot script:

[...]

> The question is: is somebody with decent ELISP knowledge able to
> implement the missing method? :-)

not really an answer to your question, but I wrote a library
(picodoc.el) that automatically generates PlantUML scripts from PicoLisp
source code:

,-------------------------------------------------------
| https://github.com/tj64/picodoc/blob/master/picodoc.el
`-------------------------------------------------------

maybe you can take some inspiration there.

Instead of parsing a source file you would need to process nested lists
after applying

,-----------------------------------------------------------------------------
| org-table-to-lisp is an autoloaded compiled Lisp function in `org-table.el'.
| 
| (org-table-to-lisp &optional TXT)
| 
| Convert the table at point to a Lisp structure.
| The structure will be a list.  Each item is either the symbol `hline'
| for a horizontal separator line, or a list of field values as strings.
| The table is taken from the parameter TXT, or from the buffer at point.
`-----------------------------------------------------------------------------

to your tables. 

-- 
cheers,
Thorsten

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-06-26 15:44 ` Rick Frankel
@ 2013-06-26 17:03   ` Karl Voit
  2013-06-26 18:25     ` Rick Frankel
  0 siblings, 1 reply; 18+ messages in thread
From: Karl Voit @ 2013-06-26 17:03 UTC (permalink / raw)
  To: emacs-orgmode

* Rick Frankel <rick@rickster.com> wrote:
>
> Two things:
>
> 	1. You don't need to write table parsing code, as passing in a
> 	   table as an argument to a code block will convert it to an
> 	   array. 
>
> 	   #+name: ptable
>| head1 | head2 |
>|-------+-------|
>| a     |     1 |
>| b     |     2 |
[...]
> 	   #+RESULTS:
>| a | 1 |
>| b | 2 |
[...]
> 		   t=[["a", 1], ["b", 2]]

You're right, I totally forgot about this neat feature.

However, the header information seems to get lost. This requires
hard-coded column content which is a minor drawback of this method.

> 	2. You can also use the pydot or pygraphviz libraries for
> 	   generating the graph directly from python instead of generating
> 	   dot code.

Thanks for the pointer!

If somebody else is looking for an example (or some less formal
documentation), take a look at [1] which gave me a much better
start-up than the pydot web page.

  1. https://pythonhaven.wordpress.com/tag/pydot/
-- 
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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-06-26 17:03   ` Karl Voit
@ 2013-06-26 18:25     ` Rick Frankel
  2013-06-27  6:47       ` Karl Voit
  2013-06-28  9:20       ` Karl Voit
  0 siblings, 2 replies; 18+ messages in thread
From: Rick Frankel @ 2013-06-26 18:25 UTC (permalink / raw)
  To: news1142; +Cc: emacs-orgmode

On 2013-06-26 13:03, Karl Voit wrote:
> * Rick Frankel <rick@rickster.com> wrote:
> 
> Two things:
> 
> 	1. You don't need to write table parsing code, as passing in a
> 	   table as an argument to a code block will convert it to an
> 	   array.
> 		   t=[["a", 1], ["b", 2]]
> 
> You're right, I totally forgot about this neat feature.
> 
> 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':

	#+BEGIN_SRC python :var t=ptable :results value :colnames no
	  return t
	#+END_SRC

	t=[["head1", "head2"], ["a", 1], ["b", 2]]
	return t

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.
		- It requires you to specify the range on the node table

	#+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


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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-06-26 16:54 ` Thorsten Jolitz
@ 2013-06-27  6:36   ` Karl Voit
  0 siblings, 0 replies; 18+ messages in thread
From: Karl Voit @ 2013-06-27  6:36 UTC (permalink / raw)
  To: emacs-orgmode

* Thorsten Jolitz <tjolitz@gmail.com> wrote:
>
> not really an answer to your question, but I wrote a library
> (picodoc.el) that automatically generates PlantUML scripts from PicoLisp
> source code:

Thanks for the pointer. Looks interesting but as you wrote, not
really the solution that seems applicable in my case. However, I
should start reading ELISP like that :-)

-- 
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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-06-26 18:25     ` Rick Frankel
@ 2013-06-27  6:47       ` Karl Voit
  2013-06-27 13:06         ` Rick Frankel
  2013-06-28  9:20       ` Karl Voit
  1 sibling, 1 reply; 18+ messages in thread
From: Karl Voit @ 2013-06-27  6:47 UTC (permalink / raw)
  To: emacs-orgmode

* Rick Frankel <rick@rickster.com> wrote:
> On 2013-06-26 13:03, Karl Voit wrote:
>> * Rick Frankel <rick@rickster.com> 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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-06-26 16:40 ` Eric S Fraga
@ 2013-06-27  6:56   ` Karl Voit
  0 siblings, 0 replies; 18+ messages in thread
From: Karl Voit @ 2013-06-27  6:56 UTC (permalink / raw)
  To: emacs-orgmode

* Eric S Fraga <e.fraga@ucl.ac.uk> wrote:
>
> Hi Karl,

Hi Eric!

> I did something simple for generating graphs but without an adjacency
> type of matrix as you have defined and without the special types of
> edges.  So, quite limited with respect to what you want.  In any case,
> I've attached what I played with a while ago in the hope that maybe some
> of it proves useful.  What I did taxed my abilities in emacs lisp so I
> won't be able to help much in adapting it to what you want...

Looks cool! I definitely have to look into this snippet. However,
for now I probably will stick to Ricks simple solution since I
almost understand, how it is achieved. :-)

So far, your solutions looks like something for a more generic
problem. Thanks for providing it!

-- 
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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-06-27  6:47       ` Karl Voit
@ 2013-06-27 13:06         ` Rick Frankel
  2013-06-27 13:56           ` Bastien
  0 siblings, 1 reply; 18+ messages in thread
From: Rick Frankel @ 2013-06-27 13:06 UTC (permalink / raw)
  To: news1142; +Cc: emacs-orgmode

On Thu, Jun 27, 2013 at 08:47:14AM +0200, Karl Voit wrote:
> * Rick Frankel <rick@rickster.com> wrote:
> 
> > 		- 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.
[snip]
> 
> > 	#+HEADER: :var nodes=foobar-node-table[2:-1]

Yes, that's the range spec i was referring to.

[snip]
> 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

I'm not sure. Carsten or Bastien would be a better person to ask. It
might also belong in the Hacks?

rick

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-06-27 13:06         ` Rick Frankel
@ 2013-06-27 13:56           ` Bastien
  0 siblings, 0 replies; 18+ messages in thread
From: Bastien @ 2013-06-27 13:56 UTC (permalink / raw)
  To: Rick Frankel; +Cc: news1142, emacs-orgmode

Rick Frankel <rick@rickster.com> writes:

>> 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
>
> I'm not sure. Carsten or Bastien would be a better person to ask. It
> might also belong in the Hacks?

org-tutorials would do.  Thanks in advance!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-06-26 18:25     ` Rick Frankel
  2013-06-27  6:47       ` Karl Voit
@ 2013-06-28  9:20       ` Karl Voit
  2013-06-28 15:34         ` Rick Frankel
  1 sibling, 1 reply; 18+ messages in thread
From: Karl Voit @ 2013-06-28  9:20 UTC (permalink / raw)
  To: emacs-orgmode

* Rick Frankel <rick@rickster.com> wrote:

> And here's a simplier version which uses a graph table in the
> following format:
[...]

I tried to use your solution with the "#+call:" method.

Unfortunately, it fails and due to my limited ELISP knowledge, I can
not debug this issue. I've got the feeling that you might be able to
spot my error right away. 

I should add, that this is my first usage of "call:". So there might
be a misunderstanding on my side on how to use it properly:

#+name: graph-from-table
#+HEADER: :var nodes=foobar-node-table graph=foobar-graph
#+BEGIN_SRC emacs-lisp :file ~/tmp/2del/foovar-example-simple.png :colnames yes :exports results
  (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

#+name: example-node-table
| *node*     | *label*                | *shape* | *fillcolor* |
|------------+------------------------+---------+-------------|
| S_start    | example start          | ellipse | green       |
| S_fill     | example fill form      |         |             |
| S_send     | example send form      |         |             |
| S_complete | example form complete? | diamond | yellow      |
| S_do       | example do task        |         | red         |
| S_end      | example end            | ellipse |             |

#+name: example-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      |       |

#+call: graph-from-table(nodes=example-node-table,graph=example-graph)

-> this results in "format: Wrong type argument: listp, hline"



Note: I got the following additional parameters "in my pipeline" (want
to make them work) as well:

 :exports results :resname example-result :file ~/tmp/2del/example-simple.png


-- 
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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-06-28  9:20       ` Karl Voit
@ 2013-06-28 15:34         ` Rick Frankel
  2013-07-01 17:44           ` Karl Voit
  0 siblings, 1 reply; 18+ messages in thread
From: Rick Frankel @ 2013-06-28 15:34 UTC (permalink / raw)
  To: news1142; +Cc: emacs-orgmode

On 2013-06-28 05:20, Karl Voit wrote:
> * Rick Frankel <rick@rickster.com> wrote:
> 
> And here's a simplier version which uses a graph table in the
> following format:
> [...]
> 
> I tried to use your solution with the "#+call:" method.
> 
> Unfortunately, it fails and due to my limited ELISP knowledge, I can
> not debug this issue. I've got the feeling that you might be able to
> spot my error right away.
> 
> #+call: graph-from-table(nodes=example-node-table,graph=example-graph)
> 
> -> this results in "format: Wrong type argument: listp, hline"

This is because of what seems to be a bug in babel -- :colnames
options are not being respected in/for call lines. You always get the
above error when trying to process a table in elisp and the header is
not removed.

The solution is to specify the range on the call:

#+call: 
graph-from-table(nodes=example-node-table[2:-1],graph=example-graph[2:-1])

> > Note: I got the following additional parameters "in my pipeline" (want
> to make them work) as well:
> 
> :exports results :resname example-result :file 
> ~/tmp/2del/example-simple.png

You will also need to specify results :file; and the filename as a
parameter to the called block not the call. `Call's always export the
results i believe (you can add :exports results to the orginal source 
block).

#+call: graph-from-file[:file out.png](...) :results file

I don't think there is a :resname option. There was a #+RESNAME:
keyword, but it has been replaced w/ #+NAME:, which is currently not
functional for call lines (but is a hot topic in another thread on the
list.)

rick

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-06-28 15:34         ` Rick Frankel
@ 2013-07-01 17:44           ` Karl Voit
  0 siblings, 0 replies; 18+ messages in thread
From: Karl Voit @ 2013-07-01 17:44 UTC (permalink / raw)
  To: emacs-orgmode

* Rick Frankel <rick@rickster.com> wrote:
>
> The solution is to specify the range on the call:
>
> #+call: 
> graph-from-table(nodes=example-node-table[2:-1],graph=example-graph[2:-1])
[...]

Thank you *very* much for your explanations! You helped me to
understand the method that good that I will soon start documenting
it on Worg.

-- 
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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-06-26 15:23 Process diagrams with dot and some glue using Org-mode Karl Voit
                   ` (3 preceding siblings ...)
  2013-06-26 16:54 ` Thorsten Jolitz
@ 2013-07-03 19:18 ` Karl Voit
  2013-07-03 20:57   ` Nick Dokos
  2013-07-05 16:15   ` Eric S Fraga
  4 siblings, 2 replies; 18+ messages in thread
From: Karl Voit @ 2013-07-03 19:18 UTC (permalink / raw)
  To: emacs-orgmode

* Karl Voit <devnull@Karl-Voit.at> wrote:
>
> I would be happy to document this method and provide it on Worg. In
> my opinion, this would be very handy for many Org-mode users.

I summarized the method on Worg[1].

Can someone please proof read the page? I am not a native speaker
and it's always good to let someone else check my weird flow of
thoughts :-)

And there is a small issue I have got: I was not able to include the
resulting image files. I looked at [2] and did it like with [3].
However, my [4] results in a 404 Not Found message. Do I have to
register any new folder somewhere?

Thanks!

  1. http://orgmode.org/worg/org-tutorials/org-dot-diagrams.html
  2. http://orgmode.org/worg/org-tutorials/org-plot.html
  3. http://orgmode.org/worg/images/org-plot/example-1.png
  4. http://orgmode.org/worg/images/org-dot/example-diagram.png
-- 
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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-07-03 19:18 ` Karl Voit
@ 2013-07-03 20:57   ` Nick Dokos
  2013-07-05 16:15   ` Eric S Fraga
  1 sibling, 0 replies; 18+ messages in thread
From: Nick Dokos @ 2013-07-03 20:57 UTC (permalink / raw)
  To: emacs-orgmode

Karl Voit <devnull@Karl-Voit.at> writes:

> * Karl Voit <devnull@Karl-Voit.at> wrote:
>>
>> I would be happy to document this method and provide it on Worg. In
>> my opinion, this would be very handy for many Org-mode users.
>
> I summarized the method on Worg[1].
>
> Can someone please proof read the page? I am not a native speaker
> and it's always good to let someone else check my weird flow of
> thoughts :-)
>

It's all good I think - thanks for putting it together!

> And there is a small issue I have got: I was not able to include the
> resulting image files. I looked at [2] and did it like with [3].
> However, my [4] results in a 404 Not Found message. Do I have to
> register any new folder somewhere?
>

Well, I pulled worg and there is an images/org-dot directory and it has
two png files in it. AFAICT, it should work: nginx obviously
disagrees. But from this distance, it seems like a small problem: Jason
or Bastien (or somebody with access to the server logs) should be able to
fix it in a jiffy.

> Thanks!
>
>   1. http://orgmode.org/worg/org-tutorials/org-dot-diagrams.html
>   2. http://orgmode.org/worg/org-tutorials/org-plot.html
>   3. http://orgmode.org/worg/images/org-plot/example-1.png
>   4. http://orgmode.org/worg/images/org-dot/example-diagram.png

-- 
Nick

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Process diagrams with dot and some glue using Org-mode
  2013-07-03 19:18 ` Karl Voit
  2013-07-03 20:57   ` Nick Dokos
@ 2013-07-05 16:15   ` Eric S Fraga
  1 sibling, 0 replies; 18+ messages in thread
From: Eric S Fraga @ 2013-07-05 16:15 UTC (permalink / raw)
  To: Karl Voit; +Cc: news1142, emacs-orgmode

Karl Voit <devnull@Karl-Voit.at> writes:

> * Karl Voit <devnull@Karl-Voit.at> wrote:
>>
>> I would be happy to document this method and provide it on Worg. In
>> my opinion, this would be very handy for many Org-mode users.
>
> I summarized the method on Worg[1].
>
> Can someone please proof read the page? I am not a native speaker
> and it's always good to let someone else check my weird flow of
> thoughts :-)

Looks good!  Thanks for putting this up.
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.50.1, Org release_8.0.3-324-gb61ef4

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2013-07-05 16:15 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-26 15:23 Process diagrams with dot and some glue using Org-mode Karl Voit
2013-06-26 15:41 ` Karl Voit
2013-06-26 15:44 ` Rick Frankel
2013-06-26 17:03   ` Karl Voit
2013-06-26 18:25     ` Rick Frankel
2013-06-27  6:47       ` Karl Voit
2013-06-27 13:06         ` Rick Frankel
2013-06-27 13:56           ` Bastien
2013-06-28  9:20       ` Karl Voit
2013-06-28 15:34         ` Rick Frankel
2013-07-01 17:44           ` Karl Voit
2013-06-26 16:40 ` Eric S Fraga
2013-06-27  6:56   ` Karl Voit
2013-06-26 16:54 ` Thorsten Jolitz
2013-06-27  6:36   ` Karl Voit
2013-07-03 19:18 ` Karl Voit
2013-07-03 20:57   ` Nick Dokos
2013-07-05 16:15   ` Eric S Fraga

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).