From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric S Fraga Subject: Re: Business process diagrams in org-mode Date: Tue, 16 Nov 2010 16:35:03 +0000 Message-ID: <87vd3x9nmp.fsf@ucl.ac.uk> References: <87bp5sacnf.fsf@bunting.net.au> <871v6mq15z.fsf@pinto.chemeng.ucl.ac.uk> <87fwv2z9au.fsf@bunting.net.au> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=47318 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PIPg2-0000ZA-EL for emacs-orgmode@gnu.org; Tue, 16 Nov 2010 12:50:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PIPSX-0004sM-PA for emacs-orgmode@gnu.org; Tue, 16 Nov 2010 12:36:46 -0500 Received: from vscane-a2.ucl.ac.uk ([144.82.108.42]:54622) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PIPSX-0004rA-Hr for emacs-orgmode@gnu.org; Tue, 16 Nov 2010 12:36:45 -0500 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bart Bunting Cc: emacs-orgmode@gnu.org --=-=-= Bart Bunting writes: > Hi Eric, > > Thanks very much for the suggestion! > > I'm not familiar with dot but will invest some time to see if I can get > my head around it. > > This sounds like a good solution. Perhaps just writing directly in dot > will solve my problem. Possibly, although as it is possibly nicer to work with org tables, and because my train was delayed 45 minutes on the way to work this morning, here (attached as an org file with babel emacs lisp code) is one attempt at a solution. There is one bug in this code: for some reason, the dot code generated by the emacs lisp code gets embedded in an org EXAMPLE block. Not sure why but I have to do something else now... I'll try to come back to this later. Oh, I also changed your table so that each next step takes up a column entry in the table. This is not ideal but I didn't want to bother parsing the actual table entries. --=-=-= Content-Type: text/org Content-Disposition: attachment; filename=businessprocess.org Content-Description: business process org table to dot conversion example * 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: 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 --=-=-= HTH, eric -- : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 23.2.1 : using Org-mode version 7.3 (release_7.3.74.gb5907) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--