diff --git a/CHANGELOG.md b/CHANGELOG.md index d8d98cc0..2913031d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Bugs fixed +* [#547](https://github.com/clojure-emacs/clojure-mode/issues/547): Fix font-lock regex for character literals for uppercase chars and other symbols. * [#556](https://github.com/clojure-emacs/clojure-mode/issues/556): Fix renaming of ns aliases containing regex characters. * [#555](https://github.com/clojure-emacs/clojure-mode/issues/555): Fix ns detection for ns forms with complex metadata. * [#550](https://github.com/clojure-emacs/clojure-mode/issues/550): Fix `outline-regexp` so `outline-insert-heading` behaves correctly. diff --git a/clojure-mode.el b/clojure-mode.el index c9a419f4..7bcb1abf 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -868,7 +868,13 @@ any number of matches of `clojure--sym-forbidden-rest-chars'.")) "\\>") 0 font-lock-constant-face) ;; Character literals - \1, \a, \newline, \u0000 - ("\\\\\\([[:punct:]]\\|[a-z0-9]+\\>\\)" 0 'clojure-character-face) + (,(rx "\\" (or any + "newline" "space" "tab" "formfeed" "backspace" + "return" + (: "u" (= 4 (char "0-9a-fA-F"))) + (: "o" (repeat 1 3 (char "0-7")))) + word-boundary) + 0 'clojure-character-face) ;; namespace definitions: (ns foo.bar) (,(concat "(\\[ \r\n\t]*" diff --git a/test/clojure-mode-font-lock-test.el b/test/clojure-mode-font-lock-test.el index a45e3de1..23dade2b 100644 --- a/test/clojure-mode-font-lock-test.el +++ b/test/clojure-mode-font-lock-test.el @@ -884,15 +884,30 @@ DESCRIPTION is the description of the spec." ("\\a" (1 2 clojure-character-face)) + ("\\A" + (1 2 clojure-character-face)) + ("\\newline" (1 8 clojure-character-face)) + ("\\abc" + (1 4 nil)) + + ("\\newlin" + (1 7 nil)) + + ("\\newlinex" + (1 9 nil)) + ("\\1" (1 2 clojure-character-face)) ("\\u0032" (1 6 clojure-character-face)) + ("\\o127" + (1 4 clojure-character-face)) + ("\\+" (1 2 clojure-character-face)) @@ -903,6 +918,12 @@ DESCRIPTION is the description of the spec." (1 2 clojure-character-face)) ("\\;" + (1 2 clojure-character-face)) + + ("\\Ω" + (1 2 clojure-character-face)) + + ("\\ク" (1 2 clojure-character-face))) (when-fontifying-it "should handle referred vars"