diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el index 841eee0cc..e8227650f 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 ;;