[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 72a0998 73/79: Add quote and backquote function support.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master 72a0998 73/79: Add quote and backquote function support. |
Date: |
Sun, 14 Jun 2015 00:05:47 +0000 |
branch: master
commit 72a09987d2562df79c288011313b5bbbd30a3c42
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Add quote and backquote function support.
---
context-coloring.el | 78 ++++++++++++++++++++++++++++-------------
test/context-coloring-test.el | 3 ++
test/fixtures/quote.el | 3 ++
3 files changed, 59 insertions(+), 25 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index a9bcdac..b1bede5 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -819,6 +819,17 @@ with CALLBACK."
;; Exit.
(forward-char))))))
+(defun context-coloring-elisp-colorize-quote ()
+ "Color the `quote' at point."
+ (let* ((start (point))
+ (end (progn (forward-sexp)
+ (point))))
+ (context-coloring-colorize-region
+ start
+ end
+ (context-coloring-elisp-get-current-scope-level))
+ (context-coloring-elisp-colorize-comments-and-strings-in-region start
end)))
+
(defun context-coloring-elisp-colorize-parenthesized-sexp ()
"Color the sexp enclosed by parenthesis at point."
(context-coloring-elisp-increment-sexp-count)
@@ -871,6 +882,14 @@ with CALLBACK."
(goto-char start)
(context-coloring-elisp-colorize-defadvice)
t)
+ ((string-equal "quote" name-string)
+ (goto-char start)
+ (context-coloring-elisp-colorize-quote)
+ t)
+ ((string-equal "backquote" name-string)
+ (goto-char start)
+ (context-coloring-elisp-colorize-backquote)
+ t)
(t
nil)))))
;; Not a special form; just colorize the remaining region.
@@ -900,35 +919,44 @@ with CALLBACK."
(context-coloring-elisp-get-variable-level
symbol-string))))))
+(defun context-coloring-elisp-colorize-backquote-form ()
+ "Color the backquote form at point."
+ (let ((start (point))
+ (end (progn (forward-sexp)
+ (point)))
+ char)
+ (goto-char start)
+ (while (> end (progn (forward-char)
+ (point)))
+ (setq char (char-after))
+ (when (= char context-coloring-COMMA-CHAR)
+ (forward-char)
+ (when (= (char-after) context-coloring-AT-CHAR)
+ ;; If we don't do this "@" could be interpreted as a symbol.
+ (forward-char))
+ (context-coloring-elisp-forward-sws)
+ (context-coloring-elisp-colorize-sexp)))
+ ;; We could probably do this as part of the above loop but it'd be
+ ;; repetitive.
+ (context-coloring-elisp-colorize-comments-and-strings-in-region
+ start end)))
+
+(defun context-coloring-elisp-colorize-backquote ()
+ "Color the `backquote' at point."
+ (context-coloring-elisp-skip-callee-name)
+ (context-coloring-elisp-colorize-backquote-form)
+ ;; Exit.
+ (forward-char))
+
(defun context-coloring-elisp-colorize-expression-prefix ()
"Color the expression prefix and the following expression at
point. It could be a quoted or backquoted expression."
(context-coloring-elisp-increment-sexp-count)
- (let ((char (char-after))
- start
- end)
- (cond
- ((/= char context-coloring-BACKTICK-CHAR)
- (context-coloring-elisp-forward-sexp))
- (t
- (setq start (point))
- (setq end (progn (forward-sexp)
- (point)))
- (goto-char start)
- (while (> end (progn (forward-char)
- (point)))
- (setq char (char-after))
- (when (= char context-coloring-COMMA-CHAR)
- (forward-char)
- (when (= (char-after) context-coloring-AT-CHAR)
- ;; If we don't do this "@" could be interpreted as a symbol.
- (forward-char))
- (context-coloring-elisp-forward-sws)
- (context-coloring-elisp-colorize-sexp)))
- ;; We could probably do this as part of the above loop but it'd be
- ;; repetitive.
- (context-coloring-elisp-colorize-comments-and-strings-in-region
- start end)))))
+ (cond
+ ((/= (char-after) context-coloring-BACKTICK-CHAR)
+ (context-coloring-elisp-forward-sexp))
+ (t
+ (context-coloring-elisp-colorize-backquote-form))))
(defun context-coloring-elisp-colorize-comment ()
"Color the comment at point."
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index 291b36a..cce22a3 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -1094,6 +1094,9 @@ ssssssssssss0"))
(context-coloring-test-deftest-emacs-lisp quote
(lambda ()
(context-coloring-test-assert-coloring "
+(xxxxx 0000000 00 00000)
+(xxx () (xxxxxxxxx (,0000)))
+
(xxxxx x (x)
(xx (xx x 111
111111 1 111 111
diff --git a/test/fixtures/quote.el b/test/fixtures/quote.el
index 63892a0..5fc126d 100644
--- a/test/fixtures/quote.el
+++ b/test/fixtures/quote.el
@@ -1,3 +1,6 @@
+(quote (lambda () free))
+(let () (backquote (,free)))
+
(defun a (a)
(or (eq a 'b)
(equal a '(a b))
- [elpa] master d2e08e8 62/79: Improve and test lazy coloring., (continued)
- [elpa] master d2e08e8 62/79: Improve and test lazy coloring., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 46a9193 65/79: Find the edges of the screen more efficiently., Jackson Ray Hamilton, 2015/06/13
- [elpa] master fd4bc95 66/79: Add dolist support., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 9edc6c3 69/79: Checkdoc cleanup., Jackson Ray Hamilton, 2015/06/13
- [elpa] master e2ceef9 57/79: Prepend function symbols with octothorpes., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 22403b7 61/79: Cover parsing edge cases., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 67576b5 72/79: Skip all insignificant expression prefixes., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 306335e 71/79: Add defadvice support., Jackson Ray Hamilton, 2015/06/13
- [elpa] master acf15ae 70/79: Remove if., Jackson Ray Hamilton, 2015/06/13
- [elpa] master ed870d8 68/79: Refactor minor mode definition., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 72a0998 73/79: Add quote and backquote function support.,
Jackson Ray Hamilton <=
- [elpa] master a4a136c 74/79: Refactor defun / defadvice name handling., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 69ea835 67/79: Refactor elisp parsers using helper functions., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 9b436c0 76/79: Fully recolor later after a fast recolor., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 40f67bf 78/79: Version 6.4.0., Jackson Ray Hamilton, 2015/06/13
- [elpa] master c81eecb 58/79: Update function names and docstrings., Jackson Ray Hamilton, 2015/06/13
- [elpa] master f7c6dcb 75/79: Refactor callee dispatching., Jackson Ray Hamilton, 2015/06/13
- [elpa] master fff08de 36/79: Add elisp benchmarks., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 2d96f10 77/79: Merge branch 'elisp', Jackson Ray Hamilton, 2015/06/13
- [elpa] master e2f402c 79/79: Merge commit '40f67bf039c143758ac070f9693bb0af87b98aba' from context-coloring, Jackson Ray Hamilton, 2015/06/13