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