GNU bug report logs - #20226
25.0.50; [PATCH] Make (S)CSS mode require final newline

Previous Next

Package: emacs;

Reported by: Simen Heggestøyl <simenheg <at> gmail.com>

Date: Sun, 29 Mar 2015 21:16:02 UTC

Severity: normal

Tags: patch

Found in version 25.0.50

Done: Simen Heggestøyl <simenheg <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Simen Heggestøyl <simenheg <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Cc: rgm <at> gnu.org
Subject: 25.0.50; [PATCH] Make (S)CSS mode require final newline
Date: Sun, 29 Mar 2015 23:15:10 +0200
[Message part 1 (text/plain, inline)]
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?= <simenheg <at> gmail.com>
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  <simenheg <at> gmail.com>
+
+	* textmodes/css-mode.el (css-mode): Require final newline.
+
2015-03-28  Jan Djärv  <jan.h.d <at> swipnet.se>

	* 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


[Message part 2 (text/html, inline)]

This bug report was last modified 10 years and 52 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.