summaryrefslogtreecommitdiff
path: root/rust-mode.el
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2015-08-15 00:20:40 +0100
committerWilfred Hughes <me@wilfred.me.uk>2015-08-15 00:20:40 +0100
commit5e77aedb27761d770e7e1a3b37875d3a4b0e932f (patch)
treeacb70c281003d0977abec1c8be5d1913761c0177 /rust-mode.el
parent99c5571670068e05da40d05f6215e18fa9043eed (diff)
downloadrust-mode-5e77aedb27761d770e7e1a3b37875d3a4b0e932f.tar.gz
Correcting highlighting of capitals in function names.
Previously, code of the form: fn foo_Bar () {} would be incorrectly highlighted, because the regex matched on word boundaries rather than symbol boundaries. Test added.
Diffstat (limited to 'rust-mode.el')
-rw-r--r--rust-mode.el9
1 files changed, 6 insertions, 3 deletions
diff --git a/rust-mode.el b/rust-mode.el
index a97e2eb..7de82bf 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