Browse Source

Merge branch 'maint'

Nicolas Goaziou 1 year ago
parent
commit
774e553f11
2 changed files with 40 additions and 2 deletions
  1. 3 1
      lisp/ob-core.el
  2. 37 1
      testing/lisp/test-ob.el

+ 3 - 1
lisp/ob-core.el

@@ -2790,7 +2790,9 @@ block but are passed literally to the \"example-block\"."
 			    (lambda (i)
 			      ;; Expand body of code blocked
 			      ;; represented by block info I.
-			      (let ((b (org-babel-expand-noweb-references i)))
+			      (let ((b (if (org-babel-noweb-p (nth 2 i) :eval)
+					   (org-babel-expand-noweb-references i)
+					 (nth 1 i))))
 				(if (not comment) b
 				  (let ((cs (org-babel-tangle-comment-links i)))
 				    (concat (funcall c-wrap (car cs)) "\n"

+ 37 - 1
testing/lisp/test-ob.el

@@ -721,7 +721,43 @@ x
 #+begin_src sh :noweb-sep \"\"
   (+ 1 1)
 #+end_src"
-      (org-babel-expand-noweb-references)))))
+      (org-babel-expand-noweb-references))))
+  ;; Handle recursive expansion.
+  (should
+   (equal "baz"
+	  (org-test-with-temp-text "
+#+begin_src emacs-lisp :noweb yes<point>
+  <<foo>>
+#+end_src
+
+#+name: foo
+#+begin_src emacs-lisp :noweb yes
+  <<bar>>
+#+end_src
+
+#+name: bar
+#+begin_src emacs-lisp
+  baz
+#+end_src"
+	    (org-babel-expand-noweb-references))))
+  ;; During recursive expansion, obey to `:noweb' property.
+  (should
+   (equal "<<bar>>"
+	  (org-test-with-temp-text "
+#+begin_src emacs-lisp :noweb yes<point>
+  <<foo>>
+#+end_src
+
+#+name: foo
+#+begin_src emacs-lisp :noweb no
+  <<bar>>
+#+end_src
+
+#+name: bar
+#+begin_src emacs-lisp
+  baz
+#+end_src"
+	    (org-babel-expand-noweb-references)))))
 
 (ert-deftest test-ob/splitting-variable-lists-in-references ()
   (org-test-with-temp-text ""