bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#22211: [PATCH] Add a face for CSS/SCSS variables


From: Simen Heggestøyl
Subject: bug#22211: [PATCH] Add a face for CSS/SCSS variables
Date: Sun, 27 Dec 2015 19:19:52 +0100

On Sat, Dec 19, 2015 at 3:18 PM, Stefan Monnier <address@hidden> wrote:
Why not use font-lock-variable-name-face?

That's OK by me.

Then I suggest the following patch instead:

From 84bea3c332b32626d0579e8f8be164d832d0a557 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= <address@hidden>
Date: Sun, 27 Dec 2015 19:12:58 +0100
Subject: [PATCH] Highlight CSS variables with variable name face

* lisp/textmodes/css-mode.el (css-nmstart-re): Don't match variables.
(css--font-lock-keywords): Highlight variables in
`font-lock-variable-name-face'.
---
 lisp/textmodes/css-mode.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index 3e84b43..0bcd1ee 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -215,7 +215,7 @@ css-syntax-propertize-function
 (defconst css-escapes-re
   "\\\\\\(?:[^\000-\037\177]\\|[0-9a-fA-F]+[ \n\t\r\f]?\\)")
 (defconst css-nmchar-re (concat "\\(?:[-[:alnum:]]\\|" css-escapes-re "\\)"))
-(defconst css-nmstart-re (concat "\\(?:--\\)?\\(?:[[:alpha:]]\\|" css-escapes-re "\\)"))
+(defconst css-nmstart-re (concat "\\(?:[[:alpha:]]\\|" css-escapes-re "\\)"))
 (defconst css-ident-re ;; (concat css-nmstart-re css-nmchar-re "*")
   ;; Apparently, "at rules" names can start with a dash, e.g. @-moz-keyframes.
   (concat css-nmchar-re "+"))
@@ -246,6 +246,8 @@ css--font-lock-keywords
     ;; Since "An at-rule consists of everything up to and including the next
     ;; semicolon (;) or the next block, whichever comes first."
     (,(concat "@" css-ident-re) (0 font-lock-builtin-face))
+    ;; Variables.
+    (,(concat "--" css-ident-re) (0 font-lock-variable-name-face))
     ;; Selectors.
     ;; FIXME: attribute selectors don't work well because they may contain
     ;; strings which have already been highlighted as f-l-string-face and
-- 
2.6.4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]