Convert consecutive FSF copyright years to ranges.
[bpt/emacs.git] / lisp / org / ob-ditaa.el
CommitLineData
86fbb8ca
CD
1;;; ob-ditaa.el --- org-babel functions for ditaa evaluation
2
73b0cd50 3;; Copyright (C) 2009-2011 Free Software Foundation, Inc.
86fbb8ca
CD
4
5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org
acedf35c 8;; Version: 7.4
86fbb8ca
CD
9
10;; This file is part of GNU Emacs.
11
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.
16
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.
21
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/>.
24
25;;; Commentary:
26
27;; Org-Babel support for evaluating ditaa source code.
28;;
29;; This differs from most standard languages in that
30;;
31;; 1) there is no such thing as a "session" in ditaa
32;;
33;; 2) we are generally only going to return results of type "file"
34;;
35;; 3) we are adding the "file" and "cmdline" header arguments
36;;
37;; 4) there are no variables (at least for now)
38
39;;; Code:
40(require 'ob)
41
42(defvar org-babel-default-header-args:ditaa
43 '((:results . "file") (:exports . "results"))
44 "Default arguments for evaluating a ditaa source block.")
45
86fbb8ca
CD
46(defvar org-ditaa-jar-path)
47(defun org-babel-execute:ditaa (body params)
48 "Execute a block of Ditaa code with org-babel.
49This function is called by `org-babel-execute-src-block'."
afe98dfa
CD
50 (let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
51 (out-file (cdr (assoc :file params)))
52 (cmdline (cdr (assoc :cmdline params)))
53 (in-file (org-babel-temp-file "ditaa-"))
54 (cmd (concat "java -jar "
55 (shell-quote-argument
56 (expand-file-name org-ditaa-jar-path))
57 " " cmdline
58 " " (org-babel-process-file-name in-file)
59 " " (org-babel-process-file-name out-file))))
86fbb8ca
CD
60 (unless (file-exists-p org-ditaa-jar-path)
61 (error "Could not find ditaa.jar at %s" org-ditaa-jar-path))
62 (with-temp-file in-file (insert body))
afe98dfa 63 (message cmd) (shell-command cmd)
86fbb8ca
CD
64 out-file))
65
66(defun org-babel-prep-session:ditaa (session params)
67 "Return an error because ditaa does not support sessions."
68 (error "Ditaa does not support sessions"))
69
70(provide 'ob-ditaa)
71
86fbb8ca
CD
72
73;;; ob-ditaa.el ends here