Guess I made some mistake in the fix... but here's the idea: In the first two patches, the main change is that we removed =org-trim= (which removes all the trailing empty lines in tangled blocks blindly) since it 1) eats all the intentionally left blank lines 2) leads to incorrect/ambiguous tangling behavior that makes it non-revertible for detangling (cuz detangling needs to infer the body content from the tangled result).
Then, this will have a series of impacts on tests written on top of the assumption that they can carelessly add surrounding blank lines as the =org-trim= will do the cleanup. Also, some of the tangling functions for each language also add trailing blank lines, e.g., via string joining with "\n". What I'm trying to do is to fix these reckless implementations to not add the incorrect new lines. Hope this explains. MT On Sat, Mar 28, 2026, at 11:01, Ihor Radchenko wrote: > MT <[email protected]> writes: > > > 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. > > I applied the first two patches and the test is still failing for me. > > (ert-test-failed > ((should > (string= > "package tangle;\n\npublic class Tangle {\n public static void > main(String[] args) {\n return \"tangled\";\n }\n}\n" > (unwind-protect ... ... ...))) > :form > (string= > "package tangle;\n\npublic class Tangle {\n public static void > main(String[] args) {\n return \"tangled\";\n }\n}\n" > "package tangle;\npublic class Tangle {\n public static void > main(String[] args) {\n return \"tangled\";\n }\n}\n") > :value nil :explanation > (arrays-of-different-length 118 117 > "package tangle;\n\npublic class Tangle {\n public static void > main(String[] args) {\n return \"tangled\";\n }\n}\n" > "package tangle;\npublic class Tangle {\n public static void > main(String[] args) {\n return \"tangled\";\n }\n}\n" > first-mismatch-at 16))) > FAILED 128/1460 ob-java/tangle-with-package (0.003503 sec) at > ../lisp/test-ob-java.el:596 > > The original test looks like > > (string= > "package tangle; > > public class Tangle { > public static void main(String[] args) { > return \"tangled\"; > } > } > " > (unwind-protect ...)) > > Could you please explain why you removed the blank line before class > declaration in the patch? > > > diff --git a/lisp/ob-java.el b/lisp/ob-java.el > > index ec0c99b5d..3657ca6dc 100644 > > --- a/lisp/ob-java.el > > +++ b/lisp/ob-java.el > > @@ -367,7 +367,8 @@ is simplest to expand the code block from the inside > > out." > > (when (not (re-search-forward org-babel-java--class-re nil t)) > > (org-babel-java--move-past org-babel-java--package-re) ; if > > package is defined, move past it > > (org-babel-java--move-past org-babel-java--imports-re) ; if > > imports are defined, move past them > > - (insert (concat "\npublic class " (file-name-base classname) " > > {\n")) > > + (unless (bobp) (insert "\n")) > > + (insert (concat "public class " (file-name-base classname) " {\n")) > > -- > 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> >
