babel: smarter `org-babel-ref-split-args' -- fixes bug parsing indexed function-style...
[rgr-org-mode.git] / contrib / babel / lisp / langs / org-babel-ditaa.el
blobcc57584c4c0848805b6edd21b688180b88e9d136
1 ;;; org-babel-ditaa.el --- org-babel functions for ditaa evaluation
3 ;; Copyright (C) 2009 Eric Schulte
5 ;; Author: Eric Schulte
6 ;; Keywords: literate programming, reproducible research
7 ;; Homepage: http://orgmode.org
8 ;; Version: 0.01
10 ;;; License:
12 ;; This program 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, or (at your option)
15 ;; any later version.
17 ;; This program 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; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
27 ;;; Commentary:
29 ;; Org-Babel support for evaluating ditaa source code.
31 ;; This differs from most standard languages in that
33 ;; 1) there is no such thing as a "session" in ditaa
35 ;; 2) we are generally only going to return results of type "file"
37 ;; 3) we are adding the "file" and "cmdline" header arguments
39 ;; 4) there are no variables (at least for now)
41 ;;; Code:
42 (require 'org-babel)
44 (org-babel-add-interpreter "ditaa")
46 (add-to-list 'org-babel-tangle-langs '("ditaa" "ditaa"))
48 (defvar org-babel-default-header-args:ditaa
49 '((:results . "file") (:exports . "results"))
50 "Default arguments to use when evaluating a ditaa source block.")
52 (defun org-babel-execute:ditaa (body params)
53 "Execute a block of Ditaa code with org-babel. This function is
54 called by `org-babel-execute-src-block'."
55 (message "executing Ditaa source code block")
56 (let ((result-params (split-string (or (cdr (assoc :results params)) "")))
57 (out-file (cdr (assoc :file params)))
58 (cmdline (cdr (assoc :cmdline params)))
59 (in-file (make-temp-file "org-babel-ditaa")))
60 (unless (file-exists-p org-ditaa-jar-path)
61 (error (format "Could not find ditaa.jar at %s" org-ditaa-jar-path)))
62 (with-temp-file in-file (insert body))
63 (message (concat "java -jar " org-ditaa-jar-path " " cmdline " " in-file " " out-file))
64 (shell-command (concat "java -jar " org-ditaa-jar-path " " cmdline " " in-file " " out-file))
65 out-file))
67 (defun org-babel-prep-session:ditaa (session params)
68 (error "Ditaa does not support sessions"))
70 (provide 'org-babel-ditaa)
71 ;;; org-babel-ditaa.el ends here