Really apologize for the late response, it's been a draining semester for me. I have read all your comments and fixed a few bugs I discovered when dogfooding, including the misuse of the ob-tangle function you mentioned earlier (thanks for pointing it out!). Please check the attached for the new patches.
Regarding your question > Could you please explain why we do not want to add empty line in all > cases (after interposing the prefix)? What is the logic behind "block > body does not end with noweb reference"? Before: 1. =expand-body= (which calls =add-comment=) adds an empty line at the end of the expansion. (=org-babel-expand-noweb-references=, lisp/ob-core.el). The expanded body is then interposed if Noweb prefix is kept. The result is that, the empty line at the end of the expanded body is also interposed. Consider this example in my commit message: ,#+name: a string ,#+begin_src emacs-lisp "hello" ,#+end_src ,#+begin_src emacs-lisp :tangle tangle-bug.el :noweb yes :comments noweb prefix<<a string>> ,#+end_src tangles to ,#+begin_src emacs-lisp ;; [[file:org-babel-tangle.org::*Incorrect interposition of Noweb prefix when =:comments noweb=][Incorrect interposition of Noweb prefix when =:comments noweb=:2]] prefix;; [[file:org-babel-tangle.org::a string][a string]] prefix"hello" prefix;; a string ends here prefix ;; Incorrect interposition of Noweb prefix when =:comments noweb=:2 ends here ,#+end_src Note the second last line of the tangled result, it is THE empty line added at the end of the expansion, and interposed with the prefix string "prefix". So what's wrong here? The key is that <<a string>> is the last thing in the original code block's body, therefore there should not be any line after it except the end comments. Also, the interposition timing is incorrect, which causes the additional "prefix" after the end comment line. The correct tangled result should be just: ,#+begin_src emacs-lisp ;; [[file:org-babel-tangle.org::*Incorrect interposition of Noweb prefix when =:comments noweb=][Incorrect interposition of Noweb prefix when =:comments noweb=:2]] prefix;; [[file:org-babel-tangle.org::a string][a string]] prefix"hello" prefix;; a string ends here ;; Incorrect interposition of Noweb prefix when =:comments noweb=:2 ends here ,#+end_src The intention in the original code is that, we want the end comment to be on its own line, so the next thing starts on a new line and doesn't get commented by the end comment. However, the original code is being naive about it, the correct logic should be: 1. If the Noweb reference is the last thing in the original code block body, we don't add the \n. 2. If it is not the last thing, we add the \n, but after interposition, not before. Hope I'm explaining this well. Best, MT On Sat, Feb 28, 2026, at 07:13, Ihor Radchenko wrote: > Ihor Radchenko <[email protected]> writes: > > > MT <[email protected]> writes: > > > >> I just finished polishing my code, splitting them into commits, as well as > >> adding/updating a bunch of test cases! Please check the attached for the > >> patch files. > > > > Thanks! > > I will provide some initial comments. > > ... > > It has been a while. Mingtong, did you have a chance to look into my comments? > > -- > Ihor Radchenko // yantar92, > Org mode maintainer, > Learn more about Org mode at <https://orgmode.org/>. > Support Org development at <https://liberapay.com/org-mode>, > or support my work at <https://liberapay.com/yantar92> >
0001-ob-core.el-Fix-incorrect-interposition-of-Noweb-pref.patch
Description: Binary data
0002-ob-tangle.el-Fix-incorrect-trimming-behavior-on-tang.patch
Description: Binary data
0003-ob-core.el-Generate-numbered-names-for-unnamed-Noweb.patch
Description: Binary data
0004-ob-core.el-Enrich-the-Noweb-comments-with-metadata-f.patch
Description: Binary data
0005-ob-tangle.el-Rewrite-Noweb-comment-parsing-and-jump-.patch
Description: Binary data
0006-ob-tangle.el-Rewrite-detangling.patch
Description: Binary data
