|
1 |
| -;;; elixir-mode.el --- Major mode for editing Elixir files |
| 1 | +;;; elixir-mode.el --- Major mode for editing Elixir files -*- lexical-binding: t -*- |
2 | 2 |
|
3 | 3 | ;; Copyright 2011-2015 secondplanet
|
4 | 4 | ;; 2013-2015 Samuel Tonini, Matt DeBoard, Andreas Fuchs
|
|
10 | 10 | ;; URL: https://github.com/elixir-editors/emacs-elixir
|
11 | 11 | ;; Created: Mon Nov 7 2011
|
12 | 12 | ;; Keywords: languages elixir
|
13 |
| -;; Version: 2.3.1 |
| 13 | +;; Version: 2.4.0 |
14 | 14 | ;; Package-Requires: ((emacs "24") (pkg-info "0.4"))
|
15 | 15 |
|
16 | 16 | ;; This file is not a part of GNU Emacs.
|
|
48 | 48 | :link '(url-link :tag "Github" "https://github.com/elixir-editors/emacs-elixir")
|
49 | 49 | :link '(emacs-commentary-link :tag "Commentary" "elixir-mode"))
|
50 | 50 |
|
51 |
| -(defvar elixir-mode-website-url "http://elixir-lang.org" |
52 |
| - "Official url of Elixir programming website.") |
| 51 | +(defcustom elixir-mode-website-url "http://elixir-lang.org" |
| 52 | + "Official url of Elixir programming website." |
| 53 | + :type 'string) |
53 | 54 |
|
54 |
| -(defvar elixir-mode-doc-url "https://hexdocs.pm/elixir" |
55 |
| - "Official documentation for the Elixir programming language.") |
| 55 | +(defcustom elixir-mode-doc-url "https://hexdocs.pm/elixir" |
| 56 | + "Official documentation for the Elixir programming language." |
| 57 | + :type 'string) |
56 | 58 |
|
57 |
| -(defvar elixir-mode-hook nil) |
| 59 | +(defcustom elixir-mode-hook nil |
| 60 | + "Hook that runs when switching to major mode" |
| 61 | + :type 'hook) |
58 | 62 |
|
59 | 63 | (defvar elixir-mode-map
|
60 | 64 | (let ((map (make-sparse-keymap)))
|
|
72 | 76 | ("Tests" "^\\s-*test[ \t\n]+\"?\\(:?[a-z0-9_@+() \t-]+\\)\"?[ \t\n]+.*" 1))
|
73 | 77 | "Imenu pattern for `elixir-mode'.")
|
74 | 78 |
|
75 |
| -(defvar elixir-basic-offset 2) |
76 |
| -(defvar elixir-key-label-offset 0) |
77 |
| -(defvar elixir-match-label-offset 2) |
| 79 | +(defcustom elixir-basic-offset 2 |
| 80 | + "Basic offset." |
| 81 | + :type 'integer) |
| 82 | +(defcustom elixir-key-label-offset 0 |
| 83 | + "Offset used for key label." |
| 84 | + :type 'integer) |
| 85 | +(defcustom elixir-match-label-offset 2 |
| 86 | + "Offset for a match label." |
| 87 | + :type 'integer) |
| 88 | + |
| 89 | +(defgroup elixir-faces nil |
| 90 | + "Font-lock faces for `elixir'." |
| 91 | + :group 'elixir |
| 92 | + :group 'faces) |
78 | 93 |
|
79 | 94 | (defvar elixir-attribute-face 'elixir-attribute-face)
|
80 | 95 | (defface elixir-attribute-face
|
81 | 96 | '((t (:inherit font-lock-preprocessor-face)))
|
82 |
| - "For use with module attribute tokens." |
83 |
| - :group 'font-lock-faces) |
| 97 | + "For use with module attribute tokens.") |
84 | 98 |
|
85 | 99 | (defvar elixir-atom-face 'elixir-atom-face)
|
86 | 100 | (defface elixir-atom-face
|
87 | 101 | '((t (:inherit font-lock-builtin-face)))
|
88 |
| - "For use with atoms & map keys." |
89 |
| - :group 'font-lock-faces) |
| 102 | + "For use with atoms & map keys.") |
| 103 | + |
| 104 | +(defvar elixir-number-face 'elixir-number-face) |
| 105 | +(defface elixir-number-face |
| 106 | + '((t (:inherit default))) |
| 107 | + "For use with numbers.") |
| 108 | + |
90 | 109 |
|
91 | 110 | (eval-when-compile
|
92 | 111 | (defconst elixir-rx-constituents
|
|
107 | 126 | (zero-or-more (any "a-z" "A-Z" "0-9" "_" "\"" "'" "!" "@" "?")))
|
108 | 127 | (and "\"" (one-or-more (not (any "\""))) "\"")
|
109 | 128 | (and "'" (one-or-more (not (any "'"))) "'"))))
|
| 129 | + (numbers . ,(rx (and symbol-start |
| 130 | + (? "-") |
| 131 | + (+ digit) |
| 132 | + (0+ (and "_" (= 3 digit))) |
| 133 | + symbol-end))) |
110 | 134 | (builtin . ,(rx symbol-start
|
111 | 135 | (or "case" "cond" "for" "if" "quote" "raise" "receive" "send"
|
112 | 136 | "super" "throw" "try" "unless" "unquote" "unquote_splicing"
|
@@ -382,6 +406,10 @@ is used to limit the scan."
|
382 | 406 | (optional "="))
|
383 | 407 | 1 elixir-atom-face)
|
384 | 408 |
|
| 409 | + ;; Numbers |
| 410 | + (,(elixir-rx (group numbers)) |
| 411 | + 1 elixir-number-face) |
| 412 | + |
385 | 413 | ;; Gray out variables starting with "_"
|
386 | 414 | (,(elixir-rx symbol-start
|
387 | 415 | (group (and "_"
|
|
0 commit comments