From f526cf641181e9cdb533a1f8a278de1fad49ca25 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 4 Apr 2026 13:07:50 -0500 Subject: fix: mode-line tooltip always shows "Updated just now" The tooltip was a static string computed at fetch time. Since every successful fetch sets the cache timestamp to now and immediately renders the tooltip, it was always "just now". Extract wttrin--mode-line-tooltip as a named function that computes age from the cache at call time. Set help-echo to this function so Emacs invokes it on hover, producing an accurate age like "Updated 12 minutes ago". --- tests/test-wttrin--mode-line-update-display.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/test-wttrin--mode-line-update-display.el') diff --git a/tests/test-wttrin--mode-line-update-display.el b/tests/test-wttrin--mode-line-update-display.el index e23780b..81fbded 100644 --- a/tests/test-wttrin--mode-line-update-display.el +++ b/tests/test-wttrin--mode-line-update-display.el @@ -146,7 +146,8 @@ (cl-letf (((symbol-function 'float-time) (lambda () 1300.0))) (setq wttrin--mode-line-cache (cons 1000.0 "Paris: ☀️ +61°F Clear")) (wttrin--mode-line-update-display) - (let ((tooltip (get-text-property 0 'help-echo wttrin-mode-line-string))) + (let* ((help-echo-fn (get-text-property 0 'help-echo wttrin-mode-line-string)) + (tooltip (funcall help-echo-fn nil nil nil))) (should (string-match-p "Paris" tooltip)) (should (string-match-p "Updated 5 minutes ago" tooltip)))) (test-wttrin--mode-line-update-display-teardown))) @@ -162,7 +163,8 @@ ;; Data is 2000 seconds old, threshold is 2*900=1800 -> stale (setq wttrin--mode-line-cache (cons 1000.0 "Paris: ☀️ +61°F Clear")) (wttrin--mode-line-update-display) - (let ((tooltip (get-text-property 0 'help-echo wttrin-mode-line-string))) + (let* ((help-echo-fn (get-text-property 0 'help-echo wttrin-mode-line-string)) + (tooltip (funcall help-echo-fn nil nil nil))) (should (string-match-p "Stale" tooltip)) (should (string-match-p "fetch failed" tooltip))))) (test-wttrin--mode-line-update-display-teardown))) -- cgit v1.2.3