unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#20226: 25.0.50; [PATCH] Make (S)CSS mode require final newline
@ 2015-03-29 21:15 Simen Heggestøyl
  2015-03-30  1:06 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Simen Heggestøyl @ 2015-03-29 21:15 UTC (permalink / raw)
  To: 20226

[-- Attachment #1: Type: text/plain, Size: 2156 bytes --]

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@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@gmail.com>
+
+	* textmodes/css-mode.el (css-mode): Require final newline.
+
 2015-03-28  Jan Djärv  <jan.h.d@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



[-- Attachment #2: Type: text/html, Size: 3004 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-03-31 21:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-29 21:15 bug#20226: 25.0.50; [PATCH] Make (S)CSS mode require final newline Simen Heggestøyl
2015-03-30  1:06 ` Stefan Monnier
2015-03-30 20:50   ` Simen Heggestøyl
2015-03-30 22:03     ` Stefan Monnier
2015-03-31 18:05       ` Simen Heggestøyl
2015-03-31 21:12         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).