From 02587c363e10b0342b8fd9f30b0e9dc227b8b414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Requena=20L=C3=B3pez?= Date: Mon, 25 Feb 2019 23:44:44 +0100 Subject: [PATCH] [Fix #508] Correct font-lock for namespaces namespace metadata prevented the namespace name to be highlighted as such add font-lock tests as well. --- CHANGELOG.md | 1 + clojure-mode.el | 4 ++-- test/clojure-mode-font-lock-test.el | 9 ++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98210219..c57ebe25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/clojure-mode.el b/clojure-mode.el index a9ea8e2c..5eee99b9 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -861,8 +861,8 @@ any number of matches of `clojure--sym-forbidden-rest-chars'.")) ;; namespace definitions: (ns foo.bar) (,(concat "(\\[ \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)) diff --git a/test/clojure-mode-font-lock-test.el b/test/clojure-mode-font-lock-test.el index 2eb1fa15..8eb187c3 100644 --- a/test/clojure-mode-font-lock-test.el +++ b/test/clojure-mode-font-lock-test.el @@ -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)