Skip to content

Commit 43a0905

Browse files
committed
Highlight module references equally
Closes #166
1 parent d39baa5 commit 43a0905

File tree

2 files changed

+15
-32
lines changed

2 files changed

+15
-32
lines changed

elixir-mode.el

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -201,25 +201,6 @@ for the Elixir programming language."
201201
"defexception" "defstruct" "defimpl"
202202
"defcallback")
203203
symbol-end))
204-
(builtin-modules . ,(rx symbol-start
205-
(or "Agent" "Application" "Atom" "Base"
206-
"Behaviour" "Bitwise" "Builtin" "Code" "Dict"
207-
"EEx" "Elixir" "Enum" "ExUnit" "Exception"
208-
"File" "File.Stat" "File.Stream" "Float"
209-
"Function" "GenEvent" "GenServer" "GenTCP"
210-
"HashDict" "HashSet" "IO" "IO.ANSI"
211-
"IO.Stream" "Inspect.Algebra" "Inspect.Opts"
212-
"Integer" "Kernel" "Kernel.ParallelCompiler"
213-
"Kernel.ParallelRequire" "Kernel.SpecialForms"
214-
"Kernel.Typespec" "Keyword" "List" "Macro"
215-
"Macro.Env" "Map" "Math" "Module" "Node"
216-
"OptionParser" "OrdDict" "Path" "Port"
217-
"Process" "Protocol" "Range" "Record" "Regex"
218-
"Set" "Stream" "String" "StringIO"
219-
"Supervisor" "Supervisor.Spec" "System" "Task"
220-
"Task.Supervisor" "Tuple" "URI"
221-
"UnboundMethod" "Version")
222-
symbol-end))
223204
(builtin-namespace . ,(rx symbol-start
224205
(or "import" "require" "use" "alias")
225206
symbol-end))
@@ -229,8 +210,8 @@ for the Elixir programming language."
229210
anything
230211
symbol-end))
231212
(function-declaration . ,(rx symbol-start
232-
(or "def" "defp")
233-
symbol-end))
213+
(or "def" "defp")
214+
symbol-end))
234215
;; Match `@doc' or `@moduledoc' syntax, with or without triple quotes.
235216
(heredocs . ,(rx symbol-start
236217
(or "@doc" "@moduledoc" "~s")
@@ -259,7 +240,7 @@ for the Elixir programming language."
259240
(zero-or-more
260241
(and "."
261242
(one-or-more (any "A-Z" "_"))
262-
(zero-or-more (any "A-Z" "a-z" "_" "0-9"))))
243+
(zero-or-more (any "A-Z" "a-z" "_" "0-9"))))
263244
(optional (or "!" "?"))
264245
symbol-end))
265246
(operators1 . ,(rx symbol-start
@@ -296,12 +277,6 @@ for the Elixir programming language."
296277
;; String interpolation
297278
(elixir-match-interpolation 0 font-lock-variable-name-face t)
298279

299-
;; Module-defining & namespace builtins
300-
(,(elixir-rx (or builtin-declaration builtin-namespace)
301-
space
302-
(group module-names))
303-
1 font-lock-type-face)
304-
305280
;; Module attributes
306281
(,(elixir-rx (group (or heredocs
307282
(and "@" (1+ identifiers)))))
@@ -357,6 +332,10 @@ for the Elixir programming language."
357332
(and "<" (group (one-or-more (not (any ">")))) ">"))
358333
1 font-lock-string-face)
359334

335+
;; Modules
336+
(,(elixir-rx (group module-names))
337+
1 font-lock-type-face)
338+
360339
;; Atoms and singleton-like words like true/false/nil.
361340
(,(elixir-rx (group atoms))
362341
1 elixir-atom-face)
@@ -365,8 +344,8 @@ for the Elixir programming language."
365344
(,(elixir-rx (group (and (one-or-more identifiers) ":")))
366345
1 elixir-atom-face)
367346

368-
;; Built-in modules and pseudovariables
369-
(,(elixir-rx (group (or builtin-modules pseudo-var)))
347+
;; Pseudovariables
348+
(,(elixir-rx (group pseudo-var))
370349
1 font-lock-constant-face)
371350

372351
;; Code points

test/elixir-mode-font-test.el

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ buffer."
3232
:tags '(fontification syntax-table)
3333
(elixir-test-with-temp-buffer
3434
"defmodule Application.Behavior do
35-
use Application.Behaviour"
35+
use Application.Behaviour
36+
Stand.Alone.call"
3637
(should (eq (elixir-test-face-at 1) 'font-lock-keyword-face))
3738
(should (eq (elixir-test-face-at 11) 'font-lock-type-face))
3839
(should (eq (elixir-test-face-at 22) 'font-lock-type-face))
@@ -41,7 +42,10 @@ buffer."
4142
(should (eq (elixir-test-face-at 37) 'font-lock-keyword-face))
4243
(should (eq (elixir-test-face-at 41) 'font-lock-type-face))
4344
(should (eq (elixir-test-face-at 52) 'font-lock-type-face))
44-
(should (eq (elixir-test-face-at 53) 'font-lock-type-face))))
45+
(should (eq (elixir-test-face-at 53) 'font-lock-type-face))
46+
(should (eq (elixir-test-face-at 68) 'font-lock-type-face))
47+
(should (eq (elixir-test-face-at 72) 'font-lock-type-face))
48+
(should (eq (elixir-test-face-at 79) nil))))
4549

4650
(ert-deftest elixir-mode-syntax-table/fontify-regex-with-quote ()
4751
"https://github.com/elixir-lang/emacs-elixir/issues/23"

0 commit comments

Comments
 (0)