Skip to content

Commit d495ed8

Browse files
authored
Merge pull request #478 from mpanarin/add_font-lock_to_arrows
Add font-lock to arrows
2 parents e0d0466 + 192fa47 commit d495ed8

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

elixir-mode.el

+5
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182
(zero-or-more (any "A-Z" "a-z" "_" "0-9"))))
183183
(optional (or "!" "?"))
184184
symbol-end))
185+
(arrows . ,(rx (or "->" "<-" "=>" "|>")))
185186
(pseudo-var . ,(rx symbol-start
186187
(optional (or "%" "&"))
187188
(or "_" "__MODULE__" "__DIR__" "__ENV__" "__CALLER__"
@@ -435,6 +436,10 @@ is used to limit the scan."
435436
(,(elixir-rx (group pseudo-var))
436437
1 font-lock-constant-face)
437438

439+
;; Arrows
440+
(,(elixir-rx (group arrows))
441+
1 font-lock-keyword-face)
442+
438443
;; Code points
439444
(,(elixir-rx (group code-point))
440445
1 font-lock-negation-char-face)))

tests/elixir-mode-font-test.el

+25
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,31 @@ _1_day"
579579
(should (eq (elixir-test-face-at 2) 'font-lock-comment-face))
580580
(should (eq (elixir-test-face-at 19) 'font-lock-comment-face))))
581581

582+
(ert-deftest elixir-mode-syntax-table/arrows ()
583+
:tags '(fontification syntax-table)
584+
585+
(elixir-test-with-temp-buffer
586+
"with {:ok, _} <- SomeModule.call(),
587+
:ok <- OtherModule.call() do
588+
:ok
589+
end"
590+
(should (eq (elixir-test-face-at 15) 'font-lock-keyword-face))
591+
(should (eq (elixir-test-face-at 50) 'font-lock-keyword-face)))
592+
593+
(elixir-test-with-temp-buffer
594+
"%{
595+
\"\"foo\"\" => \"bar\"
596+
}"
597+
(should (eq (elixir-test-face-at 18) 'font-lock-keyword-face)))
598+
599+
(elixir-test-with-temp-buffer
600+
"[] |> IO.inspect()"
601+
(should (eq (elixir-test-face-at 4) 'font-lock-keyword-face)))
602+
603+
(elixir-test-with-temp-buffer
604+
"a = fn x -> x end"
605+
(should (eq (elixir-test-face-at 10) 'font-lock-keyword-face))))
606+
582607
(ert-deftest elixir-mode-in-docstring ()
583608
"https://github.com/elixir-editors/emacs-elixir/issues/355"
584609
:tags 'fontification

0 commit comments

Comments
 (0)