babel: ob-perl is now using the new ob-eval functionality
[org-mode.git] / lisp / ob-ditaa.el
blob1d70b5a44f7c4173acea221fec9b53c9b4c0335a
1 ;;; ob-ditaa.el --- org-babel functions for ditaa evaluation
3 ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
5 ;; Author: Eric Schulte
6 ;; Keywords: literate programming, reproducible research
7 ;; Homepage: http://orgmode.org
8 ;; Version: 0.01
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 ;; Org-Babel support for evaluating ditaa source code.
29 ;; This differs from most standard languages in that
31 ;; 1) there is no such thing as a "session" in ditaa
33 ;; 2) we are generally only going to return results of type "file"
35 ;; 3) we are adding the "file" and "cmdline" header arguments
37 ;; 4) there are no variables (at least for now)
39 ;;; Code:
40 (require 'ob)
42 (defvar org-babel-default-header-args:ditaa
43 '((:results . "file") (:exports . "results"))
44 "Default arguments to use when evaluating a ditaa source block.")
46 (defun org-babel-expand-body:ditaa (body params &optional processed-params)
47 "Expand BODY according to PARAMS, return the expanded body." body)
49 (defvar org-ditaa-jar-path)
50 (defun org-babel-execute:ditaa (body params)
51 "Execute a block of Ditaa code with org-babel. This function is
52 called by `org-babel-execute-src-block'."
53 (message "executing Ditaa source code block")
54 (let ((result-params (split-string (or (cdr (assoc :results params)) "")))
55 (out-file (cdr (assoc :file params)))
56 (cmdline (cdr (assoc :cmdline params)))
57 (in-file (make-temp-file "org-babel-ditaa")))
58 (unless (file-exists-p org-ditaa-jar-path)
59 (error (format "Could not find ditaa.jar at %s" org-ditaa-jar-path)))
60 (with-temp-file in-file (insert body))
61 (message (concat "java -jar " org-ditaa-jar-path " " cmdline " " in-file " " out-file))
62 (shell-command (concat "java -jar " org-ditaa-jar-path " " cmdline " " in-file " " out-file))
63 out-file))
65 (defun org-babel-prep-session:ditaa (session params)
66 "This function does nothing as ditaa does not support
67 sessions."
68 (error "Ditaa does not support sessions"))
70 (provide 'ob-ditaa)
72 ;; arch-tag: 492cd006-07d9-4fac-bef6-5bb60b48842e
74 ;;; ob-ditaa.el ends here