Subject: 25.0.50; [PATCH] Make (S)CSS mode require final newline

From: Simen Heggestøyl <[email-masked]>
Date: Sun, 29 Mar 2015 23:15:10 +0200

This patch makes CSS mode and its sister mode, SCSS mode, require
final newlines. I was surprised to find that the modes didn't do this
already. I think that final newlines play nicer with version control
systems such as Git, in that adding new lines won't be interpreted as
changes to the line that used to be last. Final newlines are also
mandated by at least one SCSS linter [1].

By the way, maybe it would make sense for CSS mode to derive from
`prog-mode' instead of `fundamental-mode'? With this patch, it is
already setting `require-final-newline' and
`parse-sexp-ignore-comments'. I can see that it used to derive from
`prog-mode', but this was changed in 2007 by Glenn Morris. Glenn, can
you remember the reason for this change?

[1] https://github.com/causes/scss-lint

 From e960348b679ba5743743afc7a0fdd3f55b098358 Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= <[email-masked]>
Date: Sun, 29 Mar 2015 22:50:19 +0200
Subject: [PATCH] Make (S)CSS mode require final newline

* textmodes/css-mode.el (css-mode): Require final newline.
---
 lisp/ChangeLog             | 4 ++++
 lisp/textmodes/css-mode.el | 1 +
 2 files changed, 5 insertions(+)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c8e84a3..babdbde 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-29  Simen Heggestøyl  <[email-masked]>
+
+	* textmodes/css-mode.el (css-mode): Require final newline.
+
 2015-03-28  Jan Djärv  <[email-masked]>

 	* emacs-lisp/package.el (package-refresh-contents): Fix spelling
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index 3e7612a..6004d84 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -372,6 +372,7 @@ pseudo-classes, and at-rules."
 ;;;###autoload
 (define-derived-mode css-mode fundamental-mode "CSS"
   "Major mode to edit Cascading Style Sheets."
+  (setq-local require-final-newline mode-require-final-newline)
   (setq-local font-lock-defaults css-font-lock-defaults)
   (setq-local comment-start "/*")
   (setq-local comment-start-skip "/\\*+[ \t]*")
-- 
2.1.4