Subject: bug#34986: write-region not governed by require-final-newline

From: "Basil L. Contovounesios" <[email-masked]>
Date: Mon, 25 Mar 2019 04:08:38 +0000

積丹尼 Dan Jacobson <[email-masked]> writes:

> User, despite setting
>  require-final-newline t
> in .emacs, still finds he is often creating files without final
> newlines.
>
> It turns out write-region, which he often uses, is not governed by
> require-final-newline.
>
> I though the whole logic of require-final-newline was to help people add
> those newlines.

The user option require-final-newline is relevant only when visiting
files, not when writing to arbitrary ones, so you probably want to use
save-buffer instead of write-region or similar.

See (info "(emacs) Visiting"), (info "(emacs) Customize Save"), and
(info "(elisp) Saving Buffers").

-- 
Basil