GNU bug report logs - #22211
[PATCH] Add a face for CSS/SCSS variables

Previous Next

Package: emacs;

Reported by: Simen Heggestøyl <simenheg <at> gmail.com>

Date: Sat, 19 Dec 2015 11:13:02 UTC

Severity: wishlist

Tags: patch

Done: Simen Heggestøyl <simenheg <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 22211 in the body.
You can then email your comments to 22211 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#22211; Package emacs. (Sat, 19 Dec 2015 11:13:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Simen Heggestøyl <simenheg <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 19 Dec 2015 11:13:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Simen Heggestøyl <simenheg <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: [PATCH] Add a face for CSS/SCSS variables
Date: Sat, 19 Dec 2015 12:12:25 +0100
[Message part 1 (text/plain, inline)]
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 <at> 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


[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22211; Package emacs. (Sat, 19 Dec 2015 14:20:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Simen Heggestøyl <simenheg <at> gmail.com>
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: [PATCH] Add a face for CSS/SCSS variables
Date: Sat, 19 Dec 2015 09:18:49 -0500
> +(defface css-variable '((t :inherit font-lock-variable-name-face))
> +  "Face to use for variables.")

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


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22211; Package emacs. (Sun, 27 Dec 2015 18:21:02 GMT) Full text and rfc822 format available.

Message #11 received at 22211 <at> debbugs.gnu.org (full text, mbox):

From: Simen Heggestøyl <simenheg <at> gmail.com>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 22211 <at> debbugs.gnu.org
Subject: Re: bug#22211: [PATCH] Add a face for CSS/SCSS variables
Date: Sun, 27 Dec 2015 19:19:52 +0100
[Message part 1 (text/plain, inline)]
On Sat, Dec 19, 2015 at 3:18 PM, Stefan Monnier 
<monnier <at> 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 <at> 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


[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22211; Package emacs. (Sun, 27 Dec 2015 18:29:02 GMT) Full text and rfc822 format available.

Message #14 received at 22211 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Simen Heggestøyl <simenheg <at> gmail.com>
Cc: Stefan Monnier <monnier <at> IRO.UMontreal.CA>, 22211 <at> debbugs.gnu.org
Subject: Re: bug#22211: [PATCH] Add a face for CSS/SCSS variables
Date: Sun, 27 Dec 2015 19:28:08 +0100
Simen Heggestøyl <simenheg <at> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22211; Package emacs. (Sun, 27 Dec 2015 18:39:02 GMT) Full text and rfc822 format available.

Message #17 received at 22211 <at> debbugs.gnu.org (full text, mbox):

From: Simen Heggestøyl <simenheg <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 22211 <at> debbugs.gnu.org
Subject: Re: bug#22211: [PATCH] Add a face for CSS/SCSS variables
Date: Sun, 27 Dec 2015 19:38:30 +0100
[Message part 1 (text/plain, inline)]
On Sun, Dec 27, 2015 at 7:28 PM, Lars Ingebrigtsen <larsi <at> 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
[Message part 2 (text/html, inline)]
[0001-Highlight-CSS-variables-with-variable-name-face.patch (text/x-patch, attachment)]

Reply sent to Simen Heggestøyl <simenheg <at> gmail.com>:
You have taken responsibility. (Sun, 31 Jan 2016 14:31:03 GMT) Full text and rfc822 format available.

Notification sent to Simen Heggestøyl <simenheg <at> gmail.com>:
bug acknowledged by developer. (Sun, 31 Jan 2016 14:31:03 GMT) Full text and rfc822 format available.

Message #22 received at 22211-done <at> debbugs.gnu.org (full text, mbox):

From: Simen Heggestøyl <simenheg <at> gmail.com>
To: 22211-done <at> debbugs.gnu.org
Subject: Re: bug#22211: [PATCH] Add a face for CSS/SCSS variables
Date: Sun, 31 Jan 2016 15:29:59 +0100
[Message part 1 (text/plain, inline)]
Installed in emacs-25.
[Message part 2 (text/html, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 29 Feb 2016 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 191 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.