[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master cacf5de 49/79: Add cond support.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master cacf5de 49/79: Add cond support. |
Date: |
Sun, 14 Jun 2015 00:05:37 +0000 |
branch: master
commit cacf5de396962d767d59ca203afc2cc3d0bb6d85
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Add cond support.
---
context-coloring.el | 37 +++++++++++++++++++++++++++++++++++++
test/context-coloring-test.el | 10 ++++++++++
test/fixtures/cond.el | 6 ++++++
3 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index f53066e..104964c 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -280,6 +280,14 @@ generated by `js2-mode'."
"Move forward through whitespace and comments."
(while (forward-comment 1)))
+(defsubst context-coloring-elisp-forward-sws ()
+ "Move forward through whitespace and comments, colorizing
+them along the way."
+ (let ((start (point)))
+ (context-coloring-forward-sws)
+ (context-coloring-elisp-colorize-comments-and-strings-in-region
+ start (point))))
+
(defsubst context-coloring-get-syntax-code ()
(syntax-class
;; Faster version of `syntax-after':
@@ -539,6 +547,31 @@ provide visually \"instant\" updates at 60 frames per
second.")
(defun context-coloring-elisp-colorize-let* ()
(context-coloring-elisp-colorize-defun-like t 'let*))
+(defun context-coloring-elisp-colorize-cond ()
+ (let (syntax-code)
+ ;; Enter.
+ (forward-char)
+ (context-coloring-elisp-forward-sws)
+ ;; Skip past the "cond".
+ (skip-syntax-forward "^w_")
+ (context-coloring-elisp-forward-sws)
+ (while (/= (setq syntax-code (context-coloring-get-syntax-code))
+ context-coloring-CLOSE-PARENTHESIS-CODE)
+ (cond
+ ((= syntax-code context-coloring-OPEN-PARENTHESIS-CODE)
+ ;; Colorize inside the parens.
+ (let ((start (point)))
+ (forward-sexp)
+ (context-coloring-elisp-colorize-region
+ (1+ start) (1- (point)))
+ ;; Exit.
+ (forward-char)))
+ (t
+ (forward-sexp)))
+ (context-coloring-elisp-forward-sws))
+ ;; Exit.
+ (forward-char)))
+
(defun context-coloring-elisp-colorize-parenthesized-sexp ()
(context-coloring-elisp-increment-sexp-count)
(let* ((start (point))
@@ -573,6 +606,10 @@ provide visually \"instant\" updates at 60 frames per
second.")
(goto-char start)
(context-coloring-elisp-colorize-lambda)
t)
+ ((string-equal "cond" name-string)
+ (goto-char start)
+ (context-coloring-elisp-colorize-cond)
+ t)
(t
nil)))))
;; Not a special form; just colorize the remaining region.
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index 7535817..c97228e 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -1152,6 +1152,16 @@ ssssssssssss0"))
2222 1 1 2 2 2 000022
1111 1 1 1 0 0 000011")))
+(context-coloring-test-deftest-emacs-lisp cond
+ (lambda ()
+ (context-coloring-test-assert-coloring "
+(xxx (x)
+ 11111
+ 11 11
+ 10000 11
+ 1111 1 00001 11
+ 11 11111 1 0000111)")))
+
(defun context-coloring-test-insert-unread-space ()
"Simulate the insertion of a space as if by a user."
(setq unread-command-events (cons '(t . 32)
diff --git a/test/fixtures/cond.el b/test/fixtures/cond.el
new file mode 100644
index 0000000..e05d255
--- /dev/null
+++ b/test/fixtures/cond.el
@@ -0,0 +1,6 @@
+(let (a)
+ (cond
+ (a t)
+ (free t)
+ ((eq a free) t)
+ (t (list a free))))
- [elpa] master acaaf39 38/79: Add file statistics to benchmarks., (continued)
- [elpa] master acaaf39 38/79: Add file statistics to benchmarks., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 8836df9 37/79: Add colorization times to logs., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 5661ed0 44/79: Document `:host' and `:port' properties., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 16fa835 40/79: Optimize JSON parser., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 3dfd515 42/79: Messy server implementation., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 872bf5f 46/79: Bump required scopifier version., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 2258572 39/79: Optimize. Refactor., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 59492ab 41/79: Refactor token application., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 233ea1a 47/79: Kill any scopifier server before running the tests., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 0079778 48/79: Set `:send-report' to nil., Jackson Ray Hamilton, 2015/06/13
- [elpa] master cacf5de 49/79: Add cond support.,
Jackson Ray Hamilton <=
- [elpa] master 8d15938 43/79: Cleaner server implementation., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 89286b6 54/79: Cleanup., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 5f9bd49 50/79: Add comments and strings to the cond test., Jackson Ray Hamilton, 2015/06/13
- [elpa] master c2834f0 51/79: Add condition-case support., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 2ee41c1 52/79: Add comments and strings to condition-case test., Jackson Ray Hamilton, 2015/06/13
- [elpa] master e387aaf 45/79: Merge branch 'server' into elisp, Jackson Ray Hamilton, 2015/06/13
- [elpa] master 77b075f 60/79: Space., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 5857bc8 53/79: Refactor comments and strings coloring., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 4bd7fc7 56/79: Make delays configurable at the dispatch level., Jackson Ray Hamilton, 2015/06/13
- [elpa] master f870598 59/79: Fix infinite loop when parsing let., Jackson Ray Hamilton, 2015/06/13