branch: master commit 284cfa6f6743c270c6dc8e9a383c29e450ad3ade Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com> Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
Don't treat unbindables like variables. --- context-coloring.el | 6 ++++-- test/context-coloring-test.el | 5 +++++ test/fixtures/unbindable.el | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/context-coloring.el b/context-coloring.el index 92e4578..3bd2b0f 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -526,8 +526,10 @@ generated by `js2-mode'." token-pos variable-end)) (cond - ;; Ignore numbers - ((string-match-p "\\`[-+]?[0-9]" variable-string)) + ;; Ignore constants such as numbers, keywords, t, nil. These can't + ;; be rebound, so they should be treated like syntax. + ((string-match-p "\\`[-+]?[0-9]\\|\\`t\\'\\|\\`nil\\'" variable-string)) + ((keywordp (read variable-string))) (t (setq variable (intern variable-string)) (setq variable-scope-level diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el index 192d2ef..8e5b699 100644 --- a/test/context-coloring-test.el +++ b/test/context-coloring-test.el @@ -1077,6 +1077,11 @@ see that function." :setup (lambda () (setq context-coloring-syntactic-strings t))) +(context-coloring-test-deftest-emacs-lisp-mode unbindable + (lambda () + (context-coloring-test-assert-region-level 20 40 1) ; 1 +1 -1 1.0 :a t nil + )) + (provide 'context-coloring-test) ;;; context-coloring-test.el ends here diff --git a/test/fixtures/unbindable.el b/test/fixtures/unbindable.el new file mode 100644 index 0000000..d5bb47f --- /dev/null +++ b/test/fixtures/unbindable.el @@ -0,0 +1,2 @@ +(defun a () + (+ a 1 +1 -1 1.0 :a t nil))