Hi, Thanks for the feedback. It seems that the test didn't run on my local machine due to the absence of Java. Basically, such test cases are failing because I removed the =org-trim=, so some of the existing ob functions that are careless about blank lines are revealed now. I tried to fix some others (in ob-sql and ob-sqlite) as well, but if I miss some, it should all be easy fix.
> The code still feels a bit weird to me, but I do not see any counterexamples. Yeah the tangling logic is kinda a mess, so the reverse is even worse... :x Admittedly, I also found new bugs in Noweb-involved detangling and had to fix them in the newly attached patches. Of course, I can't say there's no more. But the bottomline is that, it's already **way better** than the current =org-babel-detangle= - there's nothing to lose. We'll see. MT On Sun, Mar 15, 2026, at 15:08, Ihor Radchenko wrote: > MT <[email protected]> writes: > > > 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: > > ... > > Ok, got it. > The code still feels a bit weird to me, but I do not see any counterexamples. > > I applied the first 2 patches onto main (others do not apply), and there > is one test failing: > > 1 unexpected results: > FAILED ob-java/tangle ((should (string= "public class Tangle {\n > public static void main(String[] args) {\n return \"tangled\";\n > }\n}\n" (unwind-protect (progn (org-babel-tangle) (with-temp-buffer ... ... > ...)) (delete-file "Tangle.java")))) :form (string= "public class Tangle {\n > public static void main(String[] args) {\n return \"tangled\";\n > }\n}\n" "\npublic class Tangle {\n public static void main(String[] args) > {\n return \"tangled\";\n }\n}\n") :value nil :explanation > (arrays-of-different-length 101 102 "public class Tangle {\n public static > void main(String[] args) {\n return \"tangled\";\n }\n}\n" > "\npublic class Tangle {\n public static void main(String[] args) {\n > return \"tangled\";\n }\n}\n" first-mismatch-at 0)) > > -- > 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
