Skip to content

Commit 18bc1c4

Browse files
committed
Added a test for highlighting end after comment
1 parent d26a33e commit 18bc1c4

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

elixir-mode.el

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,18 @@
131131
(zero-or-more (any "a-z" "A-Z" "0-9" "_" "\"" "'" "!" "@" "?")))
132132
(and "\"" (one-or-more (not (any "\""))) "\"")
133133
(and "'" (one-or-more (not (any "'"))) "'"))))
134-
(builtin . ,(rx (or line-start (not (any ".")))
135-
symbol-start
134+
(builtin . ,(rx symbol-start
136135
(or "case" "cond" "for" "if" "unless" "try" "receive"
137136
"raise" "quote" "unquote" "unquote_splicing" "throw"
138137
"super" "send")
139138
symbol-end))
140-
(builtin-declaration . ,(rx (or line-start (not (any ".")))
141-
symbol-start
139+
(builtin-declaration . ,(rx symbol-start
142140
(or "def" "defp" "defmodule" "defprotocol"
143141
"defmacro" "defmacrop" "defdelegate"
144142
"defexception" "defstruct" "defimpl"
145143
"defcallback" "defoverridable")
146144
symbol-end))
147-
(builtin-namespace . ,(rx (or line-start (not (any ".")))
148-
symbol-start
145+
(builtin-namespace . ,(rx symbol-start
149146
(or "import" "require" "use" "alias")
150147
symbol-end))
151148
;; Set aside code point syntax for `elixir-negation-face'.
@@ -163,12 +160,10 @@
163160
(identifiers . ,(rx (one-or-more (any "A-Z" "a-z" "_"))
164161
(zero-or-more (any "A-Z" "a-z" "0-9" "_"))
165162
(optional (or "?" "!"))))
166-
(keyword . ,(rx (or line-start (not (any ".")))
167-
symbol-start
163+
(keyword . ,(rx symbol-start
168164
(or "fn" "do" "end" "after" "else" "rescue" "catch")
169165
symbol-end))
170-
(keyword-operator . ,(rx (or line-start (not (any ".")))
171-
symbol-start
166+
(keyword-operator . ,(rx symbol-start
172167
(or "not" "and" "or" "when" "in")
173168
symbol-end))
174169
;; Module and submodule names start with upper case letter. This
@@ -321,8 +316,9 @@ is used to limit the scan."
321316
0 elixir-attribute-face)
322317

323318
;; Keywords
324-
(,(elixir-rx (group (or builtin builtin-declaration builtin-namespace
325-
keyword keyword-operator)))
319+
(,(elixir-rx (and (or line-start (not (any ".")))
320+
(group (or builtin builtin-declaration builtin-namespace
321+
keyword keyword-operator))))
326322
1 font-lock-keyword-face)
327323

328324
;; Function names, i.e. `def foo do'.

test/elixir-mode-font-test.el

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ end"
152152
end"
153153
(should (eq (elixir-test-face-at 91) 'font-lock-keyword-face))))
154154

155+
(ert-deftest elixir-mode-syntax-table/fontify-end-if-the-last-line-in-a-module-is-a-comment ()
156+
"https://github.com/elixir-lang/emacs-elixir/issues/283"
157+
:tags '(fontification syntax-table)
158+
(elixir-test-with-temp-buffer
159+
"defmodule Foo do
160+
# foo
161+
end"
162+
(should (eq (elixir-test-face-at 26) 'font-lock-keyword-face))))
163+
155164
(ert-deftest elixir-mode-syntax-table/fontify-heredoc/1 ()
156165
:tags '(fontification heredoc syntax-table)
157166
(elixir-test-with-temp-buffer

0 commit comments

Comments
 (0)