ob-org.el 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ;;; ob-org.el --- org-babel functions for org code block evaluation
  2. ;; Copyright (C) 2010 Free Software Foundation, Inc.
  3. ;; Author: Eric Schulte
  4. ;; Keywords: literate programming, reproducible research
  5. ;; Homepage: http://orgmode.org
  6. ;; Version: 7.4
  7. ;; This file is part of GNU Emacs.
  8. ;; GNU Emacs is free software: you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation, either version 3 of the License, or
  11. ;; (at your option) any later version.
  12. ;; GNU Emacs is distributed in the hope that it will be useful,
  13. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;; GNU General Public License for more details.
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  18. ;;; Commentary:
  19. ;; This is the simplest of code blocks, where upon evaluation the
  20. ;; contents of the code block are returned in a raw result.
  21. ;;; Code:
  22. (require 'ob)
  23. (declare-function org-export-string "org-exp" (string fmt &optional dir))
  24. (defvar org-babel-default-header-args:org
  25. '((:results . "raw silent") (:exports . "results"))
  26. "Default arguments for evaluating a org source block.")
  27. (defvar org-babel-org-default-header
  28. "#+TITLE: default empty header\n"
  29. "Default header inserted during export of org blocks.")
  30. (defun org-babel-execute:org (body params)
  31. "Execute a block of Org code with.
  32. This function is called by `org-babel-execute-src-block'."
  33. (let ((result-params (split-string (or (cdr (assoc :results params)) "")))
  34. (body (replace-regexp-in-string "^," "" body)))
  35. (cond
  36. ((member "latex" result-params) (org-export-string
  37. (concat "#+Title: \n" body) "latex"))
  38. ((member "html" result-params) (org-export-string body "html"))
  39. ((member "ascii" result-params) (org-export-string body "ascii"))
  40. (t body))))
  41. (defun org-babel-prep-session:org (session params)
  42. "Return an error because org does not support sessions."
  43. (error "Org does not support sessions"))
  44. (provide 'ob-org)
  45. ;; arch-tag: 130af5fe-cc56-46bd-9508-fa0ebd94cb1f
  46. ;;; ob-org.el ends here