[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master f1ed39f 21/79: Pass comment and string tests with recursiv
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master f1ed39f 21/79: Pass comment and string tests with recursive colorizer. |
Date: |
Sun, 14 Jun 2015 00:05:24 +0000 |
branch: master
commit f1ed39f634a9c109e829ee79e9070026a6253050
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Pass comment and string tests with recursive colorizer.
---
context-coloring.el | 37 ++++++++++++++++++++++++++++++++++++-
test/context-coloring-test.el | 30 +++++++++++++-----------------
2 files changed, 49 insertions(+), 18 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index 174edde..a3a1887 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -333,6 +333,10 @@ provide visually \"instant\" updates at 60 frames per
second.")
(defconst context-coloring-OPEN-PARENTHESIS-CODE 4)
(defconst context-coloring-CLOSE-PARENTHESIS-CODE 5)
(defconst context-coloring-EXPRESSION-PREFIX-CODE 6)
+(defconst context-coloring-STRING-QUOTE-CODE 7)
+(defconst context-coloring-ESCAPE-CODE 9)
+(defconst context-coloring-COMMENT-START-CODE 11)
+(defconst context-coloring-COMMENT-END-CODE 12)
(defconst context-coloring-APOSTROPHE-CHAR (string-to-char "'"))
(defconst context-coloring-OPEN-PARENTHESIS-CHAR (string-to-char "("))
@@ -632,10 +636,37 @@ provide visually \"instant\" updates at 60 frames per
second.")
(t
(forward-char)))))
+(defun context-coloring-elisp-colorize-comment ()
+ (let ((start (point)))
+ (skip-syntax-forward "^>")
+ (context-coloring-maybe-colorize-comments-and-strings
+ start
+ (point))))
+
+(defun context-coloring-elisp-colorize-string ()
+ (let ((start (point))
+ (syntax-code (context-coloring-get-syntax-code)))
+ ;; Move past the opening string delimiter.
+ (forward-char)
+ (while (progn
+ (skip-syntax-forward "^\\\"")
+ (cond
+ ((= syntax-code context-coloring-ESCAPE-CODE)
+ ;; If there was an escape char, keep going.
+ (forward-char 2)
+ t)
+ ((= syntax-code context-coloring-STRING-QUOTE-CODE)
+ ;; If the string ended, move outside it.
+ (forward-char)
+ nil))))
+ (context-coloring-maybe-colorize-comments-and-strings
+ start
+ (point))))
+
(defun context-coloring-elisp-colorize-region (start end)
(let (syntax-code)
(goto-char start)
- (while (> end (progn (skip-syntax-forward "^()w_'" end)
+ (while (> end (progn (skip-syntax-forward "^()w_'<\"" end)
(point)))
(setq syntax-code (context-coloring-get-syntax-code))
(cond
@@ -644,6 +675,10 @@ provide visually \"instant\" updates at 60 frames per
second.")
(= syntax-code context-coloring-SYMBOL-CODE)
(= syntax-code context-coloring-EXPRESSION-PREFIX-CODE))
(context-coloring-elisp-colorize-sexp))
+ ((= 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))))))
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index f1ed4d2..4d59054 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -1101,23 +1101,19 @@ ssssssssssss0"))
111111 1 111 111
111111 1 1111111111 11 111 1 111 1 00001 10000 11 00001 1 100001111")))
-;; (context-coloring-test-deftest-emacs-lisp comment
-;; (lambda ()
-;; ;; Just check that the comment isn't parsed syntactically.
-;; (context-coloring-test-assert-coloring "
-;; (xxxxx x ()
-;; (xx (x xxxxx-xxxx xx) cccccccccc
-;; 11 00000-0000 11))) cccccccccc"))
-;; :before (lambda ()
-;; (setq context-coloring-syntactic-comments t)))
+(context-coloring-test-deftest-emacs-lisp comment
+ (lambda ()
+ ;; Just check that the comment isn't parsed syntactically.
+ (context-coloring-test-assert-coloring "
+(xxxxx x ()
+ (xx (x xxxxx-xxxx xx) cccccccccc
+ 11 00000-0000 11))) cccccccccc")))
-;; (context-coloring-test-deftest-emacs-lisp string
-;; (lambda ()
-;; (context-coloring-test-assert-coloring "
-;; (xxxxx x (x)
-;; (xxxxxx x x sss 1 0 sssss 0 1 sssssss11"))
-;; :before (lambda ()
-;; (setq context-coloring-syntactic-strings t)))
+(context-coloring-test-deftest-emacs-lisp string
+ (lambda ()
+ (context-coloring-test-assert-coloring "
+(xxxxx x (x)
+ (xxxxxx x x sss 1 0 sssss 0 1 sssssss11")))
(context-coloring-test-deftest-emacs-lisp ignored
(lambda ()
- [elpa] master 23cf7b3 09/79: Refactor derived mode tests., (continued)
- [elpa] master 23cf7b3 09/79: Refactor derived mode tests., Jackson Ray Hamilton, 2015/06/13
- [elpa] master fd2f2d0 08/79: Refactor remaining js tests., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 1f474d9 11/79: Reorganize functions., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 92166ba 13/79: Add no-fixture option., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 8ea8c9c 15/79: Pass defun test with recursive colorizer., Jackson Ray Hamilton, 2015/06/13
- [elpa] master ea6b4ef 14/79: Increase test documentation., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 7975003 18/79: Pass ignored test with recursive colorizer., Jackson Ray Hamilton, 2015/06/13
- [elpa] master d8b5f03 12/79: Remove before-all and after-all., Jackson Ray Hamilton, 2015/06/13
- [elpa] master bc0cb0d 16/79: Pass lambda test with recursive colorizer., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 6090eb3 17/79: Pass quote test with recursive colorizer., Jackson Ray Hamilton, 2015/06/13
- [elpa] master f1ed39f 21/79: Pass comment and string tests with recursive colorizer.,
Jackson Ray Hamilton <=
- [elpa] master d146af8 23/79: Fix string coloring., Jackson Ray Hamilton, 2015/06/13
- [elpa] master aaf4835 20/79: Remove let-varlist data structure. Cleanup., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 49265ab 25/79: Simplify comment and string parsing., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 52383b5 26/79: Handle octothorpes., Jackson Ray Hamilton, 2015/06/13
- [elpa] master a283883 24/79: Always colorize the remaining region., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 3d3c693 22/79: Pass interrupt test with recursive colorizer., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 966bd20 31/79: Add test for escape characters., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 7ab01e3 30/79: Fix ignored test., Jackson Ray Hamilton, 2015/06/13
- [elpa] master f88e21c 29/79: Ignore escaped characters., Jackson Ray Hamilton, 2015/06/13
- [elpa] master e06f1a6 27/79: Color comments and strings inside quotes., Jackson Ray Hamilton, 2015/06/13