branch: master commit e06f1a6194abaec8dffd684b75c805500b7191b6 Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com> Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
Color comments and strings inside quotes. --- context-coloring.el | 27 +++++++++++++++++++-------- test/context-coloring-test.el | 6 +++++- test/fixtures/quote.el | 4 ++++ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/context-coloring.el b/context-coloring.el index 459aca0..9b53fd1 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -593,18 +593,15 @@ generated by `js2-mode'." symbol-string)))))) (defun context-coloring-elisp-colorize-expression-prefix () - (let (start - end - char) - (setq char (char-after)) + (let ((char (char-after)) + (start (point)) + (end (progn (forward-sexp) + (point)))) (cond ((or (= char context-coloring-APOSTROPHE-CHAR) (= char context-coloring-OCTOTHORPE-CHAR)) - (forward-sexp)) + (context-coloring-elisp-colorize-comments-and-strings-in-region start end)) ((= char context-coloring-BACKTICK-CHAR) - (setq start (point)) - (forward-sexp) - (setq end (point)) (goto-char start) (while (> end (progn (forward-char) (point))) @@ -668,6 +665,20 @@ provide visually \"instant\" updates at 60 frames per second.") start (point)))) +(defun context-coloring-elisp-colorize-comments-and-strings-in-region (start end) + (let (syntax-code) + (goto-char start) + (while (> end (progn (skip-syntax-forward "^<\"" end) + (point))) + (setq syntax-code (context-coloring-get-syntax-code)) + (cond + ((= syntax-code context-coloring-COMMENT-START-CODE) + (context-coloring-elisp-colorize-comment)) + ((= syntax-code context-coloring-STRING-QUOTE-CODE) + (context-coloring-elisp-colorize-string)) + (t + (forward-char)))))) + (defun context-coloring-elisp-colorize-region (start end) (let (syntax-code) (goto-char start) diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el index 2a9cdd0..2f519f9 100644 --- a/test/context-coloring-test.el +++ b/test/context-coloring-test.el @@ -1099,7 +1099,11 @@ ssssssssssss0")) (xxxxx x (x) (xx (xx x 111 111111 1 111 111 - 111111 1 1111111111 11 111 1 111 1 00001 10000 11 00001 1 100001111"))) + 111111 1 1111111111 11 111 1 111 1 00001 10000 11 00001 1 100001111 + +(xxxxxx '(sss cc + sss cc + ))"))) (context-coloring-test-deftest-emacs-lisp comment (lambda () diff --git a/test/fixtures/quote.el b/test/fixtures/quote.el index 654bc70..8a282da 100644 --- a/test/fixtures/quote.el +++ b/test/fixtures/quote.el @@ -2,3 +2,7 @@ (or (eq a 'b) (equal a '(a b)) (equal a `(,(append () `(a b ,(+ 1 free) ,free b) free) b ,free)))) + +(append '("a" ; b + "b" ; a + ))