From 7673e72ed4dc4af9c3db9a5962c4673bd1ce90e3 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 4 Nov 2025 19:21:34 -0600 Subject: fix(wttrin): Fix ANSI color rendering on fresh Emacs launch Critical bug fix: On fresh Emacs launch, weather displayed with only double quotes colored blue, all other text white. Pressing 'g' to refresh brought colors back. Root cause: wttrin-mode (derived mode) calls kill-all-local-variables internally. The code was setting xterm-color--state buffer-local BEFORE calling wttrin-mode, so the state was immediately wiped out. On refresh, the mode was already active (no-op), so the state survived. Fix: Call wttrin-mode FIRST, then set buffer-local variables after. This ensures kill-all-local-variables runs before we set any state. Changes: - Reorder initialization in wttrin--display-weather (wttrin.el:277-285) - Add regression tests for mode initialization order (2 new tests) Test results: 65 tests, all passing --- tests/test-wttrin--display-weather.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/test-wttrin--display-weather.el') diff --git a/tests/test-wttrin--display-weather.el b/tests/test-wttrin--display-weather.el index 364908f..4b2a90d 100644 --- a/tests/test-wttrin--display-weather.el +++ b/tests/test-wttrin--display-weather.el @@ -87,7 +87,7 @@ Weather report: Paris, France ;; Check that keybindings are set (they should be in the local map) (should (keymapp (current-local-map))) (should (commandp (lookup-key (current-local-map) "q"))) - (should (commandp (lookup-key (current-local-map) "r"))) + (should (commandp (lookup-key (current-local-map) "a"))) (should (commandp (lookup-key (current-local-map) "g"))))) (test-wttrin--display-weather-teardown))) @@ -103,8 +103,8 @@ Weather report: Paris, France (forward-line -2) ;; Should contain help text (should (search-forward "Press:" nil t)) - (should (search-forward "[g] to query another location" nil t)) - (should (search-forward "[r] to refresh" nil t)) + (should (search-forward "[a] for another location" nil t)) + (should (search-forward "[g] to refresh" nil t)) (should (search-forward "[q] to quit" nil t)))) (test-wttrin--display-weather-teardown))) -- cgit v1.2.3