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 6c82483c..623928e5 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-singleton () + "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