Skip to content

Commit ab09ca1

Browse files
committed
Merge pull request #84 from elixir-lang/camelcase-font
Improve fontification for identifiers.
2 parents 2903f94 + 976a219 commit ab09ca1

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

elixir-mode.el

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,11 @@
287287
(zero-or-more
288288
(any "a-z")))
289289
symbol-end))
290-
(variables . ,(rx symbol-start
291-
(one-or-more (any "A-Z" "a-z" "0-9" "_"))
292-
symbol-end))
290+
(identifiers . ,(rx symbol-start
291+
(one-or-more (any "A-Z" "a-z""_"))
292+
(zero-or-more (any "0-9"))
293+
(optional (or "?" "!"))
294+
symbol-end))
293295
(atoms . ,(rx ":"
294296
(or
295297
(one-or-more (any "a-z" "A-Z" "0-9" "_"))
@@ -321,11 +323,11 @@
321323
;; Method names, i.e. `def foo do'
322324
(,(elixir-rx method-defines
323325
space
324-
(group (one-or-more (any "a-z" "_"))))
326+
(group identifiers))
325327
1 font-lock-function-name-face)
326328

327329
;; Variable definitions
328-
(,(elixir-rx (group variables)
330+
(,(elixir-rx (group identifiers)
329331
(one-or-more space)
330332
"="
331333
(one-or-more space))

elixir-smie.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
(modify-syntax-entry ?_ "w" table)
1919
(modify-syntax-entry ?? "w" table)
2020
(modify-syntax-entry ?~ "w" table)
21-
21+
(modify-syntax-entry ?! "_" table)
2222
(modify-syntax-entry ?' "\"'" table)
2323
(modify-syntax-entry ?\" "\"\"" table)
2424
(modify-syntax-entry ?# "<" table)

test/elixir-mode-font-tests.el

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,30 @@ x = 15"
7272
"a = \"\" <> \"?\"
7373
x = 15"
7474
(should (eq (elixir-test-face-at 15) 'font-lock-variable-name-face))))
75+
76+
(ert-deftest elixir-mode-syntax-table/fontify-function-name/1 ()
77+
:tags '(fontification syntax-table)
78+
(elixir-test-with-temp-buffer
79+
"def fooBar do
80+
:foo
81+
end"
82+
(should (eq (elixir-test-face-at 5) 'font-lock-function-name-face))
83+
(should (eq (elixir-test-face-at 8) 'font-lock-function-name-face))))
84+
85+
(ert-deftest elixir-mode-syntax-table/fontify-function-name/2 ()
86+
:tags '(fontification syntax-table)
87+
(elixir-test-with-temp-buffer
88+
"def foo? do
89+
:foo
90+
end"
91+
(should (eq (elixir-test-face-at 5) 'font-lock-function-name-face))
92+
(should (eq (elixir-test-face-at 8) 'font-lock-function-name-face))))
93+
94+
(ert-deftest elixir-mode-syntax-table/fontify-function-name/3 ()
95+
:tags '(fontification syntax-table)
96+
(elixir-test-with-temp-buffer
97+
"def foo! do
98+
:foo
99+
end"
100+
(should (eq (elixir-test-face-at 5) 'font-lock-function-name-face))
101+
(should (eq (elixir-test-face-at 8) 'font-lock-function-name-face))))

0 commit comments

Comments
 (0)