Skip to content

Fix highlighting ignored variable in pattern match #374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions elixir-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,6 @@ is used to limit the scan."
(optional "="))
1 elixir-atom-face)

;; Variable definitions
(,(elixir-rx (group identifiers)
(zero-or-more space)
(repeat 1 "=")
(or (or sigils identifiers space)
(one-or-more "\n")))
1 font-lock-variable-name-face)

;; Gray out variables starting with "_"
(,(elixir-rx symbol-start
(group (and "_"
Expand All @@ -401,6 +393,14 @@ is used to limit the scan."
(optional (or "?" "!"))))
1 font-lock-comment-face)

;; Variable definitions
(,(elixir-rx (group identifiers)
(zero-or-more space)
(repeat 1 "=")
(or (or sigils identifiers space)
(one-or-more "\n")))
1 font-lock-variable-name-face)

;; Map keys
(,(elixir-rx (group (and (one-or-more identifiers) ":")) space)
1 elixir-atom-face)
Expand Down
11 changes: 10 additions & 1 deletion test/elixir-mode-font-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ end

(ert-deftest elixir-mode-syntax-table/question-quote ()
"https://github.com/elixir-lang/emacs-elixir/issues/185"
:tags '(fontification syntax-table hoge)
:tags '(fontification syntax-table)
(elixir-test-with-temp-buffer
"\"\\\"foo\\\"\" |> String.strip(?\")"
(should-not (eq (elixir-test-face-at 28) 'font-lock-string-face)))
Expand All @@ -536,6 +536,15 @@ end
"\"\\\"foo\\\"\" |> String.strip(?')"
(should-not (eq (elixir-test-face-at 28) 'font-lock-string-face))))

(ert-deftest elixir-mode-syntax-table/ignored-variables-in-pattern-match ()
"https://github.com/elixir-lang/emacs-elixir/issues/361"
:tags '(fontification syntax-table)
(elixir-test-with-temp-buffer
"(_1_day = 86_400)
_1_day"
(should (eq (elixir-test-face-at 2) 'font-lock-comment-face))
(should (eq (elixir-test-face-at 19) 'font-lock-comment-face))))

(provide 'elixir-mode-font-test)

;;; elixir-mode-font-test.el ends here