From 7943b29c5ac1d2a3016e9931d9481ce5c4c80d34 Mon Sep 17 00:00:00 2001 From: Michael Griffiths Date: Sat, 16 Feb 2019 23:19:11 +0000 Subject: [PATCH] Fix font locking for non-alphanumeric chars in dynamic var names --- CHANGELOG.md | 4 ++++ clojure-mode.el | 3 ++- test/clojure-mode-font-lock-test.el | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78354744..98210219 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## master (unreleased) +### Bugs fixed + +* Dynamic vars whose names contain non-alphanumeric characters are now font-locked correctly. + ## 5.10.0 (2019-01-05) ### New features diff --git a/clojure-mode.el b/clojure-mode.el index 7940b800..a9ea8e2c 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -847,7 +847,8 @@ any number of matches of `clojure--sym-forbidden-rest-chars'.")) "\\>") 0 font-lock-builtin-face) ;; Dynamic variables - *something* or @*something* - ("\\(?:\\<\\|/\\)@?\\(\\*[a-z-]*\\*\\)\\>" 1 font-lock-variable-name-face) + (,(concat "\\(?:\\<\\|/\\)@?\\(\\*" clojure--sym-regexp "\\*\\)\\>") + 1 font-lock-variable-name-face) ;; Global constants - nil, true, false (,(concat "\\<" diff --git a/test/clojure-mode-font-lock-test.el b/test/clojure-mode-font-lock-test.el index f97c30f9..2eb1fa15 100644 --- a/test/clojure-mode-font-lock-test.el +++ b/test/clojure-mode-font-lock-test.el @@ -822,6 +822,8 @@ POS." (should (eq (clojure-test-face-at 2 11 "@*some-var*") 'font-lock-variable-name-face)) (should (eq (clojure-test-face-at 9 13 "some.ns/*var*") + 'font-lock-variable-name-face)) + (should (eq (clojure-test-face-at 1 11 "*some-var?*") 'font-lock-variable-name-face))) (provide 'clojure-mode-font-lock-test)