emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/clojure-mode 0be365aca8: [Fix #581] Fix font locking for k


From: ELPA Syncer
Subject: [nongnu] elpa/clojure-mode 0be365aca8: [Fix #581] Fix font locking for keywords starting with a number (#628)
Date: Wed, 24 Aug 2022 13:58:18 -0400 (EDT)

branch: elpa/clojure-mode
commit 0be365aca8dc5e931f3df454ce834390e0740bc9
Author: Vadim Rodionov <47952597+OknoLombarda@users.noreply.github.com>
Commit: GitHub <noreply@github.com>

    [Fix #581] Fix font locking for keywords starting with a number (#628)
---
 CHANGELOG.md                        |  4 ++++
 clojure-mode.el                     | 14 ++++++++++++--
 test.clj                            |  5 +++++
 test/clojure-mode-font-lock-test.el | 25 +++++++++++++++++++++++--
 4 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index d8f864bbc5..ac6e3d13f9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
 
 ## master (unreleased)
 
+### Bugs fixed
+
+* [#581](https://github.com/clojure-emacs/clojure-mode/issues/581): Fix font 
locking not working for keywords starting with a number
+
 ## 5.15.1 (2022-07-30)
 
 ### Bugs fixed
diff --git a/clojure-mode.el b/clojure-mode.el
index 5b6c7f79b0..33ebc6d021 100644
--- a/clojure-mode.el
+++ b/clojure-mode.el
@@ -780,6 +780,15 @@ definition of 'macros': URL `http://git.io/vRGLD'.")
     (concat "[^" clojure--sym-forbidden-1st-chars "][^" 
clojure--sym-forbidden-rest-chars "]*")
     "A regexp matching a Clojure symbol or namespace alias.
 Matches the rule `clojure--sym-forbidden-1st-chars' followed by
+any number of matches of `clojure--sym-forbidden-rest-chars'.")
+  (defconst clojure--keyword-sym-forbidden-1st-chars
+    (concat clojure--sym-forbidden-rest-chars ":'")
+    "A list of chars that a Clojure keyword symbol cannot start with.")
+  (defconst clojure--keyword-sym-regexp
+    (concat "[^" clojure--keyword-sym-forbidden-1st-chars "]"
+            "[^" clojure--sym-forbidden-rest-chars "]*")
+    "A regexp matching a Clojure keyword name or keyword namespace.
+Matches the rule `clojure--keyword-sym-forbidden-1st-chars' followed by
 any number of matches of `clojure--sym-forbidden-rest-chars'."))
 
 (defconst clojure-font-lock-keywords
@@ -974,13 +983,14 @@ any number of matches of 
`clojure--sym-forbidden-rest-chars'."))
       ;; TODO dedupe the code for matching of keywords, type-hints and 
unmatched symbols
 
       ;; keywords: {:oneword/ve/yCom|pLex.stu-ff 0}
-      (,(concat "\\(:\\{1,2\\}\\)\\(" clojure--sym-regexp "?\\)\\(/\\)\\(" 
clojure--sym-regexp "\\)")
+      (,(concat "\\(:\\{1,2\\}\\)\\(" clojure--keyword-sym-regexp "?\\)\\(/\\)"
+                "\\(" clojure--keyword-sym-regexp "\\)")
        (1 'clojure-keyword-face)
        (2 font-lock-type-face)
        ;; (2 'clojure-keyword-face)
        (3 'default)
        (4 'clojure-keyword-face))
-      (,(concat "\\(:\\{1,2\\}\\)\\(" clojure--sym-regexp "\\)")
+      (,(concat "\\(:\\{1,2\\}\\)\\(" clojure--keyword-sym-regexp "\\)")
        (1 'clojure-keyword-face)
        (2 'clojure-keyword-face))
 
diff --git a/test.clj b/test.clj
index 8ec9b94730..221380e8f6 100644
--- a/test.clj
+++ b/test.clj
@@ -163,6 +163,11 @@
   {:oneword/ve/yCom|pLex.stu-ff 0}
   {:oneword/.ve/yCom|pLex.stu-ff 0}
 
+  :1oneword
+  :ns/1word
+  :1ns/word
+  :1ns/1word
+
   {:seg.mnt 0}
   ;; {:@seg.mnt 0} ; not allowed
   {:#seg.mnt 0}
diff --git a/test/clojure-mode-font-lock-test.el 
b/test/clojure-mode-font-lock-test.el
index b3687aaf59..c8304a0535 100644
--- a/test/clojure-mode-font-lock-test.el
+++ b/test/clojure-mode-font-lock-test.el
@@ -487,11 +487,17 @@ DESCRIPTION is the description of the spec."
 
   (when-fontifying-it "should handle oneword keywords"
     (" :oneword"
-     (3 9 clojure-keyword-face ))
+     (3 9 clojure-keyword-face))
+
+    (" :1oneword"
+     (3 10 clojure-keyword-face))
 
     ("{:oneword 0}"
      (3 9 clojure-keyword-face))
 
+    ("{:1oneword 0}"
+     (3 10 clojure-keyword-face))
+
     ("{:#oneword 0}"
      (3 10 clojure-keyword-face))
 
@@ -563,7 +569,22 @@ DESCRIPTION is the description of the spec."
      (10 17 clojure-keyword-face))
 
     (":_:_:foo/bar_:_:foo"
-     (10 19 clojure-keyword-face)))
+     (10 19 clojure-keyword-face))
+
+    (":1foo/bar"
+     (2 5 font-lock-type-face)
+     (6 6 default)
+     (7 9 clojure-keyword-face))
+
+    (":foo/1bar"
+     (2 4 font-lock-type-face)
+     (5 5 default)
+     (6 9 clojure-keyword-face))
+
+    (":1foo/1bar"
+     (2 5 font-lock-type-face)
+     (6 6 default)
+     (7 10 clojure-keyword-face)))
 
   (when-fontifying-it "should handle segment keywords"
     (" :seg.mnt"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]