Skip to content

Commit 2086dfe

Browse files
committed
---
yaml --- r: 47035 b: refs/heads/try c: 1ef8c48 h: refs/heads/master i: 47033: 9ad3537 47031: 58dfff7 v: v3
1 parent 9b2ad99 commit 2086dfe

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
5-
refs/heads/try: c7f85003a345826b17801d473303d0c545d0e8d2
5+
refs/heads/try: 1ef8c48a204ad215310f38a239a898ee38d9bf8e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/etc/emacs/rust-mode.el

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,7 @@
101101
(rust-push-context st 'string (current-column) t)
102102
(setf (rust-state-tokenize st) 'rust-token-string)
103103
(rust-token-string st))
104-
(def ?\' (forward-char)
105-
(setf rust-tcat 'atom)
106-
(let ((is-escape (eq (char-after) ?\\))
107-
(start (point)))
108-
(if (not (rust-eat-until-unescaped ?\'))
109-
'font-lock-warning-face
110-
(if (or is-escape (= (point) (+ start 2)))
111-
'font-lock-string-face 'font-lock-warning-face))))
104+
(def ?\' (rust-single-quote))
112105
(def ?/ (forward-char)
113106
(case (char-after)
114107
(?/ (end-of-line) 'font-lock-comment-face)
@@ -150,6 +143,23 @@
150143
(setf rust-tcat 'op) nil)
151144
table)))
152145

146+
(defun rust-single-quote ()
147+
(forward-char)
148+
(setf rust-tcat 'atom)
149+
; Is this a lifetime?
150+
(if (or (looking-at "[a-zA-Z_]$")
151+
(looking-at "[a-zA-Z_][^']"))
152+
; If what we see is 'abc, use font-lock-type-face:
153+
(progn (rust-eat-re "[a-zA-Z_][a-zA-Z_0-9]*")
154+
'font-lock-type-face)
155+
; Otherwise, handle as a character constant:
156+
(let ((is-escape (eq (char-after) ?\\))
157+
(start (point)))
158+
(if (not (rust-eat-until-unescaped ?\'))
159+
'font-lock-warning-face
160+
(if (or is-escape (= (point) (+ start 2)))
161+
'font-lock-string-face 'font-lock-warning-face)))))
162+
153163
(defun rust-token-base (st)
154164
(funcall (char-table-range rust-char-table (char-after)) st))
155165

0 commit comments

Comments
 (0)