summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-12-10 00:59:08 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-12-10 00:59:08 +0100
commit00ea6a286c948dfefbbd6e87e6d159e5ea8d17fc (patch)
treecd759dca3c7af508992e01702c1f1d77cb8e2ec3
parent7b148e2d0ea579f851a79c081b7ca520d7dba75d (diff)
downloadorg-mode-00ea6a286c948dfefbbd6e87e6d159e5ea8d17fc.tar.gz
ob-tangle: Fix last commit
* lisp/ob-tangle.el (org-babel-tangle-single-block): `org-babel-expand-noweb-references' specifically needs to be run in the Org document so as to resolve references. * testing/lisp/test-ob-tangle.el (ob-tangle/continued-code-blocks-w-noweb-ref): Make sure a failing test doesn't leave a file behind it.
-rw-r--r--lisp/ob-tangle.el28
-rw-r--r--testing/lisp/test-ob-tangle.el11
2 files changed, 20 insertions, 19 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 87b708c..a5e18a8 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -442,25 +442,25 @@ non-nil, return the full association list to be used by
(intern (concat "org-babel-variable-assignments:" src-lang)))
(body
;; Run the tangle-body-hook.
- (with-temp-buffer
- (insert
- ;; Expand body in language specific manner.
- (let ((body (if (org-babel-noweb-p params :tangle)
- (org-babel-expand-noweb-references info)
- (nth 1 info))))
+ (let ((body (if (org-babel-noweb-p params :tangle)
+ (org-babel-expand-noweb-references info)
+ (nth 1 info))))
+ (with-temp-buffer
+ (insert
+ ;; Expand body in language specific manner.
(cond ((assq :no-expand params) body)
((fboundp expand-cmd) (funcall expand-cmd body params))
(t
(org-babel-expand-body:generic
body params (and (fboundp assignments-cmd)
- (funcall assignments-cmd params)))))))
- (when (string-match "-r" extra)
- (goto-char (point-min))
- (while (re-search-forward
- (replace-regexp-in-string "%s" ".+" cref-fmt) nil t)
- (replace-match "")))
- (run-hooks 'org-babel-tangle-body-hook)
- (buffer-string)))
+ (funcall assignments-cmd params))))))
+ (when (string-match "-r" extra)
+ (goto-char (point-min))
+ (while (re-search-forward
+ (replace-regexp-in-string "%s" ".+" cref-fmt) nil t)
+ (replace-match "")))
+ (run-hooks 'org-babel-tangle-body-hook)
+ (buffer-string))))
(comment
(when (or (string= "both" (cdr (assq :comments params)))
(string= "org" (cdr (assq :comments params))))
diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el
index a656c11..06a73f0 100644
--- a/testing/lisp/test-ob-tangle.el
+++ b/testing/lisp/test-ob-tangle.el
@@ -63,11 +63,12 @@
"df|sed '1d'|awk '{print $5 \" \" $6}'|sort -n |tail -1|awk '{print $2}'"))
(org-narrow-to-subtree)
(org-babel-tangle)
- (with-temp-buffer
- (insert-file-contents "babel.sh")
- (goto-char (point-min))
- (should (re-search-forward (regexp-quote tangled) nil t)))
- (delete-file "babel.sh"))))
+ (should (unwind-protect
+ (with-temp-buffer
+ (insert-file-contents "babel.sh")
+ (goto-char (point-min))
+ (re-search-forward (regexp-quote tangled) nil t))
+ (when (file-exists-p "babel.sh") (delete-file "babel.sh")))))))
(ert-deftest ob-tangle/expand-headers-as-noweb-references ()
"Test that references to headers are expanded during noweb expansion."