From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>
Received: from mp10.migadu.com ([2001:41d0:403:478a::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms9.migadu.com with LMTPS
	id kPOwOU72I2U/LAEAG6o9tA:P1
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Mon, 09 Oct 2023 14:47:11 +0200
Received: from aspmx1.migadu.com ([2001:41d0:403:478a::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp10.migadu.com with LMTPS
	id kPOwOU72I2U/LAEAG6o9tA
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Mon, 09 Oct 2023 14:47:11 +0200
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by aspmx1.migadu.com (Postfix) with ESMTPS id 2DC7C779FF
	for <larch@yhetil.org>; Mon,  9 Oct 2023 14:47:10 +0200 (CEST)
Authentication-Results: aspmx1.migadu.com;
	dkim=pass header.d=posteo.net header.s=2017 header.b=ZVk4ibJA;
	dmarc=pass (policy=none) header.from=posteo.net;
	spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org;
	s=key1; t=1696855630;
	h=from:from:sender:sender:reply-to:subject:subject:date:date:
	 message-id:message-id:to:to:cc:cc:mime-version:mime-version:
	 content-type:content-type:in-reply-to:in-reply-to:
	 references:references:list-id:list-help:list-unsubscribe:
	 list-subscribe:list-post:dkim-signature;
	bh=TT/S+jp+udVYRqNpByQUJQzVi2NqByF9TBV2YtDhbeM=;
	b=Ifqjzv18hUl7dVpVr9G9CER5GfH5I24h5YxdTkMzKVlI6YKLTvVq8lUs3sI/1pYpqsae4x
	jFaJgf/oPujRC9sYUP7DVX01oHaRN5VwkBQ4kE21NT64v+u6lMYcl7hoUwHDtCbp1fEBHQ
	ECU8tkw82Vo4TFjqynwmO9XkavxrGH0GJJ9vhAoXt7T1r2tGfdvuYZfR3zSy2OxJS9aUdq
	qjAu+yuISglFMRVVBsnWVpO4gNRfOljXQtX4ePMAZso07YAtHbQH0xujDQUU4r0fcSsLSO
	iStg8/qcuXAoSMAawhlzjywTxVx/rk38DhynfnDJvbh7Q0r6iQPBiq9rHR7hvw==
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1696855630; a=rsa-sha256; cv=none;
	b=c5ccair3x4YLYfRywNCofPcliGA4r2rLNSFGOCmFPd2Z8gdJOy54hz62HaidTjK1BRrVkp
	WnEkMuEB9EdOIZ1J9I2fd9u2IwcOkHbjWjL8JxptyRICM0RmCv4EMllZC6K1A2n2rrHjKC
	43PSEpM6xQF3ciH5PoPxtGqM/G/szmIjhGN445ke4d5SZIzvcNYTF7mRfOzKVr1GxuinC3
	f8UYI2jeR/dQAo6A/M/5c2yhTZIaGlA3AvftLQs9cG+GVVTqfrxsXR5pbqSX8Asr3PaU6E
	6TEidvY4b42IO1uT5O6daH36I7a8oDIobeLp9Q8RZ67KsK0i3eY4o24mbvot0w==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=pass header.d=posteo.net header.s=2017 header.b=ZVk4ibJA;
	dmarc=pass (policy=none) header.from=posteo.net;
	spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-orgmode-bounces@gnu.org>)
	id 1qppeT-0008WO-6h; Mon, 09 Oct 2023 08:46:25 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@posteo.net>)
 id 1qppe4-0008R2-N7
 for emacs-orgmode@gnu.org; Mon, 09 Oct 2023 08:46:01 -0400
Received: from mout02.posteo.de ([185.67.36.66])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@posteo.net>)
 id 1qppdu-0006vx-Lx
 for emacs-orgmode@gnu.org; Mon, 09 Oct 2023 08:45:56 -0400
Received: from submission (posteo.de [185.67.36.169]) 
 by mout02.posteo.de (Postfix) with ESMTPS id 1E240240101
 for <emacs-orgmode@gnu.org>; Mon,  9 Oct 2023 14:45:44 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1696855544; bh=amSVhvqAc9mVnwC3AdWMLfZ5k4ulvIStUv88OePm4CE=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From;
 b=ZVk4ibJAC0rwP2rDVLTvM/EHV4vEPwntOq0XudxqgOJg3FqZAi9KqlNRLl1QJRwwU
 mtxV1QU6QtYE8z4TUS9MJBMqZrXSpv2f/bC0M85GklVveLuMb2VtDfmJBcUItnsLy9
 NcH7pvyFuqkh67hilNi0ggfOZnFGyQaZ7Hy9rVy/wsVJHElvaHo375rPwYMn04KwJh
 oc49gPiY0fgJXUx06rTEtqxfxqI/HN1vXXbqEY91YeMgnW5xPGwMDbsDq6/UCl3Moi
 IP1YFl8LBXJ8v1darMdzvd5+nXLgBHzZm1Rgs1CHj8Et5otfYhSlDneugXZd3iTR7u
 /33B7WTdjIfaw==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4S3zKM1YWrz9s3m;
 Mon,  9 Oct 2023 14:45:43 +0200 (CEST)
From: Ihor Radchenko <yantar92@posteo.net>
To: Bruno Barbier <brubar.cs@gmail.com>
Cc: YE <yet@ego.team>, Max Nikulin <manikulin@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: [BUG] No newline at end of exported HTML file [9.6.6
 (release_9.6.6 @
 /Applications/MacPorts/Emacs.app/Contents/Resources/lisp/org/)]
In-Reply-To: <6523f0cd.5d0a0220.2bb6e.3bfc@mx.google.com>
References: <m2v8bjvjat.fsf@ego.team> <877cny25x4.fsf@localhost>
 <6523f0cd.5d0a0220.2bb6e.3bfc@mx.google.com>
Date: Mon, 09 Oct 2023 12:47:21 +0000
Message-ID: <87wmvwklnq.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net;
 helo=mout02.posteo.de
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: emacs-orgmode@gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
X-Migadu-Flow: FLOW_IN
X-Migadu-Country: US
X-Migadu-Scanner: mx0.migadu.com
X-Migadu-Spam-Score: -7.78
X-Spam-Score: -7.78
X-Migadu-Queue-Id: 2DC7C779FF
X-TUID: XTY1CDKl5Kl2

Bruno Barbier <brubar.cs@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>