branch: master commit 0681e9463b4d826977a97b7f1ece9fac2aa9fb0f Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com> Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
Remove `set-colors' and `set-colors-default'. --- context-coloring.el | 51 ++++++++++++++-------------------------- test/context-coloring-test.el | 32 +------------------------ 2 files changed, 20 insertions(+), 63 deletions(-) diff --git a/context-coloring.el b/context-coloring.el index 5d18157..341efe8 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -85,24 +85,23 @@ and DARK backgrounds." "Define a face for LEVEL with the default neutral colors." (context-coloring-defface level nil "#3f3f3f" "#cdcdcd")) -(defun context-coloring-set-colors-default () - (context-coloring-defface 0 nil "#000000" "#ffffff") - (context-coloring-defface 1 "yellow" "#007f80" "#ffff80") - (context-coloring-defface 2 "green" "#001580" "#cdfacd") - (context-coloring-defface 3 "cyan" "#550080" "#d8d8ff") - (context-coloring-defface 4 "blue" "#802b00" "#e7c7ff") - (context-coloring-defface 5 "magenta" "#6a8000" "#ffcdcd") - (context-coloring-defface 6 "red" "#008000" "#ffe390") - (context-coloring-defface-default 7) - (setq context-coloring-maximum-face 7) - (setq context-coloring-original-maximum-face - context-coloring-maximum-face) - ;; Theme authors can have up to 26 levels: 1 (0th) for globals, 24 (1st-24th) - ;; for in-betweens, and 1 (25th) for infinity. - (dotimes (number 18) - (context-coloring-defface-default (+ number context-coloring-maximum-face 1)))) - -(context-coloring-set-colors-default) +(context-coloring-defface 0 nil "#000000" "#ffffff") +(context-coloring-defface 1 "yellow" "#007f80" "#ffff80") +(context-coloring-defface 2 "green" "#001580" "#cdfacd") +(context-coloring-defface 3 "cyan" "#550080" "#d8d8ff") +(context-coloring-defface 4 "blue" "#802b00" "#e7c7ff") +(context-coloring-defface 5 "magenta" "#6a8000" "#ffcdcd") +(context-coloring-defface 6 "red" "#008000" "#ffe390") +(context-coloring-defface-default 7) + +(setq context-coloring-maximum-face 7) +(setq context-coloring-original-maximum-face + context-coloring-maximum-face) + +;; Theme authors can have up to 26 levels: 1 (0th) for globals, 24 (1st-24th) +;; for in-betweens, and 1 (25th) for infinity. +(dotimes (number 18) + (context-coloring-defface-default (+ number context-coloring-maximum-face 1))) ;;; Face functions @@ -114,20 +113,6 @@ and DARK backgrounds." (number-to-string level) "-face"))) -(defun context-coloring-set-colors (&rest colors) - "Set context coloring's levels' coloring to COLORS, where the -Nth element of COLORS is level N's color." - (setq context-coloring-maximum-face (- (length colors) 1)) - (setq context-coloring-original-maximum-face - context-coloring-maximum-face) - (let ((level 0)) - (dolist (color colors) - ;; Ensure there are available faces to contain new colors. - (when (not (context-coloring-face-symbol level)) - (context-coloring-defface-default level)) - (set-face-foreground (context-coloring-face-symbol level) color) - (setq level (+ level 1))))) - (defsubst context-coloring-level-face (level) "Returns the face name for LEVEL." (context-coloring-face-symbol (min level context-coloring-maximum-face))) @@ -658,7 +643,7 @@ faces for custom themes that might not exist yet." (when (and (not (eq theme 'user)) ; Called internally by `enable-theme'. (custom-theme-p theme) ; Guard against non-existent themes. (context-coloring-theme-p theme)) - (when (> (length custom-enabled-themes) 0) + (when (= (length custom-enabled-themes) 0) ;; Cache because we can't reliably figure it out in reverse. (setq context-coloring-original-maximum-face context-coloring-maximum-face)) diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el index 7c23d89..61e24b1 100644 --- a/test/context-coloring-test.el +++ b/test/context-coloring-test.el @@ -42,8 +42,7 @@ "Cleanup code to run after all tests." (setq context-coloring-comments-and-strings t) (setq context-coloring-after-colorize-hook nil) - (setq context-coloring-js-block-scopes nil) - (context-coloring-set-colors-default)) + (setq context-coloring-js-block-scopes nil)) (defmacro context-coloring-test-with-fixture (fixture &rest body) "Evaluate BODY in a temporary buffer with the relative @@ -286,32 +285,6 @@ FOREGROUND." "Context coloring is not available for this major mode" "*Messages*"))) -(ert-deftest context-coloring-test-set-colors () - ;; This test has an irreversible side-effect in that it defines faces beyond - ;; 7. Faces 0 through 7 are reset to their default states, so it might not - ;; matter, but be aware anyway. - (context-coloring-set-colors - "#000000" - "#111111" - "#222222" - "#333333" - "#444444" - "#555555" - "#666666" - "#777777" - "#888888" - "#999999") - (context-coloring-test-assert-face 0 "#000000") - (context-coloring-test-assert-face 1 "#111111") - (context-coloring-test-assert-face 2 "#222222") - (context-coloring-test-assert-face 3 "#333333") - (context-coloring-test-assert-face 4 "#444444") - (context-coloring-test-assert-face 5 "#555555") - (context-coloring-test-assert-face 6 "#666666") - (context-coloring-test-assert-face 7 "#777777") - (context-coloring-test-assert-face 8 "#888888") - (context-coloring-test-assert-face 9 "#999999")) - (defvar context-coloring-test-theme-index 0 "Unique index for unique theme names.") @@ -417,8 +390,7 @@ themes are reversed after the test completes." (progn ,@body) ;; Always cleanup. - (disable-theme theme) - (context-coloring-set-colors-default)))))) + (disable-theme theme)))))) (defun context-coloring-test-deftheme (theme) "Dynamically define theme THEME."