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: Sun, 27 Dec 2015 19:19:52 +0100 Message-ID: <1451240392.20532.0@smtp.gmail.com> References: <1450523545.4477.0@smtp.gmail.com> <"Simen =?UTF-8?Q?Heggest=C3=B8yl?="'s message of "Sat, 19 Dec 2015 12:12:25 +0100"> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=-G6HlgtQrA2EiXOPQXoQY" X-Trace: ger.gmane.org 1451240483 24225 80.91.229.3 (27 Dec 2015 18:21:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 27 Dec 2015 18:21:23 +0000 (UTC) Cc: 22211@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 27 19:21:12 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 1aDFwN-00058r-F0 for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Dec 2015 19:21:11 +0100 Original-Received: from localhost ([::1]:42378 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDFwM-0003uu-HY for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Dec 2015 13:21:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDFwH-0003un-VS for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2015 13:21:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aDFwE-0001P7-O2 for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2015 13:21:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37106) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDFwE-0001P2-Jl for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2015 13:21:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aDFwE-0003Gv-Fz for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2015 13:21: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: Sun, 27 Dec 2015 18:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22211 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 22211-submit@debbugs.gnu.org id=B22211.145124040512491 (code B ref 22211); Sun, 27 Dec 2015 18:21:02 +0000 Original-Received: (at 22211) by debbugs.gnu.org; 27 Dec 2015 18:20:05 +0000 Original-Received: from localhost ([127.0.0.1]:44708 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aDFvJ-0003FP-AK for submit@debbugs.gnu.org; Sun, 27 Dec 2015 13:20:05 -0500 Original-Received: from mail-lf0-f50.google.com ([209.85.215.50]:35706) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aDFvH-0003ER-GV for 22211@debbugs.gnu.org; Sun, 27 Dec 2015 13:20:03 -0500 Original-Received: by mail-lf0-f50.google.com with SMTP id c192so13152756lfe.2 for <22211@debbugs.gnu.org>; Sun, 27 Dec 2015 10:20:03 -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:in-reply-to:references :mime-version:content-type; bh=zALLQVs3kCP7NX/fg0YMt51UfflLJV1jxz0eM0X4YY4=; b=USZtgCRkuModLOm0p3OCqg++sHB8SRTqYblDZ+P3n+froOgA6iKrUgqL2uok9HHyPw ogrUqhAK7wsT9YNDJKcbPcXw1TRml04uEHABfghrKDgzgdfzikaoeKlxE7k815+3+i1v /bypHr52dR1nPWltui9cjEgR5k62CRE0Pb28pfbBAqlQgrLQpFA9l/xJQJQznhCbj89X NhF8oSiJc83eSylbAfqNB617Cqi2n/oUuWXaaUYmNXGpUpVPRrfjyEnFp3ia3AyqUoE8 vAoDgKoq6Wn/Nc70eKNp8/n/HMdiCozqZBLFCYD9UloHjDeGNSgtMTPx1RefbxpFo0AI QPqw== X-Received: by 10.25.158.136 with SMTP id h130mr6460454lfe.136.1451240397655; Sun, 27 Dec 2015 10:19:57 -0800 (PST) Original-Received: from [192.168.1.6] (77.17.190.234.tmi.telenormobil.no. [77.17.190.234]) by smtp.gmail.com with ESMTPSA id eb3sm4265188lbc.31.2015.12.27.10.19.55 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 27 Dec 2015 10:19:56 -0800 (PST) In-Reply-To: X-Mailer: geary/0.10.0 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:110817 Archived-At: --=-G6HlgtQrA2EiXOPQXoQY Content-Type: text/plain; charset=utf-8; format=flowed On Sat, Dec 19, 2015 at 3:18 PM, Stefan Monnier 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?= 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 --=-G6HlgtQrA2EiXOPQXoQY Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sat, Dec 19, 2015 at 3:18 PM, Stefan Monnier <monnier@IRO.UMontreal.C= A> wrote:
Why not use font-lock-variable-name-face?

That's OK by me.

Then I suggest= the following patch instead:

From 84bea3c332= b32626d0579e8f8be164d832d0a557 Mon Sep 17 00:00:00 2001
From: =3D= ?UTF-8?q?Simen=3D20Heggest=3DC3=3DB8yl?=3D <simenheg@gmail.com>
=
Date: Sun, 27 Dec 2015 19:12:58 +0100
Subject: [PATCH] Highl= ight CSS variables with variable name face

* lisp/= textmodes/css-mode.el (css-nmstart-re): Don't match variables.
(c= ss--font-lock-keywords): Highlight variables in
`font-lock-variab= le-name-face'.
---
 lisp/textmodes/css-mode.el | 4= +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
<= div>
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes= /css-mode.el
index 3e84b43..0bcd1ee 100644
--- a/lisp/t= extmodes/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-f= A-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 s= tart 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 th= e next block, whichever comes first."
     (,(conc= at "@" 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 beca= use they may contain
     ;; strings which have al= ready been highlighted as f-l-string-face and
-- 
= 2.6.4

= --=-G6HlgtQrA2EiXOPQXoQY--