Skip to content

Commit 7f33dc6

Browse files
committed
Merge pull request #252 from syohex/fix-after-dot-highlighting
Fix after dot highlighting
2 parents 87f82cb + bda0e8f commit 7f33dc6

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

elixir-mode.el

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,26 +130,30 @@
130130
(zero-or-more (any "a-z" "A-Z" "0-9" "_" "\"" "'")))
131131
(and "\"" (one-or-more (not (any "\""))) "\"")
132132
(and "'" (one-or-more (not (any "'"))) "'"))))
133-
(builtin . ,(rx symbol-start
133+
(builtin . ,(rx (or line-start (not (any ".")))
134+
symbol-start
134135
(or "case" "cond" "for" "if" "unless" "try" "receive"
135136
"raise" "quote" "unquote" "unquote_splicing" "throw"
136137
"super")
137138
symbol-end))
138-
(builtin-declaration . ,(rx symbol-start
139+
(builtin-declaration . ,(rx (or line-start (not (any ".")))
140+
symbol-start
139141
(or "def" "defp" "defmodule" "defprotocol"
140142
"defmacro" "defmacrop" "defdelegate"
141143
"defexception" "defstruct" "defimpl"
142144
"defcallback")
143145
symbol-end))
144-
(builtin-namespace . ,(rx symbol-start
146+
(builtin-namespace . ,(rx (or line-start (not (any ".")))
147+
symbol-start
145148
(or "import" "require" "use" "alias")
146149
symbol-end))
147150
;; Set aside code point syntax for `elixir-negation-face'.
148151
(code-point . ,(rx symbol-start
149152
"?"
150153
anything
151154
symbol-end))
152-
(function-declaration . ,(rx symbol-start
155+
(function-declaration . ,(rx (or line-start (not (any ".")))
156+
symbol-start
153157
(or "def" "defp")
154158
symbol-end))
155159
;; Match `@doc' or `@moduledoc' syntax, with or without triple quotes.
@@ -162,10 +166,12 @@
162166
(identifiers . ,(rx (one-or-more (any "A-Z" "a-z" "_"))
163167
(zero-or-more (any "A-Z" "a-z" "0-9" "_"))
164168
(optional (or "?" "!"))))
165-
(keyword . ,(rx symbol-start
169+
(keyword . ,(rx (or line-start (not (any ".")))
170+
symbol-start
166171
(or "fn" "do" "end" "after" "else" "rescue" "catch")
167172
symbol-end))
168-
(keyword-operator . ,(rx symbol-start
173+
(keyword-operator . ,(rx (or line-start (not (any ".")))
174+
symbol-start
169175
(or "not" "and" "or" "when" "in")
170176
symbol-end))
171177
;; Module and submodule names start with upper case letter. This

test/elixir-mode-font-test.el

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,31 @@ some_expr"
257257
(should (eq (elixir-test-face-at 6) 'font-lock-variable-name-face))
258258
(should (eq (elixir-test-face-at 12) 'font-lock-variable-name-face))))
259259

260+
(ert-deftest elixir-mode-syntax-table/fontify-keyword-after-dot ()
261+
"https://github.com/elixir-lang/emacs-elixir/issues/250"
262+
:tags '(fontification syntax-table)
263+
(elixir-test-with-temp-buffer
264+
"Mix.raise
265+
raise
266+
Mix.def foo
267+
Mix.import
268+
import
269+
Mix.after
270+
after
271+
Mix.when
272+
when"
273+
(should-not (eq (elixir-test-face-at 5) 'font-lock-keyword-face))
274+
(should (eq (elixir-test-face-at 11) 'font-lock-keyword-face))
275+
(should-not (eq (elixir-test-face-at 21) 'font-lock-keyword-face))
276+
(should-not (eq (elixir-test-face-at 25) 'font-lock-function-name-face))
277+
(should-not (eq (elixir-test-face-at 33) 'font-lock-keyword-face))
278+
(should (eq (elixir-test-face-at 40) 'font-lock-keyword-face))
279+
280+
(should-not (eq (elixir-test-face-at 51) 'font-lock-keyword-face))
281+
(should (eq (elixir-test-face-at 57) 'font-lock-keyword-face))
282+
(should-not (eq (elixir-test-face-at 67) 'font-lock-keyword-face))
283+
(should (eq (elixir-test-face-at 72) 'font-lock-keyword-face))))
284+
260285
(provide 'elixir-mode-font-test)
261286

262287
;;; elixir-mode-font-test.el ends here

0 commit comments

Comments
 (0)