Skip to content

Commit

Permalink
Merge pull request #84 from elixir-lang/camelcase-font
Browse files Browse the repository at this point in the history
Improve fontification for identifiers.
  • Loading branch information
mattdeboard committed Aug 18, 2014
2 parents 2903f94 + 976a219 commit ab09ca1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
12 changes: 7 additions & 5 deletions elixir-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,11 @@
(zero-or-more
(any "a-z")))
symbol-end))
(variables . ,(rx symbol-start
(one-or-more (any "A-Z" "a-z" "0-9" "_"))
symbol-end))
(identifiers . ,(rx symbol-start
(one-or-more (any "A-Z" "a-z""_"))
(zero-or-more (any "0-9"))
(optional (or "?" "!"))
symbol-end))
(atoms . ,(rx ":"
(or
(one-or-more (any "a-z" "A-Z" "0-9" "_"))
Expand Down Expand Up @@ -321,11 +323,11 @@
;; Method names, i.e. `def foo do'
(,(elixir-rx method-defines
space
(group (one-or-more (any "a-z" "_"))))
(group identifiers))
1 font-lock-function-name-face)

;; Variable definitions
(,(elixir-rx (group variables)
(,(elixir-rx (group identifiers)
(one-or-more space)
"="
(one-or-more space))
Expand Down
2 changes: 1 addition & 1 deletion elixir-smie.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(modify-syntax-entry ?_ "w" table)
(modify-syntax-entry ?? "w" table)
(modify-syntax-entry ?~ "w" table)

(modify-syntax-entry ?! "_" table)
(modify-syntax-entry ?' "\"'" table)
(modify-syntax-entry ?\" "\"\"" table)
(modify-syntax-entry ?# "<" table)
Expand Down
27 changes: 27 additions & 0 deletions test/elixir-mode-font-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,30 @@ x = 15"
"a = \"\" <> \"?\"
x = 15"
(should (eq (elixir-test-face-at 15) 'font-lock-variable-name-face))))

(ert-deftest elixir-mode-syntax-table/fontify-function-name/1 ()
:tags '(fontification syntax-table)
(elixir-test-with-temp-buffer
"def fooBar do
:foo
end"
(should (eq (elixir-test-face-at 5) 'font-lock-function-name-face))
(should (eq (elixir-test-face-at 8) 'font-lock-function-name-face))))

(ert-deftest elixir-mode-syntax-table/fontify-function-name/2 ()
:tags '(fontification syntax-table)
(elixir-test-with-temp-buffer
"def foo? do
:foo
end"
(should (eq (elixir-test-face-at 5) 'font-lock-function-name-face))
(should (eq (elixir-test-face-at 8) 'font-lock-function-name-face))))

(ert-deftest elixir-mode-syntax-table/fontify-function-name/3 ()
:tags '(fontification syntax-table)
(elixir-test-with-temp-buffer
"def foo! do
:foo
end"
(should (eq (elixir-test-face-at 5) 'font-lock-function-name-face))
(should (eq (elixir-test-face-at 8) 'font-lock-function-name-face))))

0 comments on commit ab09ca1

Please sign in to comment.