Skip to content

Commit 7960c74

Browse files
datomookid
authored andcommitted
Do not allow subword-match when detecting built-in formatting macros
Before this change, a user-created macro like ‘cprintln!’ would see the ‘println’ subword highlighted as a built-in macro, and the leading ‘c’ left without color. After this commit, only full words will be recognized as built-ins, and ‘cprintln!’ is highlighted as a regular macro in full, not as a built-in. In addition, this commit fixes the same issue for the write! macro.
1 parent 1d42d69 commit 7960c74

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rust-mode.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,15 +676,15 @@ Returns nil if the point is not within a Rust string."
676676
1 font-lock-preprocessor-face keep)
677677

678678
;; Builtin formatting macros
679-
(,(concat (rust-re-grab (concat (regexp-opt rust-builtin-formatting-macros) "!")) (concat rust-formatting-macro-opening-re "\\(?:" rust-start-of-string-re) "\\)?")
679+
(,(concat (rust-re-grab (concat (rust-re-word (regexp-opt rust-builtin-formatting-macros)) "!")) (concat rust-formatting-macro-opening-re "\\(?:" rust-start-of-string-re) "\\)?")
680680
(1 'rust-builtin-formatting-macro-face)
681681
(rust-string-interpolation-matcher
682682
(rust-end-of-string)
683683
nil
684684
(0 'rust-string-interpolation-face t nil)))
685685

686686
;; write! macro
687-
(,(concat (rust-re-grab "write\\(ln\\)?!") (concat rust-formatting-macro-opening-re "[[:space:]]*[^\"]+,[[:space:]]*" rust-start-of-string-re))
687+
(,(concat (rust-re-grab (concat (rust-re-word "write\\(ln\\)?") "!")) (concat rust-formatting-macro-opening-re "[[:space:]]*[^\"]+,[[:space:]]*" rust-start-of-string-re))
688688
(1 'rust-builtin-formatting-macro-face)
689689
(rust-string-interpolation-matcher
690690
(rust-end-of-string)

0 commit comments

Comments
 (0)