branch: elpa/rust-mode
commit 1ff1d7576b6882fc146b38a43ab84f6562441876
Merge: 5f5a428 5e77aed
Author: Micah Chalmer <[email protected]>
Commit: Micah Chalmer <[email protected]>
Merge pull request #90 from Wilfred/fix_type_word_boundaries
Correcting highlighting of capitals in function names.
---
rust-mode-tests.el | 6 ++++++
rust-mode.el | 9 ++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index 8f25f06..e621f82 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -979,6 +979,12 @@ list of substrings of `STR' each followed by its face."
'("'\"'" font-lock-string-face
"let" font-lock-keyword-face)))
+(ert-deftest font-lock-fn-contains-capital ()
+ (rust-test-font-lock
+ "fn foo_Bar() {}"
+ '("fn" font-lock-keyword-face
+ "foo_Bar" font-lock-function-name-face)))
+
(ert-deftest font-lock-single-quote-character-literal ()
(rust-test-font-lock
"fn main() { let ch = '\\''; }"
diff --git a/rust-mode.el b/rust-mode.el
index 15c1be7..b237896 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -359,11 +359,14 @@
"bool"
"str" "char"))
-(defconst rust-re-CamelCase "[[:upper:]][[:word:][:multibyte:]_[:digit:]]*")
+(defconst rust-re-type-or-constructor
+ (rx symbol-start
+ (group upper (0+ (any word nonascii digit "_")))
+ symbol-end))
+
(defconst rust-re-pre-expression-operators "[-=!%&*/:<>[{(|.^;}]")
(defun rust-re-word (inner) (concat "\\<" inner "\\>"))
(defun rust-re-grab (inner) (concat "\\(" inner "\\)"))
-(defun rust-re-grabword (inner) (rust-re-grab (rust-re-word inner)))
(defun rust-re-item-def (itype)
(concat (rust-re-word itype) "[[:space:]]+" (rust-re-grab rust-re-ident)))
@@ -400,7 +403,7 @@
(,(concat "'" (rust-re-grab rust-re-ident) "[^']") 1
font-lock-variable-name-face)
;; CamelCase Means Type Or Constructor
- (,(rust-re-grabword rust-re-CamelCase) 1 font-lock-type-face)
+ (,rust-re-type-or-constructor 1 font-lock-type-face)
)
;; Item definitions