]> code.delx.au - gnu-emacs-elpa/commitdiff
Make keywords in comments and strings coloring customizable.
authorJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Tue, 3 May 2016 03:42:02 +0000 (20:42 -0700)
committerJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Tue, 3 May 2016 03:42:02 +0000 (20:42 -0700)
context-coloring-emacs-lisp.el
context-coloring.el

index dbe1354bca231a64f74765d55d96e1f02db5937c..7bda871a99b8bda11ad8133164a22e8bcdbc536e 100644 (file)
   "Move forward through whitespace and comments."
   (while (forward-comment 1)))
 
+(defsubst context-coloring-elisp-colorize-comments-and-strings
+  (&optional min max)
+  "Color comments and strings from MIN to MAX."
+  (context-coloring-colorize-comments-and-strings min max t))
+
 (defsubst context-coloring-elisp-forward-sws ()
   "Move through whitespace and comments, coloring comments."
   (let ((start (point)))
     (context-coloring-forward-sws)
-    (context-coloring-colorize-comments-and-strings start (point))))
+    (context-coloring-elisp-colorize-comments-and-strings start (point))))
 
 (defsubst context-coloring-elisp-forward-sexp ()
   "Skip/ignore missing sexps, coloring comments and strings."
@@ -606,7 +611,7 @@ It could be a quoted or backquoted expression."
   (context-coloring-elisp-increment-sexp-count)
   (let ((start (point)))
     (forward-sexp)
-    (context-coloring-colorize-comments-and-strings start (point))))
+    (context-coloring-elisp-colorize-comments-and-strings start (point))))
 
 ;; Elisp has whitespace, words, symbols, open/close parenthesis, expression
 ;; prefix, string quote, comment starters/enders and escape syntax classes only.
index 52b08442f92719a8d9128680fd324efd06c7e793..c2d6c5d647432bbb45e790204a723c13a538b437 100644 (file)
@@ -263,9 +263,10 @@ it ain't."
   "Color a string according to STATE."
   (if (nth 3 state) font-lock-string-face nil))
 
-(defsubst context-coloring-colorize-comments-and-strings (&optional min max)
+(defsubst context-coloring-colorize-comments-and-strings (&optional min max keywords-p)
   "Maybe color comments and strings in buffer from MIN to MAX.
-MIN defaults to beginning of buffer.  MAX defaults to end."
+MIN defaults to beginning of buffer.  MAX defaults to end.  If
+KEYWORDS-P is non-nil, also color keywords from MIN to MAX."
   (when (or context-coloring-syntactic-comments
             context-coloring-syntactic-strings)
     (let ((min (or min (point-min)))
@@ -282,8 +283,7 @@ MIN defaults to beginning of buffer.  MAX defaults to end."
              font-lock-syntactic-face-function))))
       (save-excursion
         (font-lock-fontify-syntactically-region min max)
-        ;; TODO: Make configurable at the dispatch level.
-        (when (eq major-mode 'emacs-lisp-mode)
+        (when keywords-p
           (font-lock-fontify-keywords-region min max))))))
 
 (defcustom context-coloring-initial-level 0