branch: elpa/clojure-mode
commit 825f9ab2cf4e90df6b72ac569c0a2dd0d1988109
Author: Dave Liepmann <[email protected]>
Commit: GitHub <[email protected]>

    Don't highlight vars with colons as keywords (#670)
    
    Changes syntax highlighting regexp for keywords to match a 
colon/double-colon
    only at the beginning of a word, not in the middle. This allows local vars 
like
    `foo:bar` to be highlighted correctly instead of like an unknown symbol for 
the
    part before the colon and a keyword for the rest.
    
    Fixes #653
---
 clojure-mode.el                     |  5 +++--
 test/clojure-mode-font-lock-test.el | 25 ++++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/clojure-mode.el b/clojure-mode.el
index e3d554dea2..a9a6a0b0c9 100644
--- a/clojure-mode.el
+++ b/clojure-mode.el
@@ -1072,12 +1072,13 @@ any number of matches of 
`clojure--sym-forbidden-rest-chars'."))
       ;; keywords: {:oneword/ve/yCom|pLex.stu-ff 0}
       (,(concat "\\(:\\{1,2\\}\\)\\(" clojure--keyword-sym-regexp "?\\)\\(/\\)"
                 "\\(" clojure--keyword-sym-regexp "\\)")
+       ;; with ns
        (1 'clojure-keyword-face)
        (2 font-lock-type-face)
-       ;; (2 'clojure-keyword-face)
        (3 'default)
        (4 'clojure-keyword-face))
-      (,(concat "\\(:\\{1,2\\}\\)\\(" clojure--keyword-sym-regexp "\\)")
+      (,(concat "\\<\\(:\\{1,2\\}\\)\\(" clojure--keyword-sym-regexp "\\)")
+       ;; without ns
        (1 'clojure-keyword-face)
        (2 'clojure-keyword-face))
 
diff --git a/test/clojure-mode-font-lock-test.el 
b/test/clojure-mode-font-lock-test.el
index bb6ef74dd9..5e578ba13d 100644
--- a/test/clojure-mode-font-lock-test.el
+++ b/test/clojure-mode-font-lock-test.el
@@ -262,6 +262,13 @@ DESCRIPTION is the description of the spec."
      (9 10 nil)
      (11 16 nil))
 
+    ("(colons:are:okay)"
+     (2 16 nil))
+
+    ("(some-ns/colons:are:okay)"
+     (2 8 font-lock-type-face)
+     (9 24 nil))
+
     ("(oneword/ve/yCom|pLex.stu-ff)"
      (2 8 font-lock-type-face)
      (9 10 nil)
@@ -715,6 +722,19 @@ DESCRIPTION is the description of the spec."
      (10 10 default)
      (11 30 clojure-keyword-face)))
 
+  (when-fontifying-it "should handle keywords with colons"
+    (":a:a"
+     (1 4 clojure-keyword-face))
+
+    (":a:a/:a"
+     (1 7 clojure-keyword-face))
+
+    ("::a:a"
+     (1 5 clojure-keyword-face))
+
+    ("::a.a:a"
+     (1 7 clojure-keyword-face)))
+
   (when-fontifying-it "should handle very complex keywords"
     (" :ve/yCom|pLex.stu-ff"
      (3 4 font-lock-type-face)
@@ -824,7 +844,10 @@ DESCRIPTION is the description of the spec."
   (when-fontifying-it "should handle variables defined with def"
     ("(def foo 10)"
      (2 4 font-lock-keyword-face)
-     (6 8 font-lock-variable-name-face)))
+     (6 8 font-lock-variable-name-face))
+    ("(def foo:bar 10)"
+     (2 4 font-lock-keyword-face)
+     (6 12 font-lock-variable-name-face)))
 
   (when-fontifying-it "should handle variables definitions of type string"
     ("(def foo \"hello\")"

Reply via email to