diff options
| author | Simen Heggestøyl | 2016-02-01 21:38:25 +0100 |
|---|---|---|
| committer | Simen Heggestøyl | 2016-02-01 21:38:25 +0100 |
| commit | 1d07dcd720890764774770e0ad24ba11a5bda233 (patch) | |
| tree | 4a72b7ed09878ea11b9a012044c60c6d6fe0a4f9 | |
| parent | ee8b46699523cc1dea7b3d03e3cccff3d62cd847 (diff) | |
| download | emacs-1d07dcd720890764774770e0ad24ba11a5bda233.tar.gz emacs-1d07dcd720890764774770e0ad24ba11a5bda233.zip | |
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.
| -rw-r--r-- | lisp/textmodes/css-mode.el | 12 | ||||
| -rw-r--r-- | test/indent/css-mode.css | 2 | ||||
| -rw-r--r-- | 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 96a82baa56c..b3a41d3822c 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el | |||
| @@ -54,6 +54,14 @@ | |||
| 54 | '("charset" "font-face" "import" "media" "namespace" "page") | 54 | '("charset" "font-face" "import" "media" "namespace" "page") |
| 55 | "Identifiers that appear in the form @foo.") | 55 | "Identifiers that appear in the form @foo.") |
| 56 | 56 | ||
| 57 | (defconst css-bang-ids | ||
| 58 | '("important") | ||
| 59 | "Identifiers that appear in the form !foo.") | ||
| 60 | |||
| 61 | (defconst scss-bang-ids | ||
| 62 | '("default" "global" "optional") | ||
| 63 | "Additional identifiers that appear in the form !foo in SCSS.") | ||
| 64 | |||
| 57 | (defconst css-descriptor-ids | 65 | (defconst css-descriptor-ids |
| 58 | '("ascent" "baseline" "bbox" "cap-height" "centerline" "definition-src" | 66 | '("ascent" "baseline" "bbox" "cap-height" "centerline" "definition-src" |
| 59 | "descent" "font-family" "font-size" "font-stretch" "font-style" | 67 | "descent" "font-family" "font-size" "font-stretch" "font-style" |
| @@ -236,8 +244,8 @@ | |||
| 236 | 244 | ||
| 237 | (defun css--font-lock-keywords (&optional sassy) | 245 | (defun css--font-lock-keywords (&optional sassy) |
| 238 | `((,(concat "!\\s-*" | 246 | `((,(concat "!\\s-*" |
| 239 | (regexp-opt (append (if sassy '("global")) | 247 | (regexp-opt (append (if sassy scss-bang-ids) |
| 240 | '("important")))) | 248 | css-bang-ids))) |
| 241 | (0 font-lock-builtin-face)) | 249 | (0 font-lock-builtin-face)) |
| 242 | ;; Atrules keywords. IDs not in css-at-ids are valid (ignored). | 250 | ;; Atrules keywords. IDs not in css-at-ids are valid (ignored). |
| 243 | ;; In fact the regexp should probably be | 251 | ;; In fact the regexp should probably be |
diff --git a/test/indent/css-mode.css b/test/indent/css-mode.css index 24166b00282..3a00739bfc4 100644 --- a/test/indent/css-mode.css +++ b/test/indent/css-mode.css | |||
| @@ -9,7 +9,7 @@ article[role="main"] { | |||
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | a, b:hover, c { | 11 | a, b:hover, c { |
| 12 | color: black; | 12 | color: black !important; |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | a, b:hover { /* bug:20282 */ | 15 | a, b:hover { /* bug:20282 */ |
diff --git a/test/indent/scss-mode.scss b/test/indent/scss-mode.scss index 02a4a98a8c5..e1ec90a5299 100644 --- a/test/indent/scss-mode.scss +++ b/test/indent/scss-mode.scss | |||
| @@ -40,11 +40,20 @@ p.#{$name} var | |||
| 40 | } | 40 | } |
| 41 | article[role="main"] { | 41 | article[role="main"] { |
| 42 | $toto: 500 !global; | 42 | $toto: 500 !global; |
| 43 | float: left; | 43 | $var-with-default: 300 !default; |
| 44 | float: left !important; | ||
| 44 | width: 600px / 888px * 100%; | 45 | width: 600px / 888px * 100%; |
| 45 | height: 100px / 888px * 100%; | 46 | height: 100px / 888px * 100%; |
| 46 | } | 47 | } |
| 47 | 48 | ||
| 49 | %placeholder { | ||
| 50 | color: #f0f0f0; | ||
| 51 | } | ||
| 52 | |||
| 53 | button { | ||
| 54 | @extend %placeholder !optional; | ||
| 55 | } | ||
| 56 | |||
| 48 | @import 'reset'; | 57 | @import 'reset'; |
| 49 | 58 | ||
| 50 | @mixin border-radius($radius) { | 59 | @mixin border-radius($radius) { |