diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-28 03:56:24 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-28 04:01:06 -0400 |
| commit | 19e103fea2e55a3e3bc3a777b4c618e644b57760 (patch) | |
| tree | 6af33c4c7bf146ace78db9feec09a02f5885f23b /tests/test-wttrin--mode-line-start.el | |
| parent | ec38418d6d3eb4342363af1714f0073a74d52fbc (diff) | |
| download | emacs-wttrin-19e103fea2e55a3e3bc3a777b4c618e644b57760.tar.gz emacs-wttrin-19e103fea2e55a3e3bc3a777b4c618e644b57760.zip | |
fix: stop the mode-line cleanly when disabled before startup fires
The delayed initial fetch was scheduled with run-at-time but the one-shot timer
was discarded, and when the mode is enabled before after-init the start is
queued on after-init-hook. Disabling the mode before either fired could still
start timers, hit the network, or mutate mode-line state after the user turned
it off. Stop now cancels the stored startup timer and removes the after-init
hook, and the startup callback no-ops when the mode is off.
Diffstat (limited to 'tests/test-wttrin--mode-line-start.el')
| -rw-r--r-- | tests/test-wttrin--mode-line-start.el | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/test-wttrin--mode-line-start.el b/tests/test-wttrin--mode-line-start.el index 1b86689..21cdb24 100644 --- a/tests/test-wttrin--mode-line-start.el +++ b/tests/test-wttrin--mode-line-start.el @@ -21,7 +21,8 @@ (setq wttrin-mode-line-string nil) (setq wttrin--mode-line-cache nil) (setq wttrin--mode-line-timer nil) - (setq wttrin--buffer-refresh-timer nil)) + (setq wttrin--buffer-refresh-timer nil) + (setq wttrin--mode-line-startup-timer nil)) (defun test-wttrin--mode-line-start-teardown () "Teardown for mode-line-start tests." @@ -30,10 +31,13 @@ (cancel-timer wttrin--mode-line-timer)) (when (timerp wttrin--buffer-refresh-timer) (cancel-timer wttrin--buffer-refresh-timer)) + (when (timerp wttrin--mode-line-startup-timer) + (cancel-timer wttrin--mode-line-startup-timer)) (setq wttrin-mode-line-string nil) (setq wttrin--mode-line-cache nil) (setq wttrin--mode-line-timer nil) - (setq wttrin--buffer-refresh-timer nil)) + (setq wttrin--buffer-refresh-timer nil) + (setq wttrin--mode-line-startup-timer nil)) ;;; Normal Cases @@ -70,8 +74,10 @@ (null (plist-get call :repeat)))) scheduled-calls))) (should initial-fetch) + ;; The delayed fetch goes through the enabled-guard wrapper so a + ;; disable before it fires is a no-op. (should (eq (plist-get initial-fetch :func) - #'wttrin--mode-line-fetch-weather))))) + #'wttrin--mode-line-fetch-weather-if-enabled))))) (test-wttrin--mode-line-start-teardown))) (ert-deftest test-wttrin--mode-line-start-normal-creates-repeating-mode-line-timer () |
