Bruno Barbier <brubar...@gmail.com> writes: > The change seems to come from this commit: > > commit d7a55bbd537314d2776b082bd92a1a08b3edc84e > Date: Wed Sep 28 12:07:14 2022 +0800 > org-latex-export-to-latex: Do not suppress major modes in babel > > It replaces 'write-file' with 'write-region', but, according to the > documentation of 'require-final-newline', 'write-region' ignores > 'require-final-newline'.
Thanks for narrowing down the cause! We indeed cannot revert the commit - the change was made for a reason. > See attached diff that reverts the problematic change. > > In summary, before this commit, Emacs was fixing exported text files > (HTML, markdown, etc.) for free, adding a newline if needed for text > files. It's not anymore. I'm not sure what would be the best way to > fix this though. I do not think that we need to honour `require-final-newline' during export - this was (1) not documented; (2) caused inconsistency when exporting with different user configs. However, we indeed changed the existing behaviour. AFAIU, `require-final-newline' is t by default, except binary data. Also, Org export is not designed to generate binary output. So, it should be OK to ensure the final newline manually, in `org-export-to-file' - to minimize possible breakage. -- Ihor Radchenko // yantar92, Org mode contributor, 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>