Skip to content

Commit a8dbf36

Browse files
committed
Merge pull request #221 from elixir-lang/issue-218
highlight atoms correctly in a pattern match
2 parents 55c746a + 1acf278 commit a8dbf36

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

elixir-mode.el

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,6 @@ is used to limit the scan."
358358
(group identifiers))
359359
2 font-lock-function-name-face)
360360

361-
;; Variable definitions
362-
(,(elixir-rx (group identifiers)
363-
(one-or-more space)
364-
"="
365-
(or (one-or-more space)
366-
(one-or-more "\n")))
367-
1 font-lock-variable-name-face)
368-
369361
;; Sigils
370362
(,(elixir-rx (group sigils))
371363
1 font-lock-builtin-face)
@@ -429,9 +421,19 @@ is used to limit the scan."
429421
1 font-lock-type-face)
430422

431423
;; Atoms and singleton-like words like true/false/nil.
432-
(,(elixir-rx (group atoms))
424+
(,(elixir-rx (group atoms)
425+
(zero-or-more space)
426+
(optional "="))
433427
1 elixir-atom-face)
434428

429+
;; Variable definitions
430+
(,(elixir-rx (group identifiers)
431+
(zero-or-more space)
432+
"="
433+
(or (zero-or-more space)
434+
(one-or-more "\n")))
435+
1 font-lock-variable-name-face)
436+
435437
;; Map keys
436438
(,(elixir-rx (group (and (one-or-more identifiers) ":")))
437439
1 elixir-atom-face)

test/elixir-mode-font-test.el

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ buffer."
2121
(ert-deftest elixir-mode-syntax-table/fontify-regex ()
2222
:tags '(fontification syntax-table)
2323
(elixir-test-with-temp-buffer
24-
"match = ~r/foo/"
24+
"match = ~r/foo/
25+
match=~r/foo/"
2526
(should (eq (elixir-test-face-at 1) 'font-lock-variable-name-face))
2627
(should (eq (elixir-test-face-at 9) 'font-lock-builtin-face))
2728
(should (eq (elixir-test-face-at 12) 'font-lock-string-face))
29+
(should (eq (elixir-test-face-at 18) 'font-lock-variable-name-face))
2830
;; no face for regex delimiters
2931
(should (eq (elixir-test-face-at 15) nil))))
3032

@@ -188,6 +190,13 @@ some_expr"
188190
(should (eq (elixir-test-face-at 19) 'font-lock-string-face))
189191
(should (eq (elixir-test-face-at 31) 'font-lock-string-face))))
190192

193+
(ert-deftest elixir-mode-syntax-table/fontify-atom-in-pattern-match ()
194+
:tags '(fontification atom syntax-table)
195+
(elixir-test-with-temp-buffer
196+
":any = into_to_type(type)
197+
:another=into_to_type(type)"
198+
(should (eq (elixir-test-face-at 3) 'elixir-atom-face))))
199+
191200
(ert-deftest elixir-mode-syntax-table/fontify-assignment-with-pattern/1 ()
192201
:expected-result :failed
193202
:tags '(fontification syntax-table)

0 commit comments

Comments
 (0)