all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Simen Heggestøyl" <simenheg@gmail.com>
To: 22508@debbugs.gnu.org
Cc: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#22508: [PATCH] Highlight two additional SCSS keywords
Date: Sun, 31 Jan 2016 22:35:25 +0100	[thread overview]
Message-ID: <1454276125.9296.0@smtp.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 131 bytes --]

Hello!

The attached patch adds highlighting for two additional "bang
identifiers" in SCSS mode: !default and !optional.

-- Simen

[-- Attachment #1.2: Type: text/html, Size: 199 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Highlight-two-additional-SCSS-keywords.patch --]
[-- Type: text/x-patch, Size: 2899 bytes --]

From b9f1b493c36a51024b8fbc2cc9ba302f1437bf4c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= <simenheg@gmail.com>
Date: Sun, 31 Jan 2016 22:03:23 +0100
Subject: [PATCH] Highlight two additional SCSS keywords

* lisp/textmodes/css-mode.el (css-bang-ids): New defconst holding CSS
identifiers on the form !foo.
(scss-bang-ids): New defconst holding SCSS identifiers on the form
!foo.
(css--font-lock-keywords): Highlight the new SCSS bang identifiers in
`font-lock-builtin-face'.

* test/indent/css-mode.css: Add bang rule test case.

* test/indent/scss-mode.css: Add test cases for the introduced bang
rules.
---
 lisp/textmodes/css-mode.el | 12 ++++++++++--
 test/indent/css-mode.css   |  2 +-
 test/indent/scss-mode.scss | 11 ++++++++++-
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index 96a82ba..b3a41d3 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -54,6 +54,14 @@ css-at-ids
   '("charset" "font-face" "import" "media" "namespace" "page")
   "Identifiers that appear in the form @foo.")
 
+(defconst css-bang-ids
+  '("important")
+  "Identifiers that appear in the form !foo.")
+
+(defconst scss-bang-ids
+  '("default" "global" "optional")
+  "Additional identifiers that appear in the form !foo in SCSS.")
+
 (defconst css-descriptor-ids
   '("ascent" "baseline" "bbox" "cap-height" "centerline" "definition-src"
     "descent" "font-family" "font-size" "font-stretch" "font-style"
@@ -236,8 +244,8 @@ css-proprietary-property
 
 (defun css--font-lock-keywords (&optional sassy)
   `((,(concat "!\\s-*"
-              (regexp-opt (append (if sassy '("global"))
-                                  '("important"))))
+              (regexp-opt (append (if sassy scss-bang-ids)
+                                  css-bang-ids)))
      (0 font-lock-builtin-face))
     ;; Atrules keywords.  IDs not in css-at-ids are valid (ignored).
     ;; In fact the regexp should probably be
diff --git a/test/indent/css-mode.css b/test/indent/css-mode.css
index 24166b0..3a00739 100644
--- a/test/indent/css-mode.css
+++ b/test/indent/css-mode.css
@@ -9,7 +9,7 @@ article[role="main"] {
 }
 
 a, b:hover, c {
-    color: black;
+    color: black !important;
 }
 
 a, b:hover {                    /* bug:20282 */
diff --git a/test/indent/scss-mode.scss b/test/indent/scss-mode.scss
index 02a4a98..e1ec90a 100644
--- a/test/indent/scss-mode.scss
+++ b/test/indent/scss-mode.scss
@@ -40,11 +40,20 @@ p.#{$name} var
 }
 article[role="main"] {
     $toto: 500 !global;
-    float: left;
+    $var-with-default: 300 !default;
+    float: left !important;
     width: 600px / 888px * 100%;
     height: 100px / 888px * 100%;
 }
 
+%placeholder {
+    color: #f0f0f0;
+}
+
+button {
+    @extend %placeholder !optional;
+}
+
 @import 'reset';
 
 @mixin border-radius($radius) {
-- 
2.7.0


             reply	other threads:[~2016-01-31 21:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-31 21:35 Simen Heggestøyl [this message]
2016-02-01  2:33 ` bug#22508: [PATCH] Highlight two additional SCSS keywords Stefan Monnier
2016-02-01 20:45   ` Simen Heggestøyl

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

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

  git send-email \
    --in-reply-to=1454276125.9296.0@smtp.gmail.com \
    --to=simenheg@gmail.com \
    --cc=22508@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.