Skip to content

Commit 27915a0

Browse files
authored
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
1 parent 6bccf8c commit 27915a0

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

clojure-mode-font-lock-test.el

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@ DESCRIPTION is the description of the spec."
262262
(9 10 nil)
263263
(11 16 nil))
264264

265+
("(colons:are:okay)"
266+
(2 16 nil))
267+
268+
("(some-ns/colons:are:okay)"
269+
(2 8 font-lock-type-face)
270+
(9 24 nil))
271+
265272
("(oneword/ve/yCom|pLex.stu-ff)"
266273
(2 8 font-lock-type-face)
267274
(9 10 nil)
@@ -715,6 +722,19 @@ DESCRIPTION is the description of the spec."
715722
(10 10 default)
716723
(11 30 clojure-keyword-face)))
717724

725+
(when-fontifying-it "should handle keywords with colons"
726+
(":a:a"
727+
(1 4 clojure-keyword-face))
728+
729+
(":a:a/:a"
730+
(1 7 clojure-keyword-face))
731+
732+
("::a:a"
733+
(1 5 clojure-keyword-face))
734+
735+
("::a.a:a"
736+
(1 7 clojure-keyword-face)))
737+
718738
(when-fontifying-it "should handle very complex keywords"
719739
(" :ve/yCom|pLex.stu-ff"
720740
(3 4 font-lock-type-face)
@@ -824,7 +844,10 @@ DESCRIPTION is the description of the spec."
824844
(when-fontifying-it "should handle variables defined with def"
825845
("(def foo 10)"
826846
(2 4 font-lock-keyword-face)
827-
(6 8 font-lock-variable-name-face)))
847+
(6 8 font-lock-variable-name-face))
848+
("(def foo:bar 10)"
849+
(2 4 font-lock-keyword-face)
850+
(6 12 font-lock-variable-name-face)))
828851

829852
(when-fontifying-it "should handle variables definitions of type string"
830853
("(def foo \"hello\")"

0 commit comments

Comments
 (0)