Skip to content

Commit 02587c3

Browse files
author
Carlos Requena López
committed
[Fix #508] Correct font-lock for namespaces
namespace metadata prevented the namespace name to be highlighted as such add font-lock tests as well.
1 parent 7943b29 commit 02587c3

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
@@ -5,6 +5,7 @@
55
### Bugs fixed
66

77
* Dynamic vars whose names contain non-alphanumeric characters are now font-locked correctly.
8+
* [#508](https://github.com/clojure-emacs/clojure-mode/issues/508): Fix font lock for namespaces with metadata
89

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

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)