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

From: "Faye N." <[email-masked]>
Date: Sat, 26 Sep 2015 02:50:00 -0700

In using a mode that inherits from prog-mode (perl6-mode), I found it inserting a newline at the end of my files upon saving, despite having require-final-newline set to nil. After a bit of digging, I found that prog-mode sets require-final-newline to mode-require-final-newline.

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. In my specific case, Perl 6 is not a language that balks at the lack of a final newline, so the use of mode-require-final-newline would be inappropriate for any mode implementing Perl 6 support.

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. It could either be user-configurable for prog-mode via customize, or it could be something a deriving major mode chooses to use (but then again, that would be no better than the deriving mode setting require-final-newline itself in the first place).

In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.28)
of 2015-08-25 on AMD64
Windowing system distributor `The X.Org Foundation', version 11.0.11604000
System Description: NAME=Gentoo

Configured using:
`configure --prefix=/usr --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --mandir=/usr/share/man
--infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc
--localstatedir=/var/lib --disable-dependency-tracking
--disable-silent-rules --libdir=/usr/lib64 --program-suffix=-emacs-24
--infodir=/usr/share/info/emacs-24 --localstatedir=/var
--enable-locallisppath=/etc/emacs:/usr/share/emacs/site-lisp
--with-gameuser=:gamestat --without-compress-install
--with-file-notification=inotify --enable-acl --with-dbus
--without-gnutls --with-gpm --without-hesiod --without-kerberos
--without-kerberos5 --without-xml2 --without-selinux --without-wide-int
--with-zlib --with-sound=alsa --with-x --without-ns --without-gconf
--without-gsettings --with-toolkit-scroll-bars --with-gif --with-jpeg
--with-png --with-rsvg --with-tiff --with-xpm --without-imagemagick
--with-xft --without-libotf --without-m17n-flt --with-x-toolkit=gtk2
GENTOO_PACKAGE=app-editors/emacs-24.5 'CFLAGS=-march=k8 -O2 -pipe'
CPPFLAGS= 'LDFLAGS=-Wl,-O1 -Wl,--as-needed''

Important settings:
value of $LC_COLLATE: C
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix

Major mode: Perl6

Minor modes in effect:
tooltip-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t

Recent messages:
[not relevant]

Load-path shadows:
~/emacsmodes/cperl-mode hides /usr/share/emacs/24.5/lisp/progmodes/cperl-mode

Features:
(shadow sort mail-extr emacsbug sendmail whitespace apropos debug
mule-util epa-file epa epg perl-mode server misearch multi-isearch
cus-edit cus-start cus-load wid-edit vc-git perl6-mode derived
perl6-indent perl6-font-lock smie pcase perl6-detect tar-mode json
find-func epl rx cl-macs gv compile comint ansi-color ring autoload
lisp-mnt mm-archive message format-spec rfc822 mml mml-sec mailabbrev
gmm-utils mailheader mm-decode mm-bodies mm-encode mail-utils
network-stream starttls url-http tls mail-parse rfc2231 rfc2047 rfc2045
ietf-drums url-gw url-cache url-auth url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
mailcap url-handlers url-parse auth-source eieio byte-opt bytecomp
byte-compile cl-extra cconv eieio-core gnus-util mm-util help-fns
mail-prsvr password-cache url-vars finder-inf help-mode easymenu
cmake-mode thingatpt solarized-dark-theme solarized
solarized-theme-autoloads package epg-config site-gentoo edmacro kmacro
cl-loaddefs cl-lib imenu time-date tooltip electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register
page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind inotify
dynamic-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty emacs)

Memory information:
((conses 16 229799 51554)
(symbols 48 28232 0)
(miscs 40 1018 950)
(strings 32 47424 2827)
(string-bytes 1 1311635)
(vectors 16 27286)
(vector-slots 8 1371261 215410)
(floats 8 99 738)
(intervals 56 3990 0)
(buffers 960 29)
(heap 1024 44864 2301))