Skip to content

Commit 1ff1d75

Browse files
committed
Merge pull request #90 from Wilfred/fix_type_word_boundaries
Correcting highlighting of capitals in function names.
2 parents 5f5a428 + 5e77aed commit 1ff1d75

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

rust-mode-tests.el

+6
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,12 @@ list of substrings of `STR' each followed by its face."
979979
'("'\"'" font-lock-string-face
980980
"let" font-lock-keyword-face)))
981981

982+
(ert-deftest font-lock-fn-contains-capital ()
983+
(rust-test-font-lock
984+
"fn foo_Bar() {}"
985+
'("fn" font-lock-keyword-face
986+
"foo_Bar" font-lock-function-name-face)))
987+
982988
(ert-deftest font-lock-single-quote-character-literal ()
983989
(rust-test-font-lock
984990
"fn main() { let ch = '\\''; }"

rust-mode.el

+6-3
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,14 @@
359359
"bool"
360360
"str" "char"))
361361

362-
(defconst rust-re-CamelCase "[[:upper:]][[:word:][:multibyte:]_[:digit:]]*")
362+
(defconst rust-re-type-or-constructor
363+
(rx symbol-start
364+
(group upper (0+ (any word nonascii digit "_")))
365+
symbol-end))
366+
363367
(defconst rust-re-pre-expression-operators "[-=!%&*/:<>[{(|.^;}]")
364368
(defun rust-re-word (inner) (concat "\\<" inner "\\>"))
365369
(defun rust-re-grab (inner) (concat "\\(" inner "\\)"))
366-
(defun rust-re-grabword (inner) (rust-re-grab (rust-re-word inner)))
367370
(defun rust-re-item-def (itype)
368371
(concat (rust-re-word itype) "[[:space:]]+" (rust-re-grab rust-re-ident)))
369372

@@ -400,7 +403,7 @@
400403
(,(concat "'" (rust-re-grab rust-re-ident) "[^']") 1 font-lock-variable-name-face)
401404

402405
;; CamelCase Means Type Or Constructor
403-
(,(rust-re-grabword rust-re-CamelCase) 1 font-lock-type-face)
406+
(,rust-re-type-or-constructor 1 font-lock-type-face)
404407
)
405408

406409
;; Item definitions

0 commit comments

Comments
 (0)