emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org cb8bf4a0d0: org-babel-expand-references: Fix :noweb


From: ELPA Syncer
Subject: [elpa] externals/org cb8bf4a0d0: org-babel-expand-references: Fix :noweb-ref expansion
Date: Sat, 17 Sep 2022 03:57:51 -0400 (EDT)

branch: externals/org
commit cb8bf4a0d0262772624e4427e95d8ff4ced0f111
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>

    org-babel-expand-references: Fix :noweb-ref expansion
    
    * lisp/ob-core.el (org-babel-expand-noweb-references): Do not rely on
    reference cache being populated as a condition that all the references
    in buffer have been processed.  Set this information explicitly.
    * testing/lisp/test-ob.el (test-ob/noweb-expansion): Add new test.
---
 lisp/ob-core.el         |  4 +++-
 testing/lisp/test-ob.el | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 9843bb53a9..8a963fa8e2 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2994,7 +2994,8 @@ block but are passed literally to the \"example-block\"."
                      ;; run.  Yet, ID is not in cache (see the above
                      ;; condition).  Process missing reference in
                      ;; `expand-references'.
-                     ((hash-table-p org-babel-expand-noweb-references--cache)
+                     ((and (hash-table-p 
org-babel-expand-noweb-references--cache)
+                            (gethash 'buffer-processed 
org-babel-expand-noweb-references--cache))
                       (expand-references id))
                      ;; Though luck.  We go into the long process of
                      ;; checking each source block and expand those
@@ -3010,6 +3011,7 @@ block but are passed literally to the \"example-block\"."
                            (let* ((info (org-babel-get-src-block-info t))
                                   (ref (cdr (assq :noweb-ref (nth 2 info)))))
                              (push info (gethash ref 
org-babel-expand-noweb-references--cache))))))
+                       (puthash 'buffer-processed t 
org-babel-expand-noweb-references--cache)
                       (expand-references id)))))
               ;; Interpose PREFIX between every line.
                (if noweb-prefix
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index 7fa330fe14..99912fe639 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -883,7 +883,52 @@ x
 #+begin_src emacs-lisp :noweb yes<point>
 <<AA>>
 #+end_src"
-           (org-babel-expand-noweb-references)))))
+           (org-babel-expand-noweb-references))))
+  ;; Test :noweb-ref expansion.
+  (should
+   (equal "(message \"!! %s\" \"Running confpkg-test-setup\")
+
+(message \"- Ran `%s'\" 'confpkg-test-strip-package-statements)
+
+(message \"!! %s\" \"Still running confpkg-test-setup\")
+
+(message \"- Ran elisp blocks in `%s'\" 'confpkg-test-dependency-analysis)
+
+(message \"!! %s\" \"End of confpkg-test-setup\")"
+          (org-test-with-temp-text "
+* Setup
+
+#+name: confpkg-test-setup
+#+begin_src emacs-lisp :results silent :noweb no-export
+(message \"!! %s\" \"Running confpkg-test-setup\")
+
+<<confpkg-test-strip-package-statements>>
+
+(message \"!! %s\" \"Still running confpkg-test-setup\")
+
+<<confpkg-test-dependency-analysis>>
+
+(message \"!! %s\" \"End of confpkg-test-setup\")
+#+end_src
+
+#+call: confpkg-test-setup[:results none]()
+
+* Identify cross-package dependencies
+
+#+begin_src emacs-lisp :noweb-ref confpkg-test-dependency-analysis
+(message \"- Ran elisp blocks in `%s'\" 'confpkg-test-dependency-analysis)
+#+end_src
+
+* Commenting out ~package!~ statements
+
+#+name: confpkg-test-strip-package-statements
+#+begin_src emacs-lisp
+(message \"- Ran `%s'\" 'confpkg-test-strip-package-statements)
+#+end_src
+"
+            (goto-char (point-min))
+            (search-forward "begin_src")
+            (org-babel-expand-noweb-references)))))
 
 (ert-deftest test-ob/splitting-variable-lists-in-references ()
   (org-test-with-temp-text ""



reply via email to

[Prev in Thread] Current Thread [Next in Thread]