From 2fd477a311d8d7eb7c710922f00fd9d01008baf1 Mon Sep 17 00:00:00 2001 From: Matt DeBoard Date: Mon, 18 Aug 2014 18:23:04 -0500 Subject: [PATCH 1/5] Add test for fontification of camelCase. --- test/elixir-mode-font-tests.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/elixir-mode-font-tests.el b/test/elixir-mode-font-tests.el index 113cde0f..14834a16 100644 --- a/test/elixir-mode-font-tests.el +++ b/test/elixir-mode-font-tests.el @@ -72,3 +72,12 @@ x = 15" "a = \"\" <> \"?\" x = 15" (should (eq (elixir-test-face-at 15) 'font-lock-variable-name-face)))) + +(ert-deftest elixir-mode-syntax-table/fontify-camelcase () + :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)))) From 73ceaf11fd68bba8c1ce2a7a9aef502351b71c2a Mon Sep 17 00:00:00 2001 From: Matt DeBoard Date: Mon, 18 Aug 2014 18:23:50 -0500 Subject: [PATCH 2/5] Fix fontification rules for method names. --- elixir-mode.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/elixir-mode.el b/elixir-mode.el index 5420cd60..90032afe 100644 --- a/elixir-mode.el +++ b/elixir-mode.el @@ -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")) + (zero-or-one (or "!" "?")) + symbol-end)) (atoms . ,(rx ":" (or (one-or-more (any "a-z" "A-Z" "0-9" "_")) @@ -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)) From 448c5d6ee46cd68cc0f04222f5b3ae953ed1e746 Mon Sep 17 00:00:00 2001 From: Matt DeBoard Date: Mon, 18 Aug 2014 18:53:13 -0500 Subject: [PATCH 3/5] Add tests for fontification of func names ending in punctuation. --- test/elixir-mode-font-tests.el | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/elixir-mode-font-tests.el b/test/elixir-mode-font-tests.el index 14834a16..f4e70d51 100644 --- a/test/elixir-mode-font-tests.el +++ b/test/elixir-mode-font-tests.el @@ -73,7 +73,7 @@ x = 15" x = 15" (should (eq (elixir-test-face-at 15) 'font-lock-variable-name-face)))) -(ert-deftest elixir-mode-syntax-table/fontify-camelcase () +(ert-deftest elixir-mode-syntax-table/fontify-function-name/1 () :tags '(fontification syntax-table) (elixir-test-with-temp-buffer "def fooBar do @@ -81,3 +81,21 @@ x = 15" 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)))) From 193c601d19558cf3ef5143593a2682276468e1ce Mon Sep 17 00:00:00 2001 From: Matt DeBoard Date: Mon, 18 Aug 2014 18:53:30 -0500 Subject: [PATCH 4/5] Update syntax table to recognize '' as symbol constituent. --- elixir-smie.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elixir-smie.el b/elixir-smie.el index 9f31a717..0f0ba949 100644 --- a/elixir-smie.el +++ b/elixir-smie.el @@ -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) From 976a2196507578fb6c3ba14d14896aa2c2480ea9 Mon Sep 17 00:00:00 2001 From: Matt DeBoard Date: Mon, 18 Aug 2014 18:53:51 -0500 Subject: [PATCH 5/5] Use optional symbol. --- elixir-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elixir-mode.el b/elixir-mode.el index 90032afe..95608886 100644 --- a/elixir-mode.el +++ b/elixir-mode.el @@ -290,7 +290,7 @@ (identifiers . ,(rx symbol-start (one-or-more (any "A-Z" "a-z""_")) (zero-or-more (any "0-9")) - (zero-or-one (or "!" "?")) + (optional (or "?" "!")) symbol-end)) (atoms . ,(rx ":" (or