Skip to content

Commit 5ba4cee

Browse files
authored
[Fix #547] Fix character literal regexp (#560)
1 parent 2ef5151 commit 5ba4cee

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
### Bugs fixed
1010

11+
* [#547](https://github.com/clojure-emacs/clojure-mode/issues/547): Fix font-lock regex for character literals for uppercase chars and other symbols.
1112
* [#556](https://github.com/clojure-emacs/clojure-mode/issues/556): Fix renaming of ns aliases containing regex characters.
1213
* [#555](https://github.com/clojure-emacs/clojure-mode/issues/555): Fix ns detection for ns forms with complex metadata.
1314
* [#550](https://github.com/clojure-emacs/clojure-mode/issues/550): Fix `outline-regexp` so `outline-insert-heading` behaves correctly.

clojure-mode.el

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,13 @@ any number of matches of `clojure--sym-forbidden-rest-chars'."))
868868
"\\>")
869869
0 font-lock-constant-face)
870870
;; Character literals - \1, \a, \newline, \u0000
871-
("\\\\\\([[:punct:]]\\|[a-z0-9]+\\>\\)" 0 'clojure-character-face)
871+
(,(rx "\\" (or any
872+
"newline" "space" "tab" "formfeed" "backspace"
873+
"return"
874+
(: "u" (= 4 (char "0-9a-fA-F")))
875+
(: "o" (repeat 1 3 (char "0-7"))))
876+
word-boundary)
877+
0 'clojure-character-face)
872878

873879
;; namespace definitions: (ns foo.bar)
874880
(,(concat "(\\<ns\\>[ \r\n\t]*"

test/clojure-mode-font-lock-test.el

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,15 +884,30 @@ DESCRIPTION is the description of the spec."
884884
("\\a"
885885
(1 2 clojure-character-face))
886886

887+
("\\A"
888+
(1 2 clojure-character-face))
889+
887890
("\\newline"
888891
(1 8 clojure-character-face))
889892

893+
("\\abc"
894+
(1 4 nil))
895+
896+
("\\newlin"
897+
(1 7 nil))
898+
899+
("\\newlinex"
900+
(1 9 nil))
901+
890902
("\\1"
891903
(1 2 clojure-character-face))
892904

893905
("\\u0032"
894906
(1 6 clojure-character-face))
895907

908+
("\\o127"
909+
(1 4 clojure-character-face))
910+
896911
("\\+"
897912
(1 2 clojure-character-face))
898913

@@ -903,6 +918,12 @@ DESCRIPTION is the description of the spec."
903918
(1 2 clojure-character-face))
904919

905920
("\\;"
921+
(1 2 clojure-character-face))
922+
923+
("\\Ω"
924+
(1 2 clojure-character-face))
925+
926+
("\\"
906927
(1 2 clojure-character-face)))
907928

908929
(when-fontifying-it "should handle referred vars"

0 commit comments

Comments
 (0)