]> code.delx.au - gnu-emacs-elpa/commitdiff
Color comments and strings inside quotes.
authorJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sat, 30 May 2015 18:25:19 +0000 (11:25 -0700)
committerJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sat, 30 May 2015 18:25:19 +0000 (11:25 -0700)
context-coloring.el
test/context-coloring-test.el
test/fixtures/quote.el

index 459aca0e75856cd65ad326c752aba53ca9a49693..9b53fd13fb5ea6bc46a14b8dc5be563b4308de40 100644 (file)
@@ -593,18 +593,15 @@ generated by `js2-mode'."
         symbol-string))))))
 
 (defun context-coloring-elisp-colorize-expression-prefix ()
-  (let (start
-        end
-        char)
-    (setq char (char-after))
+  (let ((char (char-after))
+        (start (point))
+        (end (progn (forward-sexp)
+                    (point))))
     (cond
      ((or (= char context-coloring-APOSTROPHE-CHAR)
           (= char context-coloring-OCTOTHORPE-CHAR))
-      (forward-sexp))
+      (context-coloring-elisp-colorize-comments-and-strings-in-region start end))
      ((= char context-coloring-BACKTICK-CHAR)
-      (setq start (point))
-      (forward-sexp)
-      (setq end (point))
       (goto-char start)
       (while (> end (progn (forward-char)
                            (point)))
@@ -668,6 +665,20 @@ provide visually \"instant\" updates at 60 frames per second.")
      start
      (point))))
 
+(defun context-coloring-elisp-colorize-comments-and-strings-in-region (start end)
+  (let (syntax-code)
+    (goto-char start)
+    (while (> end (progn (skip-syntax-forward "^<\"" end)
+                         (point)))
+      (setq syntax-code (context-coloring-get-syntax-code))
+      (cond
+       ((= syntax-code context-coloring-COMMENT-START-CODE)
+        (context-coloring-elisp-colorize-comment))
+       ((= syntax-code context-coloring-STRING-QUOTE-CODE)
+        (context-coloring-elisp-colorize-string))
+       (t
+        (forward-char))))))
+
 (defun context-coloring-elisp-colorize-region (start end)
   (let (syntax-code)
     (goto-char start)
index 2a9cdd0f0147edd551d007de71f4a890e3d32f15..2f519f98818e79ec2021b0af1c16041ce6a783cc 100644 (file)
@@ -1099,7 +1099,11 @@ ssssssssssss0"))
 (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")))
+      111111 1 1111111111 11 111 1 111 1 00001 10000 11 00001 1 100001111
+
+(xxxxxx '(sss cc
+          sss cc
+          ))")))
 
 (context-coloring-test-deftest-emacs-lisp comment
   (lambda ()
index 654bc705b1518d81536a03a44ef44e0917dba6fe..8a282da4157026803a2975e11487d8e001b8e76e 100644 (file)
@@ -2,3 +2,7 @@
   (or (eq a 'b)
       (equal a '(a b))
       (equal a `(,(append () `(a b ,(+ 1 free) ,free b) free) b ,free))))
+
+(append '("a" ; b
+          "b" ; a
+          ))