org-html.el (org-html-handle-links): Fix bug in setting the attribute for link with...
[org-mode.git] / lisp / ob-mscgen.el
blob5838d7dec7e1fb6018ea1e5ac5c19f647a0aac6e
1 ;;; ob-msc.el --- org-babel functions for mscgen evaluation
3 ;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
5 ;; Author: Juan Pechiar
6 ;; Keywords: literate programming, reproducible research
7 ;; Homepage: http://orgmode.org
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;;; Commentary:
26 ;; This software provides EMACS org-babel export support for message
27 ;; sequence charts. The mscgen utility is used for processing the
28 ;; sequence definition, and must therefore be installed in the system.
30 ;; Mscgen is available and documented at
31 ;; http://www.mcternan.me.uk/mscgen/index.html
33 ;; This code is directly inspired by Eric Schulte's ob-dot.el
35 ;; Example:
37 ;; #+begin_src mscgen :file example.png
38 ;; msc {
39 ;; A,B;
40 ;; A -> B [ label = "send message" ];
41 ;; A <- B [ label = "get answer" ];
42 ;; }
43 ;; #+end_src
45 ;; Header for alternative file type:
47 ;; #+begin_src mscgen :file ex2.svg :filetype svg
49 ;; This differs from most standard languages in that
51 ;; 1) there is no such thing as a "session" in mscgen
52 ;; 2) we are generally only going to return results of type "file"
53 ;; 3) we are adding the "file" and "filetype" header arguments
54 ;; 4) there are no variables
56 ;;; Code:
57 (require 'ob)
58 (require 'ob-eval)
60 (defvar org-babel-default-header-args:mscgen
61 '((:results . "file") (:exports . "results"))
62 "Default arguments to use when evaluating a mscgen source block.")
64 (defun org-babel-execute:mscgen (body params)
65 "Execute a block of Mscgen code with Babel.
66 This function is called by `org-babel-execute-src-block'.
67 Default filetype is png. Modify by setting :filetype parameter to
68 mscgen supported formats."
69 (let* ((out-file (or (cdr (assoc :file params)) "output.png" ))
70 (filetype (or (cdr (assoc :filetype params)) "png" )))
71 (unless (cdr (assoc :file params))
72 (error "
73 ERROR: no output file specified. Add \":file name.png\" to the src header"))
74 (org-babel-eval (concat "mscgen -T " filetype " -o " out-file) body)
75 nil)) ;; signal that output has already been written to file
77 (defun org-babel-prep-session:mscgen (session params)
78 "Raise an error because Mscgen doesn't support sessions."
79 (error "Mscgen does not support sessions"))
81 (provide 'ob-mscgen)
85 ;;; ob-msc.el ends here