Skip to content

Commit 0efb466

Browse files
author
Bozhidar Batsov
committed
Fix font-locking of single-segment names in ns macro
1 parent 6700c65 commit 0efb466

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

clojure-mode.el

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,6 @@ Called by `imenu--generic-function'."
432432
(2 font-lock-function-name-face nil t))
433433
;; lambda arguments - %, %1, %2, etc
434434
("\\<%[1-9]?" (0 font-lock-variable-name-face))
435-
;; (ns namespace)
436-
(,(concat "(\\(?:clojure.core/\\)?ns[ \t]+"
437-
;; namespace
438-
"\\(\\sw+\\)" )
439-
(1 font-lock-type-face nil t))
440435
;; Special forms & control structures
441436
(,(concat
442437
"(\\(?:clojure.core/\\)?"
@@ -496,6 +491,13 @@ Called by `imenu--generic-function'."
496491
("\\(?:\\<\\|\\.\\|/\\|#?^\\)\\([A-Z][a-zA-Z0-9_]*[a-zA-Z0-9$_]+\\.?\\>\\)" 1 font-lock-type-face)
497492
;; foo.bar.baz
498493
("\\<^?\\([a-z][a-z0-9_-]+\\.\\([a-z][a-z0-9_-]*\\.?\\)+\\)" 1 font-lock-type-face)
494+
;; (ns namespace) - special handling for single segment namespaces
495+
(,(concat "\\<ns\\>[ \r\n\t]*"
496+
;; Possibly metadata
497+
"\\(?:\\^?{[^}]+}[ \r\n\t]*\\)*"
498+
;; namespace
499+
"\\([a-z0-9-]+\\)")
500+
(1 font-lock-type-face nil t))
499501
;; foo/ Foo/ @Foo/
500502
("\\<@?\\([a-zA-Z][a-z0-9_-]*\\)/" 1 font-lock-type-face)
501503
;; fooBar

test/clojure-mode-test.el

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ POS."
214214
(should (eq (clojure-test-face-at 1 10 "*some-var*") 'font-lock-variable-name-face))
215215
(should (eq (clojure-test-face-at 2 11 "@*some-var*") 'font-lock-variable-name-face)))
216216

217+
(ert-deftest clojure-mode-syntax-table/ns-macro ()
218+
:tags '(fontification syntax-table)
219+
(should (eq (clojure-test-face-at 5 8 "(ns name)") 'font-lock-type-face))
220+
(should (eq (clojure-test-face-at 5 13 "(ns name.name)") 'font-lock-type-face)))
221+
217222
(provide 'clojure-mode-test)
218223

219224
;; Local Variables:

0 commit comments

Comments
 (0)