Make org-publish-attachment honor directory structure
[org-mode.git] / lisp / ob-mscgen.el
blobc247dcb574bec5d1d7c83eebe332e4a4e1cf509d
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.01trans
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-expand-body:mscgen (body params &optional processed-params)
66 "Expand BODY according to PARAMS, return the expanded body." body)
68 (defun org-babel-execute:mscgen (body params)
69 "Execute a block of Mscgen code with Babel.
70 This function is called by `org-babel-execute-src-block'.
71 Default filetype is png. Modify by setting :filetype parameter to
72 mscgen supported formats."
73 (let* ((out-file (or (cdr (assoc :file params)) "output.png" ))
74 (filetype (or (cdr (assoc :filetype params)) "png" )))
75 (unless (cdr (assoc :file params))
76 (error "
77 ERROR: no output file specified. Add \":file name.png\" to the src header"))
78 (org-babel-eval (concat "mscgen -T " filetype " -o " out-file) body)
79 out-file))
81 (defun org-babel-prep-session:mscgen (session params)
82 "Raise an error because Mscgen doesn't support sessions."
83 (error "Mscgen does not support sessions"))
85 (provide 'ob-mscgen)
87 ;; arch-tag: 74695b1e-715f-4b5a-a3a9-d78ee39ba5c8
89 ;;; ob-msc.el ends here