branch: master commit 2b687aee163eb50f5baf924850584251839f2882 Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com> Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
Pass test for disabling. --- context-coloring.el | 15 ++++++++++++--- test/context-coloring-test.el | 31 +++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/context-coloring.el b/context-coloring.el index 054cdbc..bcbe86e 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -665,11 +665,20 @@ THEME." (defadvice enable-theme (after context-coloring-enable-theme (theme) activate) "Enable colors for context themes just-in-time. We can't set faces for custom themes that might not exist yet." - (when (and (not (eq theme 'user)) ; Called internally by `enable-theme'. - (context-coloring-theme-p theme) - (custom-theme-p theme)) ; Guard against non-existent themes. + (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)) (context-coloring-enable-theme theme))) +(defadvice disable-theme (after context-coloring-disable-theme (theme) activate) + "Colors are disabled normally, but +`context-coloring-face-count' isn't. Update it here." + (when (custom-theme-p theme) ; Guard against non-existent themes. + (let ((enabled-theme (car custom-enabled-themes))) + (if (context-coloring-theme-p enabled-theme) + (context-coloring-enable-theme enabled-theme) + (context-coloring-set-colors-default))))) + (context-coloring-define-theme 'leuven :recede t diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el index dcad8e3..8c79b4c 100644 --- a/test/context-coloring-test.el +++ b/test/context-coloring-test.el @@ -568,21 +568,36 @@ return t for a theme with SETTINGS." (apply 'context-coloring-test-assert-face-count (append arguments '(t)))) -(context-coloring-test-deftest-define-theme disable +(context-coloring-test-deftest-define-theme disable-cascade (context-coloring-test-deftheme theme) (context-coloring-define-theme theme :colors '("#aaaaaa" "#bbbbbb")) - (let ((other-theme (context-coloring-test-get-next-theme))) - (context-coloring-test-deftheme other-theme) + (let ((second-theme (context-coloring-test-get-next-theme))) + (context-coloring-test-deftheme second-theme) (context-coloring-define-theme - other-theme + second-theme :colors '("#cccccc" - "#dddddd")) - (enable-theme theme) - (enable-theme other-theme) - (disable-theme other-theme) + "#dddddd" + "#eeeeee")) + (let ((third-theme (context-coloring-test-get-next-theme))) + (context-coloring-test-deftheme third-theme) + (context-coloring-define-theme + third-theme + :colors '("#111111" + "#222222" + "#333333" + "#444444")) + (enable-theme theme) + (enable-theme second-theme) + (enable-theme third-theme) + (disable-theme third-theme) + (context-coloring-test-assert-face 0 "#cccccc") + (context-coloring-test-assert-face 1 "#dddddd") + (context-coloring-test-assert-face 2 "#eeeeee") + (context-coloring-test-assert-face-count 3)) + (disable-theme second-theme) (context-coloring-test-assert-face 0 "#aaaaaa") (context-coloring-test-assert-face 1 "#bbbbbb") (context-coloring-test-assert-face-count 2))