1
;;; org-babel-dot.el --- org-babel functions for dot evaluation
3
;; Copyright (C) 2009 Eric Schulte
5
;; Author: Eric Schulte
6
;; Keywords: literate programming, reproducible research
7
;; Homepage: http://orgmode.org
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)
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.
29
;; Org-Babel support for evaluating dot source code.
31
;; For information on dot see http://www.graphviz.org/
33
;; This differs from most standard languages in that
35
;; 1) there is no such thing as a "session" in dot
37
;; 2) we are generally only going to return results of type "file"
39
;; 3) we are adding the "file" and "cmdline" header arguments
41
;; 4) there are no variables (at least for now)
46
(org-babel-add-interpreter "dot")
48
(add-to-list 'org-babel-tangle-langs '("dot" "dot"))
50
(defvar org-babel-default-header-args:dot '((:results . "file") (:exports . "results"))
51
"Default arguments to use when evaluating a dot source block.")
53
(defun org-babel-execute:dot (body params)
54
"Execute a block of Dot code with org-babel. This function is
55
called by `org-babel-execute-src-block'."
56
(message "executing Dot source code block")
57
(let ((result-params (split-string (or (cdr (assoc :results params)) "")))
58
(out-file (cdr (assoc :file params)))
59
(cmdline (cdr (assoc :cmdline params)))
60
(cmd (or (cdr (assoc :cmd params)) "dot"))
61
(in-file (make-temp-file "org-babel-dot")))
62
(with-temp-file in-file (insert body))
63
(message (concat cmd " " in-file " " cmdline " -o " out-file))
64
(shell-command (concat cmd " " in-file " " cmdline " -o " out-file))
67
(defun org-babel-prep-session:dot (session params)
68
(error "Dot does not support sessions"))
70
(provide 'org-babel-dot)
71
;;; org-babel-dot.el ends here