Skip to content

Fix character literal regexp #560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 "(\\<ns\\>[ \r\n\t]*"
Expand Down
21 changes: 21 additions & 0 deletions test/clojure-mode-font-lock-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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"
Expand Down