annotate lisp/org/ob-exp.el @ 110804:30fed27e97bc

Merge changes made in Gnus trunk. nnimap.el (nnimap-request-rename-group): Add this method. shr.el: Keep track of the natural width of TD elements, so we know which ones to expand. shr.el: Expand TD elements to fill available space.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Thu, 07 Oct 2010 11:46:01 +0000
parents a150e8a14679
children 5cb272c831e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109462
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
1 ;;; ob-exp.el --- Exportation of org-babel source blocks
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, Dan Davison
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 ;; See the online documentation for more information
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 ;; http://orgmode.org/worg/org-contrib/babel/
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
30
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
31 ;;; Code:
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
32 (require 'ob)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
33 (require 'org-exp-blocks)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
34 (eval-when-compile
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
35 (require 'cl))
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 (defvar obe-marker nil)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
38 (defvar org-current-export-file)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
39 (defvar org-babel-lob-one-liner-regexp)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
40 (defvar org-babel-ref-split-regexp)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
41 (declare-function org-babel-lob-get-info "ob-lob" ())
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
42 (declare-function org-babel-ref-literal "ob-ref" (ref))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
43
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
44 (add-to-list 'org-export-interblocks '(src org-babel-exp-inline-src-blocks))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
45 (add-to-list 'org-export-interblocks '(lob org-babel-exp-lob-one-liners))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
46 (add-hook 'org-export-blocks-postblock-hook 'org-exp-res/src-name-cleanup)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
47
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
48 (org-export-blocks-add-block '(src org-babel-exp-src-blocks nil))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
49
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
50 (defcustom org-export-babel-evaluate t
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
51 "Switch controlling code evaluation during export.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
52 When set to nil no code will be exported as part of the export
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
53 process."
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
54 :group 'org-babel
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
55 :type 'boolean)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
56 (put 'org-export-babel-evaluate 'safe-local-variable (lambda (x) (eq x nil)))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
57
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
58 (defvar org-babel-function-def-export-keyword "function"
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
59 "The keyword to substitute for the source name line on export.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
60 When exporting a source block function, this keyword will
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
61 appear in the exported version in the place of source name
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
62 line. A source block is considered to be a source block function
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
63 if the source name is present and is followed by a parenthesized
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
64 argument list. The parentheses may be empty or contain
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
65 whitespace. An example is the following which generates n random
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
66 \(uniform) numbers.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
67
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
68 #+source: rand(n)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
69 #+begin_src R
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
70 runif(n)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
71 #+end_src")
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
72
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
73 (defvar org-babel-function-def-export-indent 4
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
74 "Number of characters to indent a source block on export.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
75 When exporting a source block function, the block contents will
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
76 be indented by this many characters. See
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
77 `org-babel-function-def-export-name' for the definition of a
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
78 source block function.")
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
79
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
80 (defun org-babel-exp-src-blocks (body &rest headers)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
81 "Process source block for export.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
82 Depending on the 'export' headers argument in replace the source
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
83 code block with...
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
84
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
85 both ---- display the code and the results
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
86
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
87 code ---- the default, display the code inside the block but do
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
88 not process
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
89
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
90 results - just like none only the block is run on export ensuring
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
91 that it's results are present in the org-mode buffer
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
92
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
93 none ----- do not display either code or results upon export"
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
94 (interactive)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
95 (message "org-babel-exp processing...")
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
96 (save-excursion
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
97 (goto-char (match-beginning 0))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
98 (let* ((info (org-babel-get-src-block-info))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
99 (params (nth 2 info)))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
100 ;; bail if we couldn't get any info from the block
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
101 (when info
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
102 ;; expand noweb references in the original file
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
103 (setf (nth 1 info)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
104 (if (and (cdr (assoc :noweb params))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
105 (string= "yes" (cdr (assoc :noweb params))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
106 (org-babel-expand-noweb-references
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
107 info (get-file-buffer org-current-export-file))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
108 (nth 1 info))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
109 (org-babel-exp-do-export info 'block))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
110
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
111 (defun org-babel-exp-inline-src-blocks (start end)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
112 "Process inline source blocks between START and END for export.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
113 See `org-babel-exp-src-blocks' for export options, currently the
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
114 options and are taken from `org-babel-default-inline-header-args'."
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
115 (interactive)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
116 (save-excursion
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
117 (goto-char start)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
118 (while (and (< (point) end)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
119 (re-search-forward org-babel-inline-src-block-regexp end t))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
120 (let* ((info (save-match-data (org-babel-parse-inline-src-block-match)))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
121 (params (nth 2 info))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
122 (replacement
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
123 (save-match-data
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
124 (if (org-babel-in-example-or-verbatim)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
125 (buffer-substring (match-beginning 0) (match-end 0))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
126 ;; expand noweb references in the original file
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
127 (setf (nth 1 info)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
128 (if (and (cdr (assoc :noweb params))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
129 (string= "yes" (cdr (assoc :noweb params))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
130 (org-babel-expand-noweb-references
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
131 info (get-file-buffer org-current-export-file))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
132 (nth 1 info)))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
133 (org-babel-exp-do-export info 'inline)))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
134 (setq end (+ end (- (length replacement) (length (match-string 1)))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
135 (replace-match replacement t t nil 1)))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
136
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
137 (defun org-exp-res/src-name-cleanup ()
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
138 "Clean up #+results and #+srcname lines for export.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
139 This function should only be called after all block processing
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
140 has taken place."
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
141 (interactive)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
142 (save-excursion
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
143 (goto-char (point-min))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
144 (while (org-re-search-forward-unprotected
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
145 (concat
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
146 "\\("org-babel-src-name-regexp"\\|"org-babel-result-regexp"\\)")
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
147 nil t)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
148 (delete-region
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
149 (progn (beginning-of-line) (point))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
150 (progn (end-of-line) (+ 1 (point)))))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
151
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
152 (defun org-babel-in-example-or-verbatim ()
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
153 "Return true if point is in example or verbatim code.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
154 Example and verbatim code include escaped portions of
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
155 an org-mode buffer code that should be treated as normal
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
156 org-mode text."
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
157 (or (org-in-indented-comment-line)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
158 (save-excursion
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
159 (save-match-data
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
160 (goto-char (point-at-bol))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
161 (looking-at "[ \t]*:[ \t]")))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
162 (org-in-regexps-block-p "^[ \t]*#\\+begin_src" "^[ \t]*#\\+end_src")))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
163
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
164 (defun org-babel-exp-lob-one-liners (start end)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
165 "Process Library of Babel calls between START and END for export.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
166 See `org-babel-exp-src-blocks' for export options. Currently the
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
167 options are taken from `org-babel-default-header-args'."
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
168 (interactive)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
169 (let (replacement)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
170 (save-excursion
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
171 (goto-char start)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
172 (while (and (< (point) end)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
173 (re-search-forward org-babel-lob-one-liner-regexp nil t))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
174 (setq replacement
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
175 (let ((lob-info (org-babel-lob-get-info)))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
176 (save-match-data
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
177 (org-babel-exp-do-export
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
178 (list "emacs-lisp" "results"
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
179 (org-babel-merge-params
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
180 org-babel-default-header-args
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
181 (org-babel-parse-header-arguments
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
182 (org-babel-clean-text-properties
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
183 (concat ":var results="
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
184 (mapconcat #'identity
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
185 (butlast lob-info) " ")))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
186 (car (last lob-info)))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
187 'lob))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
188 (setq end (+ end (- (length replacement) (length (match-string 0)))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
189 (replace-match replacement t t)))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
190
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
191 (defun org-babel-exp-do-export (info type)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
192 "Return a string with the exported content of a code block.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
193 The function respects the value of the :exports header argument."
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
194 (flet ((silently () (let ((session (cdr (assoc :session (nth 2 info)))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
195 (when (and session
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
196 (not (equal "none" session))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
197 (not (assoc :noeval (nth 2 info))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
198 (org-babel-exp-results info type 'silent))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
199 (clean () (org-babel-remove-result info)))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
200 (case (intern (or (cdr (assoc :exports (nth 2 info))) "code"))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
201 ('none (silently) (clean) "")
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
202 ('code (silently) (clean) (org-babel-exp-code info type))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
203 ('results (org-babel-exp-results info type))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
204 ('both (concat (org-babel-exp-code info type)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
205 "\n\n"
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
206 (org-babel-exp-results info type))))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
207
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
208 (defvar backend)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
209 (defun org-babel-exp-code (info type)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
210 "Prepare and return code in the current code block for export.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
211 Code is prepared in a manner suitable for exportat by
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
212 org-mode. This function is called by `org-babel-exp-do-export'.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
213 The code block is not evaluated."
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
214 (let ((lang (nth 0 info))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
215 (body (nth 1 info))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
216 (switches (nth 3 info))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
217 (name (nth 4 info))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
218 (args (mapcar
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
219 #'cdr
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
220 (org-remove-if-not (lambda (el) (eq :var (car el))) (nth 2 info)))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
221 (case type
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
222 ('inline (format "=%s=" body))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
223 ('block
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
224 (let ((str
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
225 (format "#+BEGIN_SRC %s %s\n%s%s#+END_SRC\n" lang switches body
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
226 (if (and body (string-match "\n$" body))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
227 "" "\n"))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
228 (when name
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
229 (add-text-properties
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
230 0 (length str)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
231 (list 'org-caption
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
232 (format "%s(%s)"
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
233 name
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
234 (mapconcat #'identity args ", ")))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
235 str))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
236 str))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
237 ('lob
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
238 (let ((call-line (and (string-match "results=" (car args))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
239 (substring (car args) (match-end 0)))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
240 (cond
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
241 ((eq backend 'html)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
242 (format "\n#+HTML: <label class=\"org-src-name\">%s</label>\n"
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
243 call-line))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
244 ((format ": %s\n" call-line))))))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
245
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
246 (defun org-babel-exp-results (info type &optional silent)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
247 "Evaluate and return the results of the current code block for export.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
248 Results are prepared in a manner suitable for export by org-mode.
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
249 This function is called by `org-babel-exp-do-export'. The code
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
250 block will be evaluated. Optional argument SILENT can be used to
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
251 inhibit insertion of results into the buffer."
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
252 (if org-export-babel-evaluate
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
253 (let ((lang (nth 0 info))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
254 (body (nth 1 info))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
255 (params
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
256 ;; lets ensure that we lookup references in the original file
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
257 (mapcar
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
258 (lambda (pair)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
259 (if (and org-current-export-file
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
260 (eq (car pair) :var)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
261 (string-match org-babel-ref-split-regexp (cdr pair))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
262 (equal :ob-must-be-reference
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
263 (org-babel-ref-literal
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
264 (match-string 2 (cdr pair)))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
265 `(:var . ,(concat (match-string 1 (cdr pair))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
266 "=" org-current-export-file
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
267 ":" (match-string 2 (cdr pair))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
268 pair))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
269 (nth 2 info))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
270 ;; skip code blocks which we can't evaluate
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
271 (if (fboundp (intern (concat "org-babel-execute:" lang)))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
272 (case type
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
273 ('inline
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
274 (let ((raw (org-babel-execute-src-block
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
275 nil info '((:results . "silent"))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
276 (result-params (split-string
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
277 (cdr (assoc :results params)))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
278 (unless silent
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
279 (cond ;; respect the value of the :results header argument
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
280 ((member "file" result-params)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
281 (org-babel-result-to-file raw))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
282 ((or (member "raw" result-params)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
283 (member "org" result-params))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
284 (format "%s" raw))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
285 ((member "code" result-params)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
286 (format "src_%s{%s}" lang raw))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
287 (t
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
288 (if (stringp raw)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
289 (if (= 0 (length raw)) "=(no results)="
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
290 (format "%s" raw))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
291 (format "%S" raw)))))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
292 ('block
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
293 (org-babel-execute-src-block
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
294 nil info (org-babel-merge-params
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
295 params
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
296 `((:results . ,(if silent "silent" "replace")))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
297 "")
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
298 ('lob
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
299 (save-excursion
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
300 (re-search-backward org-babel-lob-one-liner-regexp nil t)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
301 (org-babel-execute-src-block
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
302 nil info (org-babel-merge-params
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
303 params
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
304 `((:results . ,(if silent "silent" "replace")))))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
305 "")))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
306 ""))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
307 ""))
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
308
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
309 (provide 'ob-exp)
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
310
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
311 ;; arch-tag: 523abf4c-76d1-44ed-9f27-e3bddf34bf0f
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
312
a150e8a14679 Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff changeset
313 ;;; ob-exp.el ends here