summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2020-09-15 00:07:03 -0400
committerKyle Meyer <kyle@kyleam.com>2020-09-15 23:45:16 -0400
commit469ee6340149e80e037ba9730f62fbe0c36a9651 (patch)
tree431d2e98647a6344b20d5c8a4adb06ddaf28014e
parent7dbd749bf8e3e59de68dee702a2a98c44e651ab9 (diff)
downloadorg-mode-469ee6340149e80e037ba9730f62fbe0c36a9651.tar.gz
ob-core: Fix handling of multiple noweb refs in same line
* lisp/ob-core.el (org-babel-expand-noweb-references): Don't anchor noweb regexp at start of line to allow multiple matches per line. * testing/lisp/test-ob-tangle.el (ob-tangle/multiple-noweb-in-line): Add test. This fixes a regression introduced by c1aed9f80 (ob-core: Refactor `org-babel-expand-noweb-references', 2020-01-12), which was part of the 9.4 release. Reported-by: Tom Gillespie <tgbugs@gmail.com> Ref: https://orgmode.org/list/CA+G3_PO2yO1jMMpdrkc39BGQQ2eU5X4FzTEJVotjDJo-50dsqQ@mail.gmail.com
-rw-r--r--lisp/ob-core.el2
-rw-r--r--testing/lisp/test-ob-tangle.el32
2 files changed, 33 insertions, 1 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index a5e079d..7300f23 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2781,7 +2781,7 @@ block but are passed literally to the \"example-block\"."
(lang (nth 0 info))
(body (nth 1 info))
(comment (string= "noweb" (cdr (assq :comments (nth 2 info)))))
- (noweb-re (format "^\\(.*?\\)\\(%s\\)"
+ (noweb-re (format "\\(.*?\\)\\(%s\\)"
(with-current-buffer parent-buffer
(org-babel-noweb-wrap))))
(cache nil)
diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el
index e0e2ea5..cfdf16d 100644
--- a/testing/lisp/test-ob-tangle.el
+++ b/testing/lisp/test-ob-tangle.el
@@ -420,6 +420,38 @@ another block
(org-split-string (buffer-string))))
(delete-file file))))))
+(ert-deftest ob-tangle/multiple-noweb-in-line ()
+ "Test handling of multiple noweb references in a single line."
+ (should
+ (equal '("1" "2" "1")
+ (let ((file (make-temp-file "org-tangle-")))
+ (unwind-protect
+ (progn
+ (org-test-with-temp-text-in-file
+ (format "
+#+name: block1
+#+begin_src elisp
+1
+#+end_src
+
+#+name: block2
+#+begin_src elisp
+2
+#+end_src
+
+#+name: block3
+#+begin_src elisp :noweb yes :tangle %s
+<<block1>> <<block2>> <<block1>>
+#+end_src"
+ file)
+ (let ((org-babel-noweb-error-all-langs nil)
+ (org-babel-noweb-error-langs nil))
+ (org-babel-tangle)))
+ (with-temp-buffer
+ (insert-file-contents file)
+ (org-split-string (buffer-string))))
+ (delete-file file))))))
+
(ert-deftest ob-tangle/detangle-false-positive ()
"Test handling of false positive link during detangle."
(let (buffer)