From 17da2317ba4f2848b3c5697531be43a14fb88dac Mon Sep 17 00:00:00 2001 From: Syohei YOSHIDA Date: Sun, 6 Sep 2015 09:29:19 +0900 Subject: [PATCH 1/2] Add unit test for issue 245 --- test/elixir-mode-font-test.el | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/elixir-mode-font-test.el b/test/elixir-mode-font-test.el index 6c82483c..604f5054 100644 --- a/test/elixir-mode-font-test.el +++ b/test/elixir-mode-font-test.el @@ -173,6 +173,7 @@ end" true false nil +true_false_nil " (should (eq (elixir-test-face-at 3) 'elixir-atom-face)) (should (eq (elixir-test-face-at 5) 'elixir-atom-face)) @@ -183,7 +184,8 @@ nil (should (eq (elixir-test-face-at 26) 'elixir-atom-face)) (should (eq (elixir-test-face-at 43) 'elixir-atom-face)) (should (eq (elixir-test-face-at 48) 'elixir-atom-face)) - (should (eq (elixir-test-face-at 54) 'elixir-atom-face)))) + (should (eq (elixir-test-face-at 54) 'elixir-atom-face)) + (should-not (eq (elixir-test-face-at 57) 'elixir-atom-face)))) (ert-deftest elixir-mode-syntax-table/fontify-map-keys () :tags '(fontification map syntax-table) @@ -246,6 +248,15 @@ some_expr" (should (eq (elixir-test-face-at 2) 'font-lock-variable-name-face)) (should (eq (elixir-test-face-at 4) 'font-lock-variable-name-face)))) +(ert-deftest elixir-mode-syntax-table/fontify-assignment-with-special-atom () + "https://github.com/elixir-lang/emacs-elixir/issues/245" + :tags '(fontification syntax-table) + (elixir-test-with-temp-buffer + "true_false_nil = 1" + (should (eq (elixir-test-face-at 1) 'font-lock-variable-name-face)) + (should (eq (elixir-test-face-at 6) 'font-lock-variable-name-face)) + (should (eq (elixir-test-face-at 12) 'font-lock-variable-name-face)))) + (provide 'elixir-mode-font-test) ;;; elixir-mode-font-test.el ends here From 128e70c3ee028588060cd7a81219f97042b746dc Mon Sep 17 00:00:00 2001 From: Syohei YOSHIDA Date: Sun, 6 Sep 2015 09:29:32 +0900 Subject: [PATCH 2/2] Wrap symbol-start and symbol-end for not highlighting like true_false --- elixir-mode.el | 4 +++- test/elixir-mode-font-test.el | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/elixir-mode.el b/elixir-mode.el index f3674cd3..790611ba 100644 --- a/elixir-mode.el +++ b/elixir-mode.el @@ -367,7 +367,9 @@ is used to limit the scan." 1 font-lock-type-face) ;; Atoms and singleton-like words like true/false/nil. - (,(elixir-rx (group (or atoms "true" "false" "nil")) + (,(elixir-rx symbol-start + (group (or atoms "true" "false" "nil")) + symbol-end (zero-or-more space) (optional "=")) 1 elixir-atom-face) diff --git a/test/elixir-mode-font-test.el b/test/elixir-mode-font-test.el index 604f5054..623928e5 100644 --- a/test/elixir-mode-font-test.el +++ b/test/elixir-mode-font-test.el @@ -248,7 +248,7 @@ some_expr" (should (eq (elixir-test-face-at 2) 'font-lock-variable-name-face)) (should (eq (elixir-test-face-at 4) 'font-lock-variable-name-face)))) -(ert-deftest elixir-mode-syntax-table/fontify-assignment-with-special-atom () +(ert-deftest elixir-mode-syntax-table/fontify-assignment-with-singleton () "https://github.com/elixir-lang/emacs-elixir/issues/245" :tags '(fontification syntax-table) (elixir-test-with-temp-buffer