Skip to content

Correcting highlighting of capitals in function names. #90

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 1 commit into from
Aug 15, 2015
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
6 changes: 6 additions & 0 deletions rust-mode-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '\\''; }"
Expand Down
9 changes: 6 additions & 3 deletions rust-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down Expand Up @@ -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
Expand Down