diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-05 10:06:20 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-05 10:06:20 -0500 |
| commit | 541586e3ff0606afcf0581210a62c95f5ee65c71 (patch) | |
| tree | d67d1f08323879e72a10b42f945edff9004675a8 /scripts/coverage-summary.py | |
| parent | ec00dbe1c03527ec46a0faa20545a7acd382da84 (diff) | |
| download | emacs-wttrin-541586e3ff0606afcf0581210a62c95f5ee65c71.tar.gz emacs-wttrin-541586e3ff0606afcf0581210a62c95f5ee65c71.zip | |
feat: support t for auto-detect via geolocation in wttrin-favorite-location
Completes the three-mode configuration the favorite-location feature was always meant to have:
- nil — disabled (default; unchanged)
- a string — explicit location (unchanged)
- t — auto-detect via IP geolocation (NEW)
When the user sets `wttrin-favorite-location` to t, wttrin runs the geolocation lookup once on first use and caches the result for the session. Subsequent reads return the cached string. The lookup happens in the background via the existing `wttrin-geolocation-detect`, so Emacs startup is never blocked.
I added two private state vars (`wttrin--resolved-favorite-location`, `wttrin--favorite-location-pending`) and a resolver `wttrin--resolve-favorite-location` that maps the three modes onto a returned string or nil. When t is set and the cache is empty, the resolver kicks off the lookup and returns nil for that call — the next consumer tick after the callback completes gets the cached string. The pending flag prevents duplicate concurrent lookups when several consumers ask during the resolution window.
Five consumer call sites now go through the resolver instead of reading `wttrin-favorite-location` directly: `wttrin--mode-line-fetch-weather`, `wttrin-mode-line-click`, `wttrin-mode-line-force-refresh`, `wttrin--buffer-cache-refresh`, and `wttrin--mode-line-start`. Two display sites (the placeholder and error tooltips) use a new `wttrin--favorite-location-display-name` helper that returns "current location" while a t-mode lookup is pending, instead of showing the literal `t` to the user.
Tests cover the resolver across all three modes, including the pending state, the duplicate-suppression behavior, and detection-failure retry. Existing consumer tests stay green because the resolver returns the bound string unchanged when the variable is a string. One care: the test file requires wttrin-geolocation up front so cl-letf mocks of `wttrin-geolocation-detect` aren't undone by the resolver's lazy require — without that, the first run hit ipapi.co for real.
README documents the new mode under "Setting the Favorite Location from IP Geolocation".
Diffstat (limited to 'scripts/coverage-summary.py')
0 files changed, 0 insertions, 0 deletions
