summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-11-24 23:24:25 (GMT)
committer Nicolas Goaziou <n.goaziou@gmail.com>2012-11-24 23:24:25 (GMT)
commitb7053b5f9c42095ea3bd636d0e7eb736abf8e730 (patch)
tree4281412ba93aed026a6de54839737200f5193049
parent2f4c85e6b4bc7ae9e7f0f2481ef3f31758f260ee (diff)
downloadorg-mode-b7053b5f9c42095ea3bd636d0e7eb736abf8e730.zip
org-mode-b7053b5f9c42095ea3bd636d0e7eb736abf8e730.tar.gz
org-export: Fix Babel unresolved references error
* contrib/lisp/org-export.el (org-export-execute-babel-code): New function. (org-export-as): Use new function.
-rw-r--r--contrib/lisp/org-export.el20
1 files changed, 13 insertions, 7 deletions
diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el
index 841eee0..e822765 100644
--- a/contrib/lisp/org-export.el
+++ b/contrib/lisp/org-export.el
@@ -2595,13 +2595,7 @@ Return code as a string."
;; have added some new ones.
(org-macro-initialize-templates)
(org-macro-replace-all org-macro-templates)
- ;; TODO: Setting `org-current-export-file' is required by
- ;; Org Babel to properly resolve noweb references. Once
- ;; "org-exp.el" is removed, modify
- ;; `org-export-blocks-preprocess' so it accepts the value
- ;; as an argument instead.
- (let ((org-current-export-file (current-buffer)))
- (org-export-blocks-preprocess)))
+ (org-export-execute-babel-code))
;; Update radio targets since keyword inclusion might have
;; added some more.
(org-update-radio-target-regexp)
@@ -2929,6 +2923,18 @@ file should have."
(insert (make-string offset ?*)))))))))))
(org-element-normalize-string (buffer-string))))
+(defun org-export-execute-babel-code ()
+ "Execute every Babel code in the visible part of current buffer.
+This function will return an error if the current buffer is
+visiting a file."
+ ;; Get a pristine copy of current buffer so Babel references can be
+ ;; properly resolved.
+ (let* (clone-buffer-hook (reference (clone-buffer)))
+ (unwind-protect (let ((org-current-export-file reference))
+ (org-export-blocks-preprocess))
+ (kill-buffer reference))))
+
+
;;; Tools For Back-Ends
;;