[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 6090eb3 17/79: Pass quote test with recursive colorizer.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master 6090eb3 17/79: Pass quote test with recursive colorizer. |
Date: |
Sun, 14 Jun 2015 00:05:20 +0000 |
branch: master
commit 6090eb3246079470ad7da359ecf9660fccd806c1
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Pass quote test with recursive colorizer.
---
context-coloring.el | 87 ++++++++++++++++++++++++++++++++---------
test/context-coloring-test.el | 14 +++---
2 files changed, 75 insertions(+), 26 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index 8972da9..5b5fb08 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -403,14 +403,16 @@ generated by `js2-mode'."
"\\`[^&:]")
(defconst context-coloring-ignored-word-regexp
- (concat "\\`[-+]?[0-9]\\|" (context-coloring-exact-or-regexp
- '("t" "nil" "." "?"))))
+ (concat "\\`[&:-+]?[0-9]\\|" (context-coloring-exact-or-regexp
+ '("t" "nil" "." "?"))))
(defconst context-coloring-WORD-CODE 2)
(defconst context-coloring-SYMBOL-CODE 3)
(defconst context-coloring-OPEN-PARENTHESIS-CODE 4)
(defconst context-coloring-CLOSE-PARENTHESIS-CODE 5)
+(defconst context-coloring-EXPRESSION-PREFIX-CODE 6)
+(defconst context-coloring-APOSTROPHE-CHAR (string-to-char "'"))
(defconst context-coloring-OPEN-PARENTHESIS-CHAR (string-to-char "("))
(defconst context-coloring-COMMA-CHAR (string-to-char ","))
(defconst context-coloring-BACKTICK-CHAR (string-to-char "`"))
@@ -565,7 +567,7 @@ provide visually \"instant\" updates at 60 frames per
second.")
(defun context-coloring-elisp-colorize-lambda ()
(context-coloring-elisp-colorize-defun t))
-(defun context-coloring-elisp-colorize-sexp ()
+(defun context-coloring-elisp-colorize-parenthesized-sexp ()
(let ((start (point))
end
syntax
@@ -610,31 +612,78 @@ provide visually \"instant\" updates at 60 frames per
second.")
(goto-char start)
(forward-sexp)))))
+(defun context-coloring-elisp-colorize-symbol ()
+ (let (symbol-pos
+ symbol-end
+ symbol-string)
+ (setq symbol-pos (point))
+ (forward-sexp)
+ (setq symbol-end (point))
+ (setq symbol-string (buffer-substring-no-properties
+ symbol-pos
+ symbol-end))
+ (cond
+ ((string-match-p context-coloring-ignored-word-regexp symbol-string))
+ (t
+ (context-coloring-colorize-region
+ symbol-pos
+ symbol-end
+ (context-coloring-elisp-get-variable-level
+ (buffer-substring-no-properties
+ symbol-pos
+ symbol-end)))))))
+
+(defun context-coloring-elisp-colorize-expression-prefix ()
+ (let (start
+ end
+ char)
+ (setq char (char-after))
+ (cond
+ ((= char context-coloring-APOSTROPHE-CHAR)
+ (forward-sexp))
+ ((= char context-coloring-BACKTICK-CHAR)
+ (setq start (point))
+ (forward-sexp)
+ (setq end (point))
+ (goto-char start)
+ (while (> end (progn (forward-char)
+ (point)))
+ (setq char (char-after))
+ (when (= char context-coloring-COMMA-CHAR)
+ (forward-char)
+ (skip-syntax-forward " ")
+ (context-coloring-elisp-colorize-sexp)))))))
+
+(defun context-coloring-elisp-colorize-sexp ()
+ (let (syntax
+ syntax-code)
+ (setq syntax (syntax-after (point)))
+ (setq syntax-code (syntax-class syntax))
+ (cond
+ ((= syntax-code context-coloring-OPEN-PARENTHESIS-CODE)
+ (context-coloring-elisp-colorize-parenthesized-sexp))
+ ((or (= syntax-code context-coloring-WORD-CODE)
+ (= syntax-code context-coloring-SYMBOL-CODE))
+ (context-coloring-elisp-colorize-symbol))
+ ((= syntax-code context-coloring-EXPRESSION-PREFIX-CODE)
+ (context-coloring-elisp-colorize-expression-prefix))
+ (t
+ (forward-char)))))
+
(defun context-coloring-elisp-colorize-region (start end)
(let (syntax
- syntax-code
- word-n-pos
- word-n-end)
+ syntax-code)
(goto-char start)
(while (> end (progn (skip-syntax-forward "^()w_'" end)
(point)))
(setq syntax (syntax-after (point)))
(setq syntax-code (syntax-class syntax))
(cond
- ((= syntax-code context-coloring-OPEN-PARENTHESIS-CODE)
+ ((or (= syntax-code context-coloring-OPEN-PARENTHESIS-CODE)
+ (= syntax-code context-coloring-WORD-CODE)
+ (= syntax-code context-coloring-SYMBOL-CODE)
+ (= syntax-code context-coloring-EXPRESSION-PREFIX-CODE))
(context-coloring-elisp-colorize-sexp))
- ((or (= syntax-code context-coloring-WORD-CODE)
- (= syntax-code context-coloring-SYMBOL-CODE))
- (setq word-n-pos (point))
- (forward-sexp)
- (setq word-n-end (point))
- (context-coloring-colorize-region
- word-n-pos
- word-n-end
- (context-coloring-elisp-get-variable-level
- (buffer-substring-no-properties
- word-n-pos
- word-n-end))))
(t
(forward-char))))))
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index 4b8a939..2d8cfc9 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -1093,13 +1093,13 @@ ssssssssssss0"))
11111111 11 2222222 2222
222 22 12 2221 111 0 00")))
-;; (context-coloring-test-deftest-emacs-lisp quote
-;; (lambda ()
-;; (context-coloring-test-assert-coloring "
-;; (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")))
+(context-coloring-test-deftest-emacs-lisp quote
+ (lambda ()
+ (context-coloring-test-assert-coloring "
+(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")))
;; (context-coloring-test-deftest-emacs-lisp comment
;; (lambda ()
- [elpa] master 5e0a0d9 10/79: Newlines., (continued)
- [elpa] master 5e0a0d9 10/79: Newlines., Jackson Ray Hamilton, 2015/06/13
- [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 <=
- [elpa] master f1ed39f 21/79: Pass comment and string tests with recursive colorizer., Jackson Ray Hamilton, 2015/06/13
- [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