Skip to content

Commit 22f5395

Browse files
committed
Merge pull request #509 from carlosgeos/fix-508
[Fix #508] correct font-lock for namespace name
2 parents e931d08 + 02587c3 commit 22f5395

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
* Dynamic vars whose names contain non-alphanumeric characters are now font-locked correctly.
88
* [#445 (comment)](https://github.com/clojure-emacs/clojure-mode/issues/445#issuecomment-340460753): Proper font lock for namespaced keywords like for example `(s/def ::keyword)`
9+
* [#508](https://github.com/clojure-emacs/clojure-mode/issues/508): Fix font lock for namespaces with metadata
910

1011
## 5.10.0 (2019-01-05)
1112

clojure-mode.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,8 @@ any number of matches of `clojure--sym-forbidden-rest-chars'."))
861861

862862
;; namespace definitions: (ns foo.bar)
863863
(,(concat "(\\<ns\\>[ \r\n\t]*"
864-
;; Possibly metadata
865-
"\\(?:\\^?{[^}]+}[ \r\n\t]*\\)*"
864+
;; Possibly metadata, shorthand and/or longhand
865+
"\\(?:\\^?\\(?:{[^}]+}\\|:[^ \r\n\t]+[ \r\n\t]\\)[ \r\n\t]*\\)*"
866866
;; namespace
867867
"\\(" clojure--sym-regexp "\\)")
868868
(1 font-lock-type-face))

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,14 @@ POS."
149149
(should (eq (clojure-test-face-at 5 11 "(ns Foo-bar)") 'font-lock-type-face))
150150
(should (eq (clojure-test-face-at 5 11 "(ns Foo-Bar)") 'font-lock-type-face))
151151
(should (eq (clojure-test-face-at 5 11 "(ns foo-Bar)") 'font-lock-type-face))
152-
(should (eq (clojure-test-face-at 5 9 "(ns one.X)") 'font-lock-type-face)))
152+
(should (eq (clojure-test-face-at 5 9 "(ns one.X)") 'font-lock-type-face))
153+
(should (eq (clojure-test-face-at 10 16 "(ns ^:md ns-name)") 'font-lock-type-face))
154+
(should (eq (clojure-test-face-at 13 19 "(ns ^:md \n ns-name)") 'font-lock-type-face))
155+
(should (eq (clojure-test-face-at 17 23 "(ns ^:md1 ^:md2 ns-name)") 'font-lock-type-face))
156+
(should (eq (clojure-test-face-at 24 30 "(ns ^:md1 ^{:md2 true} ns-name)") 'font-lock-type-face))
157+
(should (eq (clojure-test-face-at 24 30 "(ns ^{:md2 true} ^:md1 ns-name)") 'font-lock-type-face))
158+
(should (eq (clojure-test-face-at 27 33 "(ns ^:md1 ^{:md2 true} \n ns-name)") 'font-lock-type-face))
159+
(should (eq (clojure-test-face-at 27 33 "(ns ^{:md2 true} ^:md1 \n ns-name)") 'font-lock-type-face)))
153160

154161
(ert-deftest clojure-mode-syntax-table/oneword ()
155162
:tags '(fontification syntax-table)

0 commit comments

Comments
 (0)