unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#22211: [PATCH] Add a face for CSS/SCSS variables
@ 2015-12-19 11:12 Simen Heggestøyl
  2015-12-19 14:18 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Simen Heggestøyl @ 2015-12-19 11:12 UTC (permalink / raw)
  To: 22211; +Cc: Stefan Monnier

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

Hi,

I'd like to propose the following patch, which introduces a new face
to be used commonly for CSS and SCSS variable names.

-- Simen


 From dd89467a604d85d7fd2194bfd1a97c6834806727 Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= <simenheg@gmail.com>
Date: Fri, 18 Dec 2015 22:38:08 +0100
Subject: [PATCH] Add a face for CSS/SCSS variables

* lisp/textmodes/css-mode.el (css-nmstart-re): Don't match variables.
(css-variable): New face for variables.
(css--font-lock-keywords): Highlight variables.
(scss-font-lock-keywords): Use the new variable face.
---
 lisp/textmodes/css-mode.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index 3e84b43..8c20df7 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 "+"))
@@ -233,6 +233,8 @@ css-property
   :group 'css)
 (defface css-proprietary-property '((t :inherit (css-property italic)))
   "Face to use for vendor-specific properties.")
+(defface css-variable '((t :inherit font-lock-variable-name-face))
+  "Face to use for variables.")

 (defun css--font-lock-keywords (&optional sassy)
   `((,(concat "!\\s-*"
@@ -246,6 +248,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 'css-variable))
     ;; Selectors.
     ;; FIXME: attribute selectors don't work well because they may 
contain
     ;; strings which have already been highlighted as f-l-string-face 
and
@@ -525,7 +529,7 @@ scss-mode-syntax-table
     st))

 (defvar scss-font-lock-keywords
-  (append `((,(concat "$" css-ident-re) (0 
font-lock-variable-name-face)))
+  (append `((,(concat "$" css-ident-re) (0 'css-variable)))
           (css--font-lock-keywords 'sassy)
           `((,(concat "@mixin[ \t]+\\(" css-ident-re "\\)[ \t]*(")
              (1 font-lock-function-name-face)))))
-- 
2.6.4



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

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

* bug#22211: [PATCH] Add a face for CSS/SCSS variables
  2015-12-19 11:12 bug#22211: [PATCH] Add a face for CSS/SCSS variables Simen Heggestøyl
@ 2015-12-19 14:18 ` Stefan Monnier
  2015-12-27 18:19   ` Simen Heggestøyl
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2015-12-19 14:18 UTC (permalink / raw)
  To: Simen Heggestøyl; +Cc: 22211

> +(defface css-variable '((t :inherit font-lock-variable-name-face))
> +  "Face to use for variables.")

Why not use font-lock-variable-name-face?


        Stefan





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

* bug#22211: [PATCH] Add a face for CSS/SCSS variables
  2015-12-19 14:18 ` Stefan Monnier
@ 2015-12-27 18:19   ` Simen Heggestøyl
  2015-12-27 18:28     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Simen Heggestøyl @ 2015-12-27 18:19 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 22211

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

On Sat, Dec 19, 2015 at 3:18 PM, Stefan Monnier 
<monnier@IRO.UMontreal.CA> 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?= <simenheg@gmail.com>
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



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

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

* bug#22211: [PATCH] Add a face for CSS/SCSS variables
  2015-12-27 18:19   ` Simen Heggestøyl
@ 2015-12-27 18:28     ` Lars Ingebrigtsen
  2015-12-27 18:38       ` Simen Heggestøyl
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Ingebrigtsen @ 2015-12-27 18:28 UTC (permalink / raw)
  To: Simen Heggestøyl; +Cc: Stefan Monnier, 22211

Simen Heggestøyl <simenheg@gmail.com> writes:

>  (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. 

The patch is corrupted.  Try including it as an attachment instead.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#22211: [PATCH] Add a face for CSS/SCSS variables
  2015-12-27 18:28     ` Lars Ingebrigtsen
@ 2015-12-27 18:38       ` Simen Heggestøyl
  2016-01-31 14:29         ` Simen Heggestøyl
  0 siblings, 1 reply; 6+ messages in thread
From: Simen Heggestøyl @ 2015-12-27 18:38 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Stefan Monnier, 22211


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

On Sun, Dec 27, 2015 at 7:28 PM, Lars Ingebrigtsen <larsi@gnus.org> 
wrote:
> The patch is corrupted.  Try including it as an attachment instead.

Thanks for catching that, Lars. I've included it as an attachement 
instead.

-- Simen

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Highlight-CSS-variables-with-variable-name-face.patch --]
[-- Type: text/x-patch, Size: 1728 bytes --]

From 84bea3c332b32626d0579e8f8be164d832d0a557 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= <simenheg@gmail.com>
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


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

* bug#22211: [PATCH] Add a face for CSS/SCSS variables
  2015-12-27 18:38       ` Simen Heggestøyl
@ 2016-01-31 14:29         ` Simen Heggestøyl
  0 siblings, 0 replies; 6+ messages in thread
From: Simen Heggestøyl @ 2016-01-31 14:29 UTC (permalink / raw)
  To: 22211-done

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

Installed in emacs-25.

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

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

end of thread, other threads:[~2016-01-31 14:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-19 11:12 bug#22211: [PATCH] Add a face for CSS/SCSS variables Simen Heggestøyl
2015-12-19 14:18 ` Stefan Monnier
2015-12-27 18:19   ` Simen Heggestøyl
2015-12-27 18:28     ` Lars Ingebrigtsen
2015-12-27 18:38       ` Simen Heggestøyl
2016-01-31 14:29         ` Simen Heggestøyl

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).