org-babel-lisp.el 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ;;; org-babel-lisp.el --- org-babel functions for lisp code evaluation
  2. ;; Copyright (C) 2009 Eric Schulte
  3. ;; Author: Eric Schulte
  4. ;; Keywords: literate programming, reproducible research
  5. ;; Homepage: http://orgmode.org
  6. ;; Version: 0.01
  7. ;;; License:
  8. ;; This program 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, or (at your option)
  11. ;; any later version.
  12. ;;
  13. ;; This program is distributed in the hope that it will be useful,
  14. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;; GNU General Public License for more details.
  17. ;;
  18. ;; You should have received a copy of the GNU General Public License
  19. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  20. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. ;; Boston, MA 02110-1301, USA.
  22. ;;; Commentary:
  23. ;; Org-Babel support for evaluating lisp code
  24. ;;; Code:
  25. (require 'org-babel)
  26. (org-babel-add-interpreter "emacs-lisp")
  27. (defun org-babel-execute:emacs-lisp (body params)
  28. "Execute a block of emacs-lisp code with org-babel. This
  29. function is called by `org-babel-execute-src-block'."
  30. (message "executing emacs-lisp code block...")
  31. (save-window-excursion
  32. (let ((vars (org-babel-ref-variables params))
  33. (print-level nil) (print-length nil) results)
  34. (setq results
  35. (eval `(let ,(mapcar (lambda (var) `(,(car var) ',(cdr var))) vars)
  36. ,(read (concat "(progn " body ")")))))
  37. results)))
  38. (provide 'org-babel-lisp)
  39. ;;; org-babel-lisp.el ends here