Mercurial > emacs
annotate lisp/org/ob-emacs-lisp.el @ 110859:7aa4fdb60d57
shr.el (shr-insert): Don't insert double spaces.
auth.texi (Help for users, GnuPG and EasyPG Assistant Configuration): Update docs.
gnus-registry.el, nnregistry.el: Remove nnregistry refer method auto-install and update docs.
gnus.texi (Finding the Parent, The Gnus Registry, Registry Article Refer Method): Update docs for nnregistry.el.
gnus-demon.el, gnus-group.el, gnus-msg.el, gnus-sum.el, gnus-util.el, gnus.el: Rename `gnus-pull' to `gnus-alist-pull'.
gnus.texi (Article Washing): Add mm-shr.
mm-decode.el (mm-text-html-renderer): Add mm-shr in choice list.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Fri, 08 Oct 2010 23:55:33 +0000 |
parents | 6452d50492bb |
children | 5cb272c831e8 |
rev | line source |
---|---|
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
1 ;;; ob-emacs-lisp.el --- org-babel functions for emacs-lisp code evaluation |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
2 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
3 ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
4 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
5 ;; Author: Eric Schulte |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
6 ;; Keywords: literate programming, reproducible research |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
7 ;; Homepage: http://orgmode.org |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
8 ;; Version: 7.01 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
9 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
11 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
15 ;; (at your option) any later version. |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
16 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
20 ;; GNU General Public License for more details. |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
21 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
24 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
25 ;;; Commentary: |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
26 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
27 ;; Org-Babel support for evaluating emacs-lisp code |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
28 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
29 ;;; Code: |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
30 (require 'ob) |
109823
6452d50492bb
Fix some more Org `check-declare' issues.
Glenn Morris <rgm@gnu.org>
parents:
109462
diff
changeset
|
31 (eval-when-compile (require 'ob-comint)) |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
32 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
33 (defvar org-babel-default-header-args:emacs-lisp |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
34 '((:hlines . "yes") (:colnames . "no")) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
35 "Default arguments for evaluating an emacs-lisp source block.") |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
36 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
37 (declare-function orgtbl-to-generic "org-table" (table params)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
38 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
39 (defun org-babel-expand-body:emacs-lisp (body params &optional processed-params) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
40 "Expand BODY according to PARAMS, return the expanded body." |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
41 (let* ((processed-params (or processed-params (org-babel-process-params params))) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
42 (vars (nth 1 processed-params)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
43 (result-params (nth 2 processed-params)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
44 (print-level nil) (print-length nil) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
45 (body (if (> (length vars) 0) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
46 (concat "(let (" |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
47 (mapconcat |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
48 (lambda (var) (format "%S" (print `(,(car var) ',(cdr var))))) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
49 vars "\n ") |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
50 ")\n" body ")") |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
51 body))) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
52 (if (or (member "code" result-params) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
53 (member "pp" result-params)) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
54 (concat "(pp " body ")") body))) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
55 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
56 (defun org-babel-execute:emacs-lisp (body params) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
57 "Execute a block of emacs-lisp code with Babel." |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
58 (save-window-excursion |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
59 (let ((processed-params (org-babel-process-params params))) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
60 (org-babel-reassemble-table |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
61 (eval (read (format "(progn %s)" |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
62 (org-babel-expand-body:emacs-lisp |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
63 body params processed-params)))) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
64 (org-babel-pick-name (nth 4 processed-params) (cdr (assoc :colnames params))) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
65 (org-babel-pick-name (nth 5 processed-params) (cdr (assoc :rownames params))))))) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
66 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
67 (provide 'ob-emacs-lisp) |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
68 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
69 ;; arch-tag: e9a3acca-dc84-472a-9f5a-23c35befbcd6 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
70 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
71 ;;; ob-emacs-lisp.el ends here |