unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Simen Heggestøyl" <simenheg@gmail.com>
To: 20107@debbugs.gnu.org
Subject: bug#20107: [PATCH 1/3] css-mode: Discriminate between pseudo-classes and -elements
Date: Sat, 14 Mar 2015 12:19:01 +0100	[thread overview]
Message-ID: <1426331941.18090.0@smtp.gmail.com> (raw)

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

Hi.

The following patch makes `css-mode' discriminate between
pseudo-classes and pseudo-ids. While it might not seem immediately
useful to do so, it will become useful when completion at point is
implemented in a later patch.


 From b87dadfbbacbd1372ba31e2f591a260e7b4b581f Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= <simenheg@gmail.com>
Date: Sat, 14 Mar 2015 10:54:39 +0100
Subject: [PATCH 1/3] Discriminate between pseudo-classes and -elements

* textmodes/css-mode.el (css--font-lock-keywords): Discriminate
between pseudo-classes and pseudo-elements.
(css-pseudo-ids): Remove.
(css-pseudo-class-ids): New variable.
(css-pseudo-element-ids): New variable.
---
 lisp/ChangeLog             |  8 ++++++++
 lisp/textmodes/css-mode.el | 21 ++++++++++++++++-----
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d393190..70122c7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2015-03-14  Simen Heggestøyl  <simenheg@gmail.com>
+
+	* textmodes/css-mode.el (css--font-lock-keywords): Discriminate
+	between pseudo-classes and pseudo-elements.
+	(css-pseudo-ids): Remove.
+	(css-pseudo-class-ids): New variable.
+	(css-pseudo-element-ids): New variable.
+
 2015-03-13  Kevin Ryde  <user42_kevin@yahoo.com.au>

 	info-look fixes for Texinfo 5
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index 44dc4df..dc11d44 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -120,10 +120,17 @@
 ;;    (media . "^ +\\* '\\([^ '\n]+\\)' media group")
 ;;    (property . "^ +\\* '\\([^ '\n]+\\)',")))

-(defconst css-pseudo-ids
-  '("active" "after" "before" "first" "first-child" "first-letter" 
"first-line"
-    "focus" "hover" "lang" "left" "link" "right" "visited")
-  "Identifiers for pseudo-elements and pseudo-classes.")
+(defconst css-pseudo-class-ids
+  '("active" "checked" "disabled" "empty" "enabled" "first"
+    "first-child" "first-of-type" "focus" "hover" "indeterminate" 
"lang"
+    "last-child" "last-of-type" "left" "link" "nth-child"
+    "nth-last-child" "nth-last-of-type" "nth-of-type" "only-child"
+    "only-of-type" "right" "root" "target" "visited")
+  "Identifiers for pseudo-classes.")
+
+(defconst css-pseudo-element-ids
+  '("after" "before" "first-letter" "first-line")
+  "Identifiers for pseudo-elements.")

 (defconst css-at-ids
   '("charset" "font-face" "import" "media" "page")
@@ -258,7 +265,11 @@
          (concat "\\(?:" scss--hash-re
                  "\\|[^@/:{} \t\n#]\\)"
                  "[^:{}#]*\\(?:" scss--hash-re "[^:{}#]*\\)*"))
-       "\\(?::" (regexp-opt css-pseudo-ids t)
+       ;; Even though pseudo-elements should be prefixed by ::, a
+       ;; single colon is accepted for backward compatibility.
+       "\\(?:\\(:" (regexp-opt (append css-pseudo-class-ids
+                                       css-pseudo-element-ids) t)
+       "\\|\\::" (regexp-opt css-pseudo-element-ids t) "\\)"
        "\\(?:([^\)]+)\\)?"
        (if (not sassy)
            "[^:{}\n]*"
-- 
2.1.4

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

             reply	other threads:[~2015-03-14 11:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-14 11:19 Simen Heggestøyl [this message]
2015-03-14 11:21 ` bug#20107: [PATCH 2/3] css-mode: Add support for completion in `css-mode' Simen Heggestøyl
2015-03-14 11:22 ` bug#20107: [PATCH 3/3] css-mode: Update CSS property list Simen Heggestøyl
2015-03-14 14:05   ` Stefan Monnier
2015-03-15 12:46     ` Simen Heggestøyl
2015-03-18 17:41   ` Simen Heggestøyl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426331941.18090.0@smtp.gmail.com \
    --to=simenheg@gmail.com \
    --cc=20107@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).