~ericmoritz/+junk/emacs.d

« back to all changes in this revision

Viewing changes to src/org-6.34c/contrib/babel/lisp/langs/org-babel-dot.el

  • Committer: Eric Moritz
  • Date: 2010-03-08 17:33:56 UTC
  • Revision ID: eric@eric-moritzs-macbook-pro.local-20100308173356-lfvzvmyp2kzm7l5y
Added a src folder to hold versions of packages that I use

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;;; org-babel-dot.el --- org-babel functions for dot evaluation
 
2
 
 
3
;; Copyright (C) 2009 Eric Schulte
 
4
 
 
5
;; Author: Eric Schulte
 
6
;; Keywords: literate programming, reproducible research
 
7
;; Homepage: http://orgmode.org
 
8
;; Version: 0.01
 
9
 
 
10
;;; License:
 
11
 
 
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.
 
16
;;
 
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.
 
21
;;
 
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.
 
26
 
 
27
;;; Commentary:
 
28
 
 
29
;; Org-Babel support for evaluating dot source code.
 
30
;;
 
31
;; For information on dot see http://www.graphviz.org/
 
32
;;
 
33
;; This differs from most standard languages in that
 
34
;;
 
35
;; 1) there is no such thing as a "session" in dot
 
36
;;
 
37
;; 2) we are generally only going to return results of type "file"
 
38
;;
 
39
;; 3) we are adding the "file" and "cmdline" header arguments
 
40
;;
 
41
;; 4) there are no variables (at least for now)
 
42
 
 
43
;;; Code:
 
44
(require 'org-babel)
 
45
 
 
46
(org-babel-add-interpreter "dot")
 
47
 
 
48
(add-to-list 'org-babel-tangle-langs '("dot" "dot"))
 
49
 
 
50
(defvar org-babel-default-header-args:dot '((:results . "file") (:exports . "results"))
 
51
  "Default arguments to use when evaluating a dot source block.")
 
52
 
 
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))
 
65
    out-file))
 
66
 
 
67
(defun org-babel-prep-session:dot (session params)
 
68
  (error "Dot does not support sessions"))
 
69
 
 
70
(provide 'org-babel-dot)
 
71
;;; org-babel-dot.el ends here