From mboxrd@z Thu Jan 1 00:00:00 1970 From: Juan Subject: Re: Code snippet for Message Sequence Diagram export Date: Mon, 17 May 2010 17:04:31 -0300 Message-ID: <20100517200431.GA27574@soloJazz.com> References: <20100516201839.GA25054@soloJazz.com> <87aarzq72u.wl%ucecesf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=59703 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OE6YW-0005NR-IG for emacs-orgmode@gnu.org; Mon, 17 May 2010 16:05:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OE6YI-0006vF-8N for emacs-orgmode@gnu.org; Mon, 17 May 2010 16:04:43 -0400 Received: from cpoproxy1-pub.bluehost.com ([69.89.21.11]:58199 helo=outbound-mail-01.bluehost.com) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1OE6YH-0006uy-CV for emacs-orgmode@gnu.org; Mon, 17 May 2010 16:04:38 -0400 Content-Disposition: inline In-Reply-To: <87aarzq72u.wl%ucecesf@ucl.ac.uk> 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: e.fraga@ucl.ac.uk Cc: Emacs-orgmode Below goes code snippet using org-babel instead of org-export. On Mon, May 17, 2010 at 09:13:29AM +0100, Eric S Fraga wrote: > On Sun, 16 May 2010 17:18:39 -0300, Juan wrote: > > The following code adds an export block of type 'mscgen'. The block > > body will be processed by the mscgen application. Sort of works, not > > very tested yet. > > [...] > > Juan, > > this could be very useful. Thanks! I do wonder, however, whether it > would make sense to have this as a org-babel language? It would be > nice to have the images generated appear in the org file directly... > > Thanks again, > eric ;;; org-babel-mscgen.el --- org-babel functions for mscgen evaluation ;;; TODO insert GPL header here ;;; Commentary: ;; ;; This software provides EMACS org-babel export support for message ;; sequence charts. The mscgen utility is used for processing the ;; sequence definition, and must therefore be installed in the system. ;; ;; The code is a direct modification of org-babel-ditaa ;; from the org-mode distribution. ;; ;; Mscgen is available and documented at http://www.mcternan.me.uk/mscgen/index.html ;; ;; Customize path to mscgen utility with org-mscgen-path variable ;; ;; Example: ;; ;; #+begin_src mscgen :file example.png ;; A,B; ;; A -> B [ label = "send message" ]; ;; B <: A [ label = "get answer" ]; ;; #+end_src ;;; Code: (require 'org-babel) (defvar org-mscgen-path "/opt/local/bin/mscgen" "Complete path to the mscgen executable") (org-babel-add-interpreter "mscgen") (add-to-list 'org-babel-tangle-langs '("mscgen" "mscgen")) (defvar org-babel-default-header-args:mscgen '((:results . "file") (:exports . "results")) "Default arguments to use when evaluating a mscgen source block.") (defun org-babel-expand-body:mscgen (body params &optional processed-params) body) (defun org-babel-execute:mscgen (body params) "Execute a block of Mscgen code with org-babel. This function is called by `org-babel-execute-src-block'." (message "executing Mscgen source code block") (let ((result-params (split-string (or (cdr (assoc :results params)) ""))) (out-file (cdr (assoc :file params))) (cmdline (cdr (assoc :cmdline params))) (in-file (make-temp-file "org-babel-mscgen"))) (unless (file-exists-p org-mscgen-path) (error (format "Could not find mscgen at %s" org-mscgen-path))) (with-temp-file in-file (insert (concat "msc {\n" body "\n}\n"))) (message (concat org-mscgen-path " -T png -o " out-file " -i " in-file)) (shell-command (concat org-mscgen-path " -T png -o " out-file " -i " in-file)) out-file)) (defun org-babel-prep-session:mscgen (session params) (error "Mscgen does not support sessions")) (provide 'org-babel-mscgen) ;;; org-babel-mscgen.el ends here