From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Newsgroups: gmane.emacs.bugs Subject: bug#22211: [PATCH] Add a face for CSS/SCSS variables Date: Sat, 19 Dec 2015 12:12:25 +0100 Message-ID: <1450523545.4477.0@smtp.gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=-cpYEhbZedqWG1wfROJKK" X-Trace: ger.gmane.org 1450523606 19073 80.91.229.3 (19 Dec 2015 11:13:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Dec 2015 11:13:26 +0000 (UTC) Cc: Stefan Monnier To: 22211@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 19 12:13:15 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aAFRq-000118-2B for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 Dec 2015 12:13:14 +0100 Original-Received: from localhost ([::1]:36866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAFRp-0005sI-8A for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 Dec 2015 06:13:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43196) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAFRj-0005s4-SZ for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2015 06:13:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aAFRe-0007K8-Rp for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2015 06:13:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48677) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAFRe-0007K3-OS for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2015 06:13:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aAFRe-00061a-IT for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2015 06:13:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Dec 2015 11:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 22211 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.145052356423131 (code B ref -1); Sat, 19 Dec 2015 11:13:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Dec 2015 11:12:44 +0000 Original-Received: from localhost ([127.0.0.1]:56279 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aAFRM-000611-C0 for submit@debbugs.gnu.org; Sat, 19 Dec 2015 06:12:44 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:52157) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aAFRK-00060o-PN for submit@debbugs.gnu.org; Sat, 19 Dec 2015 06:12:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aAFRE-0007II-3Q for submit@debbugs.gnu.org; Sat, 19 Dec 2015 06:12:37 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:57982) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAFRE-0007IC-01 for submit@debbugs.gnu.org; Sat, 19 Dec 2015 06:12:36 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAFRC-0005mv-He for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2015 06:12:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aAFR7-0007HV-44 for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2015 06:12:34 -0500 Original-Received: from mail-lf0-x234.google.com ([2a00:1450:4010:c07::234]:34479) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAFR6-0007H9-Ns for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2015 06:12:29 -0500 Original-Received: by mail-lf0-x234.google.com with SMTP id y184so86922306lfc.1 for ; Sat, 19 Dec 2015 03:12:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:subject:to:cc:message-id:mime-version:content-type; bh=FFiCtFqhXNMMcuZUH/LyMD6cszL2vyBiCoe6G2c0bJg=; b=kXeCkeNAbFEiGajwCuu2k1pyKfUMAqEh1Kg2a3hHJHUBcGaIs8E8073xw1UOnnKhPn PWNRSh+huiCT4dTBDwGjWVwE6B8C4yHq9Y9CjeW2hnmVgT8ghMIfK8NXvX1UfjBFbupA 8K1Ikv4su1QLZ+DClDzLBGnhUhALqfwnxHpkPCpZX4SKrqB0OJugoSTL5Sg2H0kzFHAH WS7yWHhiiVgv4ZTMBSVGVvySenwnPhmdj2Lu2G+M07FFIs3j3MJ8BeHUZLaLz5VhUtcX QoYZxToDy5tnRiY8n2QoDRoXZiGaC/wbTTbIzjltNMKVTHyUb+S71kPum8VzTGbzD3AI e/NA== X-Received: by 10.25.85.78 with SMTP id j75mr3176984lfb.46.1450523547746; Sat, 19 Dec 2015 03:12:27 -0800 (PST) Original-Received: from [192.168.1.104] (168.165.34.95.customer.cdi.no. [95.34.165.168]) by smtp.gmail.com with ESMTPSA id rm5sm3410621lbb.20.2015.12.19.03.12.26 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 19 Dec 2015 03:12:27 -0800 (PST) X-Mailer: geary/0.10.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:110166 Archived-At: --=-cpYEhbZedqWG1wfROJKK Content-Type: text/plain; charset=utf-8; format=flowed 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?= 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 --=-cpYEhbZedqWG1wfROJKK Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
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: =3D?UTF-8?q?Simen=3D20Heggest=3DC3=3DB8yl?=3D &l= t;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 variabl= es.
(css-variable): New face for variables.
(css--font-= lock-keywords): Highlight variables.
(scss-font-lock-keywords): U= se the new variable face.
---
 lisp/textmodes/css-= mode.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 del= etions(-)

diff --git a/lisp/textmodes/css-mode.el = b/lisp/textmodes/css-mode.el
index 3e84b43..8c20df7 100644
<= div>--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mod= e.el
@@ -215,7 +215,7 @@ css-syntax-propertize-function
 (defconst css-escapes-re
   "\\\\\\(?:[^\000-\03= 7\177]\\|[0-9a-fA-F]+[ \n\t\r\f]?\\)")
 (defconst css-nmchar= -re (concat "\\(?:[-[:alnum:]]\\|" css-escapes-re "\\)"))
-(defco= nst css-nmstart-re (concat "\\(?:--\\)?\\(?:[[:alpha:]]\\|" css-escapes-re = "\\)"))
+(defconst css-nmstart-re (concat "\\(?:[[:alpha:]]\\|" c= ss-escapes-re "\\)"))
 (defconst css-ident-re ;; (concat css= -nmstart-re css-nmchar-re "*")
   ;; Apparently, "at ru= les" names can start with a dash, e.g. @-moz-keyframes.
  &n= bsp;(concat css-nmchar-re "+"))
@@ -233,6 +233,8 @@ css-property<= /div>
   :group 'css)
 (defface css-proprietar= y-property '((t :inherit (css-property italic)))
   "Fa= ce to use for vendor-specific properties.")
+(defface css-variabl= e '((t :inherit font-lock-variable-name-face))
+  "Face to u= se for variables.")
 
 (defun css--font-lock-= keywords (&optional sassy)
   `((,(concat "!\\s-*"<= /div>
@@ -246,6 +248,8 @@ css--font-lock-keywords
  &nbs= p;  ;; Since "An at-rule consists of everything up to and including th= e next
     ;; semicolon (;) or the next block, wh= ichever comes first."
     (,(concat "@" css-ident= -re) (0 font-lock-builtin-face))
+    ;; Variables.
+    (,(concat "--" css-ident-re) (0 'css-variable))
=
     ;; Selectors.
     ;; FIX= ME: attribute selectors don't work well because they may contain
=      ;; strings which have already been highlighted as f-l-s= tring-face and
@@ -525,7 +529,7 @@ scss-mode-syntax-table
     st))
 
 (defvar scss-f= ont-lock-keywords
-  (append `((,(concat "$" css-ident-re) (= 0 font-lock-variable-name-face)))
+  (append `((,(concat "$"= css-ident-re) (0 'css-variable)))
        &n= bsp;  (css--font-lock-keywords 'sassy)
      =      `((,(concat "@mixin[ \t]+\\(" css-ident-re "\\)[ \t]*("= )
              (1 font-lock-f= unction-name-face)))))
-- 
2.6.4

= --=-cpYEhbZedqWG1wfROJKK--