Subject: Re: bug#21570: 24.5; prog-mode unconditionally sets require-final-newline

From: Dmitry Gutov <[email-masked]>
Date: Sun, 27 Sep 2015 01:14:05 +0300

On 09/26/2015 12:50 PM, Faye N. wrote:

> While normally I don't have an issue with this sort of thing (I leave mode-require-final-newline on specifically for programs that have yet to handle the lack of final newlines in their input files), the fact that this is in prog-mode seems like a bug to me. prog-mode as I understand it is mainly for other modes to derive from as a starting point, so forcing a final newline in a generic major mode such as this is wrong to me.

prog-mode is the place where the mode-require-final-newline setting 
takes effect, in a centralized fashion.

Regardless of the programming language in question, certain tools that 
one might want to employ for software development interact badly with 
source files that don't end on a newline. Hence it's a good idea to add 
them in source files.

But when it's not the case, a major mode, or the user, can override this 
(in the mode definition, or in a hook).

> I'd suggest either not having prog-mode set this in the first place (leaving it to modes that actually need it to decide), or if prog-mode has to set it, that its doing so be configurable.

Since it's the first such request, I think the degree of customizability 
provided by our hooks facility is enough:

(add-hook 'prog-mode-hook (lambda () (setq require-final-newline ...)))