]> code.delx.au - gnu-emacs-elpa/commitdiff
Add quote and backquote function support.
authorJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sat, 13 Jun 2015 20:43:09 +0000 (13:43 -0700)
committerJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sat, 13 Jun 2015 20:43:09 +0000 (13:43 -0700)
context-coloring.el
test/context-coloring-test.el
test/fixtures/quote.el

index a9bcdaced2877e6f85a9d42dc51960ec048ed1cf..b1bede58abbe41b48dcc132e7fb6ffd3882062ae 100644 (file)
@@ -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."
index 291b36a1006f0cc29ce392c37ca04fdae625d707..cce22a307c9b4c8b753156c9525a5e55af1d1854 100644 (file)
@@ -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
index 63892a083eb4b0718dd6546001f30b7df74cf9cf..5fc126d0a68f5433f8906255810035601b626951 100644 (file)
@@ -1,3 +1,6 @@
+(quote (lambda () free))
+(let () (backquote (,free)))
+
 (defun a (a)
   (or (eq a 'b)
       (equal a '(a b))