1 ;;; ob-org.el --- org-babel functions for org code block evaluation
3 ;; Copyright (C) 2010 Free Software Foundation, Inc.
5 ;; Author: Eric Schulte
6 ;; Keywords: literate programming, reproducible research
7 ;; Homepage: http://orgmode.org
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/>.
27 ;; This is the simplest of code blocks, where upon evaluation the
28 ;; contents of the code block are returned in a raw result.
33 (declare-function org-load-modules-maybe
"org" (&optional force
))
34 (declare-function org-get-local-variables
"org" ())
36 (defvar org-babel-default-header-args
:org
37 '((:results .
"raw silent") (:exports .
"results"))
38 "Default arguments for evaluating a org source block.")
40 (defvar org-babel-org-default-header
41 "#+TITLE: default empty header\n"
42 "Default header inserted during export of org blocks.")
44 (defun org-babel-expand-body:org
(body params
&optional processed-params
)
45 "Expand BODY according to PARAMS, return the expanded body." body
)
47 (defun org-babel-execute:org
(body params
)
48 "Execute a block of Org code with.
49 This function is called by `org-babel-execute-src-block'."
50 (let ((result-params (split-string (or (cdr (assoc :results params
)) ""))))
52 ((member "latex" result-params
) (org-babel-org-export body
"latex"))
53 ((member "html" result-params
) (org-babel-org-export body
"html"))
54 ((member "ascii" result-params
) (org-babel-org-export body
"ascii"))
57 (defvar org-local-vars
)
58 (defun org-babel-org-export (body fmt
)
59 "Export BODY to FMT using Org-mode's export facilities. "
60 (let ((tmp-file (org-babel-temp-file "org-")))
62 (insert org-babel-org-default-header
)
65 (org-load-modules-maybe)
66 (unless org-local-vars
67 (setq org-local-vars
(org-get-local-variables)))
68 (eval ;; convert to fmt -- mimicing `org-run-like-in-org-mode'
69 (list 'let org-local-vars
70 (list (intern (concat "org-export-as-" fmt
))
71 nil nil nil
''string t
))))))
73 (defun org-babel-prep-session:org
(session params
)
74 "Return an error because org does not support sessions."
75 (error "Org does not support sessions"))
79 ;; arch-tag: 130af5fe-cc56-46bd-9508-fa0ebd94cb1f
81 ;;; ob-org.el ends here