emacs-elpa-diffs
[Top][All Lists]
Advanced

[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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]