Skip to content

Commit a5b298c

Browse files
committed
Fontify character literals as strings.
Since we're using a syntax property function, we can attempt to be smarter about parser state. I'd like to extend this to sigil expressions, also (which I suspect might be a possible way to fix #23).
1 parent cf1fb6c commit a5b298c

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

elixir-smie.el

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,27 @@
3636
(save-excursion
3737
(goto-char start)
3838
;; The ? character on its own is supposed to escape whatever comes
39-
;; after it (including any escaped chars. Examples: ?\# and ?#.
39+
;; after it (including any escaped chars. Examples: ?\# and ?".
4040
(while (search-forward "?" end t)
41-
(unless (or (= (char-syntax (char-before (- (point) 1))) ?w)
42-
(= (char-syntax (char-before (- (point) 1))) ?_))
43-
(put-text-property (1- (point))
44-
(point)
45-
'syntax-table
46-
'(?|))
47-
(when (= (char-after) ?\\)
41+
(let ((start (1- (point))))
42+
(unless (or (= (char-syntax (char-before (- (point) 1))) ?w)
43+
(= (char-syntax (char-before (- (point) 1))) ?_))
44+
(put-text-property (1- (point))
45+
(point)
46+
'syntax-table
47+
'(?|))
48+
(when (= (char-after) ?\\)
49+
(forward-char)
50+
(put-text-property (1- (point))
51+
(point)
52+
'syntax-table
53+
'(?\s)))
4854
(forward-char)
4955
(put-text-property (1- (point))
5056
(point)
5157
'syntax-table
52-
'(?\s)))
53-
(forward-char)
54-
(put-text-property (1- (point))
55-
(point)
56-
'syntax-table
57-
'(?|))))))
58+
'(?|))
59+
(put-text-property start (point) 'font-lock-face 'font-lock-string-face))))))
5860

5961
(defmacro elixir-smie-debug (message &rest format-args)
6062
`(progn

0 commit comments

Comments
 (0)