Skip to content

Commit 3c0bdf7

Browse files
committed
Font-lock namespaced keywords
1 parent 27c2a6f commit 3c0bdf7

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

clojure-mode.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,10 @@ Called by `imenu--generic-function'."
453453
0 font-lock-constant-face)
454454
;; Character literals - \1, \a, \newline, \u0000
455455
("\\\\\\([[:punct:]]\\|[a-z0-9]+\\>\\)" 0 'clojure-character-face)
456+
;; foo/ Foo/ @Foo/ /FooBar
457+
("\\(?:\\<:?\\|\\.\\)@?\\([a-zA-Z][.a-zA-Z0-9$_-]*\\)/" 1 font-lock-type-face)
456458
;; Constant values (keywords), including as metadata e.g. ^:static
457-
("\\<^?\\(:\\(\\sw\\|\\s_\\)+\\(\\>\\|\\_>\\)\\)" 1 'clojure-keyword-face)
459+
("\\<^?\\(:\\(\\sw\\|\\s_\\)+\\(\\>\\|\\_>\\)\\)" 1 'clojure-keyword-face append)
458460
;; Java interop highlighting
459461
;; CONST SOME_CONST (optionally prefixed by /)
460462
("\\(?:\\<\\|/\\)\\([A-Z]+\\|\\([A-Z]+_[A-Z1-9_]+\\)\\)\\>" 1 font-lock-constant-face)
@@ -471,8 +473,6 @@ Called by `imenu--generic-function'."
471473
;; namespace
472474
"\\([a-z0-9-]+\\)")
473475
(1 font-lock-type-face nil t))
474-
;; foo/ Foo/ @Foo/ /FooBar
475-
("\\(?:\\<\\|\\.\\)@?\\([a-zA-Z][a-zA-Z0-9$_-]*\\)/" 1 font-lock-type-face)
476476
;; fooBar
477477
("\\(?:\\<\\|/\\)\\([a-z]+[A-Z]+[a-zA-Z0-9$]*\\>\\)" 1 'clojure-interop-method-face)
478478
;; Highlight `code` marks, just like `elisp'.

test/clojure-mode-font-lock-test.el

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,16 @@ POS."
101101

102102
(ert-deftest clojure-mode-syntax-table/fontify-clojure-keyword ()
103103
:tags '(fontification syntax-table)
104-
(should (eq (clojure-test-face-at 2 11 "{:something 20}") 'clojure-keyword-face)))
104+
(should (equal (clojure-test-face-at 2 11 "{:something 20}") '(clojure-keyword-face))))
105+
106+
(ert-deftest clojure-mode-syntax-table/fontify-namespaced-keyword ()
107+
:tags '(fontification syntax-table)
108+
(should (equal (clojure-test-face-at 2 2 "{:alias/some 20}") '(clojure-keyword-face)))
109+
(should (equal (clojure-test-face-at 3 7 "{:alias/some 20}") '(font-lock-type-face clojure-keyword-face)))
110+
(should (equal (clojure-test-face-at 8 12 "{:alias/some 20}") '(clojure-keyword-face)))
111+
(should (equal (clojure-test-face-at 2 2 "{:a.ias/some 20}") '(clojure-keyword-face)))
112+
(should (equal (clojure-test-face-at 3 7 "{:a.ias/some 20}") '(font-lock-type-face clojure-keyword-face)))
113+
(should (equal (clojure-test-face-at 8 12 "{:a.ias/some 20}") '(clojure-keyword-face))))
105114

106115
(ert-deftest clojure-mode-syntax-table/type ()
107116
:tags '(fontification syntax-table)
@@ -229,7 +238,7 @@ POS."
229238
:tags '(fontification syntax-table)
230239
(clojure-test-with-temp-buffer "^:meta-data"
231240
(should (eq (clojure-test-face-at 1 1) nil))
232-
(should (eq (clojure-test-face-at 2 11) 'clojure-keyword-face))))
241+
(should (equal (clojure-test-face-at 2 11) '(clojure-keyword-face)))))
233242

234243
(ert-deftest clojure-mode-syntax-table/characters ()
235244
:tags '(fontification syntax-table)

0 commit comments

Comments
 (0)