Skip to content

Commit 3f8f409

Browse files
committed
Allow highlighting for numbers
1 parent bd417aa commit 3f8f409

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

elixir-mode.el

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@
8888
"For use with atoms & map keys."
8989
:group 'font-lock-faces)
9090

91+
(defvar elixir-number-face 'elixir-number-face)
92+
(defface elixir-number-face
93+
'((t (:inherit font-lock-builtin-face)))
94+
"For use with numbers."
95+
:group 'font-lock-faces)
96+
97+
9198
(eval-when-compile
9299
(defconst elixir-rx-constituents
93100
`(
@@ -107,6 +114,11 @@
107114
(zero-or-more (any "a-z" "A-Z" "0-9" "_" "\"" "'" "!" "@" "?")))
108115
(and "\"" (one-or-more (not (any "\""))) "\"")
109116
(and "'" (one-or-more (not (any "'"))) "'"))))
117+
(numbers . ,(rx (and symbol-start
118+
(? "-")
119+
(+ digit)
120+
(0+ (and "_" (= 3 digit)))
121+
symbol-end)))
110122
(builtin . ,(rx symbol-start
111123
(or "case" "cond" "for" "if" "quote" "raise" "receive" "send"
112124
"super" "throw" "try" "unless" "unquote" "unquote_splicing"
@@ -382,6 +394,10 @@ is used to limit the scan."
382394
(optional "="))
383395
1 elixir-atom-face)
384396

397+
;; Numbers
398+
(,(elixir-rx (group numbers))
399+
1 elixir-number-face)
400+
385401
;; Gray out variables starting with "_"
386402
(,(elixir-rx symbol-start
387403
(group (and "_"

0 commit comments

Comments
 (0)