unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Simen Heggestøyl" <simenheg@gmail.com>
To: 20226@debbugs.gnu.org
Subject: bug#20226: 25.0.50; [PATCH] Make (S)CSS mode require final newline
Date: Sun, 29 Mar 2015 23:15:10 +0200	[thread overview]
Message-ID: <1427663710.9451.0@smtp.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2015-03-29 21:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-29 21:15 Simen Heggestøyl [this message]
2015-03-30  1:06 ` bug#20226: 25.0.50; [PATCH] Make (S)CSS mode require final newline 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1427663710.9451.0@smtp.gmail.com \
    --to=simenheg@gmail.com \
    --cc=20226@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).