~ericmoritz/+junk/emacs.d

« back to all changes in this revision

Viewing changes to src/org-6.34c/contrib/babel/lisp/langs/org-babel-emacs-lisp.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-emacs-lisp.el --- org-babel functions for emacs-lisp code 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 emacs-lisp code
 
30
 
 
31
;;; Code:
 
32
(require 'org-babel)
 
33
 
 
34
(org-babel-add-interpreter "emacs-lisp")
 
35
 
 
36
(add-to-list 'org-babel-tangle-langs '("emacs-lisp" "el"))
 
37
 
 
38
(defun org-babel-execute:emacs-lisp (body params)
 
39
  "Execute a block of emacs-lisp code with org-babel."
 
40
  (message "executing emacs-lisp code block...")
 
41
  (save-window-excursion
 
42
    (let* ((processed-params (org-babel-process-params params))
 
43
           (result-params (third processed-params))
 
44
           (vars (second (org-babel-process-params params)))
 
45
           (print-level nil) (print-length nil))
 
46
      (eval `(let ,(mapcar (lambda (var) `(,(car var) ',(cdr var)))
 
47
                           vars)
 
48
               ,(read (concat "(progn "
 
49
                              (if (or (member "code" result-params)
 
50
                                      (member "pp" result-params))
 
51
                                  (concat "(pp " body ")") body)
 
52
                              ")")))))))
 
53
 
 
54
(provide 'org-babel-emacs-lisp)
 
55
;;; org-babel-emacs-lisp.el ends here