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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master dc2f9a6 25/47: Refactor maybe-colorize-comments-and-string


From: Jackson Ray Hamilton
Subject: [elpa] master dc2f9a6 25/47: Refactor maybe-colorize-comments-and-strings.
Date: Mon, 18 May 2015 09:51:54 +0000

branch: master
commit dc2f9a6e3b43e7559b9d2325031bdd79542e9cf1
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    Refactor maybe-colorize-comments-and-strings.
---
 context-coloring.el |   30 +++++++++++++-----------------
 1 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/context-coloring.el b/context-coloring.el
index 940b90d..22097a5 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -172,29 +172,25 @@ the END point (exclusive) with the face corresponding to 
LEVEL."
   "Tell `font-lock' to color a string but not a comment."
   (if (nth 3 state) font-lock-string-face nil))
 
-(defsubst context-coloring-maybe-colorize-comments-and-strings ()
+(defsubst context-coloring-maybe-colorize-comments-and-strings (&optional min 
max)
   "Color the current buffer's comments and strings if
 `context-coloring-comments-and-strings' is non-nil."
   (when (or context-coloring-comments-and-strings
             context-coloring-syntactic-comments
             context-coloring-syntactic-strings)
-    (let ((old-function font-lock-syntactic-face-function)
-          saved-function-p)
-      (cond
-       ((and context-coloring-syntactic-comments
-             (not context-coloring-syntactic-strings))
-        (setq font-lock-syntactic-face-function
-              'context-coloring-font-lock-syntactic-comment-function)
-        (setq saved-function-p t))
-       ((and context-coloring-syntactic-strings
-             (not context-coloring-syntactic-comments))
-        (setq font-lock-syntactic-face-function
-              'context-coloring-font-lock-syntactic-string-function)
-        (setq saved-function-p t)))
+    (let ((font-lock-syntactic-face-function
+           (cond
+            ((and context-coloring-syntactic-comments
+                  (not context-coloring-syntactic-strings))
+             'context-coloring-font-lock-syntactic-comment-function)
+            ((and context-coloring-syntactic-strings
+                  (not context-coloring-syntactic-comments))
+             'context-coloring-font-lock-syntactic-string-function)
+            (t
+             font-lock-syntactic-face-function))))
       (save-excursion
-        (font-lock-fontify-syntactically-region (point-min) (point-max)))
-      (when saved-function-p
-        (setq font-lock-syntactic-face-function old-function)))))
+        (font-lock-fontify-syntactically-region (or min (point-min))
+                                                (or max (point-max)))))))
 
 
 ;;; js2-mode colorization



reply via email to

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