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.
This commit is contained in:
parent
8cc821bda2
commit
cb8bf4a0d0
|
@ -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
|
||||
|
|
|
@ -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 ""
|
||||
|
|
Loading…
Reference in New Issue