File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 112112 " For use with atoms & map keys."
113113 :group 'font-lock-faces )
114114
115+ (defvar elixir-ignored-var-face 'elixir-ignored-var-face )
116+ (defface elixir-ignored-var-face
117+ '((((class color ) (min-colors 88 ) (background light ))
118+ :foreground " #424242" )
119+ (((class color ) (background dark ))
120+ (:foreground " #616161" ))
121+ (t nil ))
122+ " For use with ignored variables (starting with underscore)."
123+ :group 'font-lock-faces )
124+
115125(eval-when-compile
116126 (defconst elixir-rx-constituents
117127 `(
@@ -405,6 +415,14 @@ is used to limit the scan."
405415 (one-or-more " \n " )))
406416 1 font-lock-variable-name-face )
407417
418+ ; ; Gray out variables starting with "_"
419+ (,(elixir-rx symbol-start
420+ (group (and " _"
421+ (any " A-Z" " a-z" " 0-9" ))
422+ (zero-or-more (any " A-Z" " a-z" " 0-9" " _" ))
423+ (optional (or " ?" " !" ))))
424+ 1 elixir-ignored-var-face)
425+
408426 ; ; Map keys
409427 (,(elixir-rx (group (and (one-or-more identifiers) " :" )))
410428 1 elixir-atom-face)
Original file line number Diff line number Diff line change 426426"
427427 (should (eq (elixir-test-face-at 33 ) 'font-lock-string-face ))))
428428
429+ (ert-deftest elixir-mode-syntax-table/gray-out-ignored-var ()
430+ " https://github.com/elixir-lang/emacs-elixir/issues/292"
431+ :tags '(fontification syntax-table)
432+ (elixir-test-with-temp-buffer
433+ " variable
434+ _var
435+ _x
436+ _x!
437+ _x?
438+ _
439+ __MODULE__
440+ "
441+ (should (eq (elixir-test-face-at 4 ) nil ))
442+ (should (eq (elixir-test-face-at 14 ) 'font-lock-comment-face ))
443+ (should (eq (elixir-test-face-at 15 ) 'font-lock-comment-face ))
444+ (should (eq (elixir-test-face-at 23 ) 'font-lock-comment-face ))
445+ (should (eq (elixir-test-face-at 24 ) 'font-lock-comment-face ))
446+ (should (eq (elixir-test-face-at 30 ) 'font-lock-comment-face ))
447+ (should (eq (elixir-test-face-at 32 ) 'font-lock-comment-face ))
448+ (should (eq (elixir-test-face-at 38 ) 'font-lock-comment-face ))
449+ (should (eq (elixir-test-face-at 40 ) 'font-lock-comment-face ))
450+ (should (eq (elixir-test-face-at 46 ) 'font-lock-constant-face ))
451+ (should (eq (elixir-test-face-at 46 ) 'font-lock-constant-face ))
452+ (should (eq (elixir-test-face-at 52 ) 'font-lock-constant-face ))
453+ (should (eq (elixir-test-face-at 53 ) 'font-lock-constant-face ))
454+ (should (eq (elixir-test-face-at 55 ) 'font-lock-constant-face ))))
455+
429456(provide 'elixir-mode-font-test )
430457
431458; ;; elixir-mode-font-test.el ends here
You can’t perform that action at this time.
0 commit comments