Skip to content

Commit

Permalink
[Fix #508] Correct font-lock for namespaces
Browse files Browse the repository at this point in the history
namespace metadata prevented the namespace name to be highlighted as such

add font-lock tests as well.
  • Loading branch information
Carlos Requena López committed Feb 25, 2019
1 parent 7943b29 commit 02587c3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Bugs fixed

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

## 5.10.0 (2019-01-05)

Expand Down
4 changes: 2 additions & 2 deletions clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,8 @@ any number of matches of `clojure--sym-forbidden-rest-chars'."))

;; namespace definitions: (ns foo.bar)
(,(concat "(\\<ns\\>[ \r\n\t]*"
;; Possibly metadata
"\\(?:\\^?{[^}]+}[ \r\n\t]*\\)*"
;; Possibly metadata, shorthand and/or longhand
"\\(?:\\^?\\(?:{[^}]+}\\|:[^ \r\n\t]+[ \r\n\t]\\)[ \r\n\t]*\\)*"
;; namespace
"\\(" clojure--sym-regexp "\\)")
(1 font-lock-type-face))
Expand Down
9 changes: 8 additions & 1 deletion test/clojure-mode-font-lock-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,14 @@ POS."
(should (eq (clojure-test-face-at 5 11 "(ns Foo-bar)") 'font-lock-type-face))
(should (eq (clojure-test-face-at 5 11 "(ns Foo-Bar)") 'font-lock-type-face))
(should (eq (clojure-test-face-at 5 11 "(ns foo-Bar)") 'font-lock-type-face))
(should (eq (clojure-test-face-at 5 9 "(ns one.X)") 'font-lock-type-face)))
(should (eq (clojure-test-face-at 5 9 "(ns one.X)") 'font-lock-type-face))
(should (eq (clojure-test-face-at 10 16 "(ns ^:md ns-name)") 'font-lock-type-face))
(should (eq (clojure-test-face-at 13 19 "(ns ^:md \n ns-name)") 'font-lock-type-face))
(should (eq (clojure-test-face-at 17 23 "(ns ^:md1 ^:md2 ns-name)") 'font-lock-type-face))
(should (eq (clojure-test-face-at 24 30 "(ns ^:md1 ^{:md2 true} ns-name)") 'font-lock-type-face))
(should (eq (clojure-test-face-at 24 30 "(ns ^{:md2 true} ^:md1 ns-name)") 'font-lock-type-face))
(should (eq (clojure-test-face-at 27 33 "(ns ^:md1 ^{:md2 true} \n ns-name)") 'font-lock-type-face))
(should (eq (clojure-test-face-at 27 33 "(ns ^{:md2 true} ^:md1 \n ns-name)") 'font-lock-type-face)))

(ert-deftest clojure-mode-syntax-table/oneword ()
:tags '(fontification syntax-table)
Expand Down

0 comments on commit 02587c3

Please sign in to comment.