summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2010-06-08 14:07:12 -0700
committerEric Schulte <schulte.eric@gmail.com>2010-06-08 14:40:50 -0700
commitae234f787b3b797fa99a862e7f2ee2da314778c9 (patch)
treef9bc296ef5b48ae6fa1b64ec9d69ed6d4917b181
parentcdc70ed68d05730b0f5689713acf4bff20c22898 (diff)
downloadorg-mode-ae234f787b3b797fa99a862e7f2ee2da314778c9.tar.gz
babel: noweb references are now expanded in the pre-export buffer
this is required because in the temporary org-mode file used during export code blocks may be removed entirely leading to unresolved references * contrib/babel/lisp/org-babel-exp.el (org-babel-exp-src-blocks): expanding noweb references during export now takes place in the pre-export buffer (org-babel-exp-inline-src-blocks): expanding noweb references during export now takes place in the pre-export buffer (org-babel-exp-results): ensure that the expanded body is passed through to org-babel-execute-src-block
-rw-r--r--contrib/babel/lisp/org-babel-exp.el36
1 files changed, 28 insertions, 8 deletions
diff --git a/contrib/babel/lisp/org-babel-exp.el b/contrib/babel/lisp/org-babel-exp.el
index e279154..413e660 100644
--- a/contrib/babel/lisp/org-babel-exp.el
+++ b/contrib/babel/lisp/org-babel-exp.el
@@ -76,7 +76,17 @@ none ----- do not display either code or results upon export"
(when (member (first headers) org-babel-interpreters)
(save-excursion
(goto-char (match-beginning 0))
- (org-babel-exp-do-export (org-babel-get-src-block-info) 'block))))
+ (let* ((info (org-babel-get-src-block-info))
+ (params (third info)))
+ (message "info:%S" info)
+ ;; expand noweb references in the original file
+ (setf (second info)
+ (if (and (cdr (assoc :noweb params))
+ (string= "yes" (cdr (assoc :noweb params))))
+ (org-babel-expand-noweb-references
+ info (get-file-buffer org-current-export-file))
+ (second info)))
+ (org-babel-exp-do-export info 'block)))))
(defun org-babel-exp-inline-src-blocks (start end)
"Process inline src blocks between START and END for export.
@@ -88,8 +98,18 @@ options and are taken from `org-babel-defualt-inline-header-args'."
(while (and (< (point) end)
(re-search-forward org-babel-inline-src-block-regexp end t))
(let* ((info (save-match-data (org-babel-parse-inline-src-block-match)))
- (replacement (save-match-data
- (org-babel-exp-do-export info 'inline))))
+ (params (third info))
+ (replacement
+ (save-match-data
+ ;; expand noweb references in the original file
+ (setf (second info)
+ (if (and (cdr (assoc :noweb params))
+ (string= "yes" (cdr (assoc :noweb params))))
+ (org-babel-expand-noweb-references
+ info (get-file-buffer org-current-export-file))
+ (second info)))
+ (message "info:%S" info)
+ (org-babel-exp-do-export info 'inline))))
(setq end (+ end (- (length replacement) (length (match-string 1)))))
(replace-match replacement t t nil 1)))))
@@ -213,16 +233,16 @@ results into the buffer."
(format "=%S=" raw)))))))
('block
(org-babel-execute-src-block
- nil nil (org-babel-merge-params
- params `((:results . ,(if silent "silent" "replace")))))
+ nil info (org-babel-merge-params
+ params `((:results . ,(if silent "silent" "replace")))))
"")
('lob
(save-excursion
(re-search-backward org-babel-lob-one-liner-regexp nil t)
(org-babel-execute-src-block
- nil (list lang body
- (org-babel-merge-params
- params `((:results . ,(if silent "silent" "replace")))))) "")))))
+ nil info (org-babel-merge-params
+ params `((:results . ,(if silent "silent" "replace")))))
+ "")))))
(provide 'org-babel-exp)
;;; org-babel-exp.el ends here