Skip to content

Improve regex for defmodule highlighting. #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 19, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions elixir-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,27 @@
(or "+" "++" "<>" "-" "/" "*" "div" "rem" "==" "!=" "<="
"<" ">=" ">" "===" "!==" "and" "or" "not" "&&" "||"
"!" "." "#" "=" ":=" "<-")))
(resource-name . ,(rx symbol-start
(zero-or-more (any "A-Z")
(zero-or-more
(any "a-z"))
"."
(any "A-Z")
(zero-or-more
(any "a-z")))
symbol-end))
;; Module and submodule names start with upper case letter or `_'. This
;; can then be followed by any combination of alphanumeric chars + `_'.
;; In turn, this can be followed by a `.' which begins the notation of
;; a submodule, which follows the same naming pattern of the module.
;; Finally, like other identifiers, it can be terminated with either `?'
;; or `!'.
(module-names . ,(rx symbol-start
(one-or-more (any "A-Z" "_"))
(zero-or-more (any "A-Z" "a-z" "_" "0-9"))
(zero-or-more
(and "."
(one-or-more (any "A-Z" "_"))
(zero-or-more (any "A-Z" "a-z" "_" "0-9"))))
(optional (or "!" "?"))
symbol-end))
;; The first character of an identifier must be a letter or an underscore.
;; After that, they may contain any alphanumeric character + underscore.
;; Additionally, the final character may be either `?' or `!'.
(identifiers . ,(rx symbol-start
(one-or-more (any "A-Z" "a-z""_"))
(zero-or-more (any "0-9" "_"))
(zero-or-more (any "A-Z" "a-z" "0-9" "_"))
(optional (or "?" "!"))
symbol-end))
(atoms . ,(rx ":"
Expand All @@ -310,10 +319,10 @@

(defconst elixir-mode-font-lock-defaults
`(
;; Import, module- and method-defining keywords
(,(elixir-rx (or method-defines module-defines imports)
;; Module-defining & namespace builtins
(,(elixir-rx (or module-defines imports)
space
(group resource-name))
(group module-names))
1 font-lock-type-face)

;; Keywords
Expand Down