| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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".
|
| |
|
|
|
|
|
|
|
|
|
|
| |
wttr.in accepts single-character flags appended to the URL that control what the report looks like — no Follow line (F), narrow output (n), quiet mode (q), forecast horizon (0/1/2), console-glyph mode (d), and so on. Until now wttrin always used the same default report shape with no way to opt into these.
Added a `wttrin-display-options` defcustom that takes a string of concatenated flags, e.g. "0Fq" for current weather only with no Follow line and no header. The flags get appended to every request via `wttrin--build-url`. The defcustom defaults to nil so existing users see no change.
I excluded `A` and `T` from the recommended set in the docstring since wttrin needs ANSI output for the xterm-color rendering to produce the colored glyphs. The user could still pass them, but the docstring nudges them away.
Tests cover the normal cases (single, multi-flag, with and without unit system), the boundaries (nil and empty string both leave the URL unchanged from baseline, single character works), and a sanity check that the new flags slot in after the always-on `A`. Existing build-url tests stay green because they don't bind the new variable, and the default is nil.
Also added `.claude/` to .gitignore — the scheduled-tasks lockfile from local wakeup scheduling shouldn't be tracked.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Two CI failures from the first run, neither a real bug in production code.
The Emacs-snapshot job failed on
`test-wttrin-mode-initialization-order-normal-mode-before-buffer-local-vars-calls-mode-first`.
The original test mocked the `set' primitive to detect when
`xterm-color--state' was first set. That worked on the byte-code path some
older Emacs versions used, but `setq-local' doesn't go through the `set'
function on Emacs master, so the mock never fired and the assertion read nil.
The test was already brittle in isolation locally too.
Rewrote the test to use `advice-add :before' on `wttrin-mode' and
`make-local-variable'. Both are ordinary advisable functions, and
`make-local-variable' is on the code path for every form that defines a
buffer-local binding (`setq-local', `defvar-local', etc.) so the observation
holds across Emacs versions. Renamed the test to drop "calls-mode-first"
and use "mode-runs-before-xterm-color-state-binding" since that's what the
new advice actually observes.
The Emacs 26.3 job failed with a transient DNS error from elpa.gnu.org
during `make deps'. Wrapped the install step in a 3-attempt retry with a
15-second backoff so a runner-side network blip doesn't fail the build.
Applied to all three jobs (test, lint, coverage) since they all hit the
same archives.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The four interactive commands in `wttrin-debug.el` used `debug-wttrin-` as their prefix instead of the package's `wttrin-debug-` prefix. package-lint flags this as a convention violation, and it makes M-x discovery slightly less consistent for users.
Renamed:
- `debug-wttrin-show-raw` -> `wttrin-debug-show-raw`
- `debug-wttrin-enable` -> `wttrin-debug-enable`
- `debug-wttrin-disable` -> `wttrin-debug-disable`
- `debug-wttrin-mode-line` -> `wttrin-debug-mode-line`
The old names stay available as `define-obsolete-function-alias` entries marked since 0.4.0, so anyone with a keybinding or `(call-interactively 'debug-wttrin-enable)` in their config keeps working. The byte-compiler will emit an obsolescence warning to nudge migration. Aliases will be removed in a future release.
Internal caller `wttrin--debug-mode-line-info` now invokes the new name. Test files renamed to match (`test-debug-wttrin-*.el` -> `test-wttrin-debug-*.el`); inside each, ert-deftest names and function calls were updated.
Added `tests/test-wttrin-debug-aliases.el` to verify each old name resolves via `indirect-function` to the new name and carries `byte-obsolete-info` with the expected target and "0.4.0" version.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
I added 24 unit tests across six new files for wttrin-debug.el. They cover enable/disable, the debug-log writer, clear-log, show-log, and the mode-line diagnostic dump. That lifts wttrin-debug.el coverage from 27% to 95%, and overall coverage from 84% to 94%. Each function gets Normal / Boundary / Error categories where applicable. Globals like `wttrin-debug` and `wttrin--debug-log` are isolated per test with let-bindings. The dynamic-scope rebinding restores state cleanly at exit.
I expanded the `lint` target to run on all three source files instead of just `wttrin.el`. Checkdoc and elisp-lint run on every file. Package-lint stays scoped to `wttrin.el` because the others aren't standalone packages.
The tricky bit: `elisp-lint-file` re-runs package-lint internally as one of its validators. So the explicit guard alone wasn't enough. The fix binds `elisp-lint-ignored-validators` to include "package-lint" for the secondaries, which suppresses the re-run at the validator level.
I also added `*-autoloads.el` to .gitignore. Eask generates `emacs-wttrin-autoloads.el` during install, and it shouldn't be tracked.
I skipped one function: `wttrin--debug-mode-line-info` is a one-line dispatcher to `debug-wttrin-mode-line`. Testing it would assert the dispatch happened, which only tests Emacs.
|
| |
|
|
|
|
|
|
|
|
| |
I wanted a coverage number, so I added an Eask file declaring the runtime dep (xterm-color) plus three dev deps (undercover, package-lint, elisp-lint). The Makefile now runs every test and lint recipe through `eask emacs`. That drops the hand-rolled `(require 'package)` + `add-to-list 'package-archives` boilerplate that was duplicated across six recipes.
I added a `make deps` target that runs `eask install-deps --dev`. I also added a `make coverage` target that loads `tests/run-coverage-file.el` before each unit-test file. Undercover instruments the three source files first, then the test loads pick up the instrumented copy. Per-file results merge into `.coverage/simplecov.json` in simplecov format.
I expanded `validate-parens` and `compile` to cover all three source files instead of just `wttrin.el`. Lint stays scoped to the main file for now.
Coverage right now is 84% overall: wttrin.el 92%, wttrin-geolocation.el 100%, wttrin-debug.el 27%. The debug module is low because only the integration test exercises it. The coverage loop runs unit tests only.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Four pure helpers in wttrin-geolocation.el were exercised only indirectly through the parser tests: --decode-json, --format-city-region, --lookup-provider, and --extract-body. None of them had direct unit coverage. Edge cases like an empty JSON object, a missing-vs-empty city field, an unknown provider symbol, or a missing HTTP body separator weren't locked.
The new file groups all four functions together. Each gets Normal, Boundary, and Error cases per testing.md. Highlights:
- --decode-json: distinguishes nil input, empty string, and malformed JSON, all of which return nil for different reasons.
- --format-city-region: separates "missing key" from "empty string" since the predicate `(and (stringp city) (> (length city) 0) ...)` short-circuits on either.
- --lookup-provider: tests two of the three built-ins plus a `let`-bound synthetic provider, locking the documented extension point on `wttrin-geolocation--providers`.
- --extract-body: real UTF-8 bytes inserted into a temp buffer (mirroring what `url-retrieve` delivers) verify the decoding path. 4xx, 5xx, and missing-separator paths each get their own test.
21 new tests, all green on first run since they characterize existing behavior.
|
| |
|
|
|
|
|
|
| |
The regex that pulls the emoji character out of a wttr.in mode-line response was inlined inside `wttrin--mode-line-update-display`, mixed in with the render logic. Six tests of the parser couldn't be written without invoking the whole render path.
The new pure helper takes the weather string, runs the regex, and returns either the first non-whitespace character after the colon or "?" as a placeholder. The format-explanation comment that used to sit above the inline code is gone now that the same explanation lives in the helper's docstring. There's no risk of comment and code drifting apart.
Six tests cover Normal (typical response, different emoji), Boundary (no whitespace after colon, multiple whitespace chars), and Error (no colon, empty string).
|
| |
|
|
|
|
|
|
| |
The staleness check `(> age (* 2 wttrin-mode-line-refresh-interval))` lived in two places, `wttrin--mode-line-tooltip` and `wttrin--mode-line-update-display`, along with the four-line preamble that read the timestamp out of the cache cons and computed age. Centralizing the rule in a single helper means the threshold lives in one spot. That makes it easy to add a `wttrin-mode-line-staleness-threshold` defcustom later if the magic 2× ever needs to be tunable.
The helper takes a cache entry (or nil) and returns t/nil. Five new tests cover Normal (fresh, stale) and Boundary (just below the threshold, just past, nil entry). The boundary tests use 199s and 201s against a 100s refresh interval to lock the strict `>` semantics with comfortable float-time margins.
In `wttrin--mode-line-update-display` the refactor also drops two locals (`timestamp` and `age`) that were no longer used after the helper call replaced the inline calculation. Behavior is unchanged at both call sites.
|
| |
|
|
|
|
| |
When wttrin-mode-line-emoji-font is set and the cache is fresh, --make-emoji-icon was emitting a face plist of the form (:family ... :height 1.0 :foreground nil). Emacs validates faces on every redisplay, so a single fresh-cache state produced hundreds of "Invalid face attribute :foreground nil" warnings in *Messages*.
The new boundary test asserts the face plist omits :foreground entirely when the caller passes nil. The assertion uses plist-member, not plist-get. plist-get returns nil for both a missing key and a present key bound to nil. That's the exact distinction Emacs's redisplay validator cares about.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Lets users set `wttrin-favorite-location` by IP lookup instead of typing a city by hand. `M-x wttrin-set-location-from-geolocation` runs the lookup, shows the detected "City, Region" in a yes/no prompt, and on confirmation sets the variable for the session. The docstring points at `M-x customize-save-variable` for persistence across restarts.
The new `wttrin-geolocation.el` module provides the provider layer. Three providers come built in: ipapi.co (the default), ipinfo.io, and ipwho.is. All three are HTTPS, need no API key, and have free tiers large enough for interactive use. The module has three layers. Pure JSON parsers handle the per-provider quirks: ipapi's `error: true` flag, ipwho.is's `success: false` flag, ipinfo's HTTP-status-only signalling. A small fetch helper extracts the HTTP body. `wttrin-geolocation-detect` wires them together and calls back with "City, Region" on success, or nil on any failure (network error, HTTP 4xx or 5xx, malformed response, rate-limit signal).
Providers live in an alist keyed by symbol, with plist values for :name, :url, and :parser. To use a different provider, push an entry onto `wttrin-geolocation--providers` and select it via `wttrin-geolocation-provider`. No code change needed.
README gains a subsection under Mode-line Weather Display covering the command, how to persist the result, provider selection with free-tier limits, and the accuracy caveat for VPN or mobile-hotspot users.
39 new tests across the parser layer (10 ipapi, 6 ipinfo, 6 ipwhois), fetch-and-dispatch (11), and interactive command (6). Each suite covers Normal, Boundary, and Error categories. Tests mock `url-retrieve` and `yes-or-no-p` at their boundaries and run the real extract-and-parse pipeline underneath. Test suite: 333 → 373 passing.
|
| |
|
|
|
| |
Enable truncate-lines in wttrin-mode so the fixed-width weather art
clips at the window edge instead of wrapping and breaking the layout.
|
| |
|
|
|
|
| |
wttr.in returns "Weather report: new orleans, la" regardless of
query casing. Replace the lowercase location on the header line
with the user's original string after rendering.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add HTTP status code checking (wttrin--extract-http-status) and pass
error descriptions through the callback chain so users see "Location
not found (HTTP 404)" or "Network error — check your connection"
instead of the generic "Perhaps the location was misspelled?" for
every failure.
Also fix pre-existing bug where the condition-case error handler in
extract-response-body killed an unrelated buffer after unwind-protect
already cleaned up.
330 tests (was 307), all passing.
|
| |
|
|
|
|
| |
A debug command should show what the API currently returns, not a
cached copy. Bind wttrin--force-refresh to t so the fetch always
bypasses the cache.
|
| |
|
|
|
|
|
|
|
|
| |
The emoji face (dimmed/normal) was frozen at the last update-display
call, but the tooltip computes staleness dynamically. Between
refreshes, data could cross the stale threshold — tooltip says "Stale"
while the emoji is still normal.
Track the rendered staleness state. When the tooltip detects a
transition, trigger a re-render so the emoji dimming matches.
|
| |
|
|
|
|
|
| |
float-time was captured in the outer let* before the async fetch.
The callback used this stale value, making cache entries appear
slightly older than they are. Move the float-time call into the
callback so the timestamp reflects when the data actually arrived.
|
| |
|
|
|
| |
string-match modifies global match data as a side effect. A predicate
should not do this. Use string-match-p instead.
|
| |
|
|
|
|
|
|
|
|
|
| |
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".
|
| |
|
|
|
|
|
| |
wttr.in's %l format returns locations in lowercase (e.g.,
"new orleans, la") regardless of the query casing. Replace the API's
location prefix with the user's original wttrin-favorite-location
string at cache time so tooltips display what the user expects.
|
| |
|
|
|
| |
Update copyright headers across all 37 .el files to include 2026.
Add missing Author field to testutil-wttrin.el for consistency.
|
| |
|
|
|
|
|
|
| |
Add wttrin--make-emoji-icon and wttrin--set-mode-line-string to
eliminate three near-identical propertize blocks across
update-placeholder-error, set-placeholder, and update-display.
Reduces wttrin--mode-line-update-display from 40 lines to 25.
|
| |
|
|
|
|
|
| |
debug-wttrin-show-raw called wttrin--get-cached-or-fetch with 1 arg,
but the function now requires 2 (location + callback) since the async
refactor. Rewrote to use the callback pattern. Also handles nil
response gracefully.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add 11 new test files covering wttrin--save-debug-data,
wttrin--buffer-cache-refresh, wttrin--mode-line-stop,
wttrin--mode-line-start, wttrin-query, wttrin-requery-force,
wttrin-mode-line-click, wttrin-mode-line-force-refresh,
wttrin-fetch-raw-string, wttrin-clear-cache, and wttrin-requery.
Fix bug in wttrin--save-debug-data where nil raw-string caused
(insert nil) crash — reachable when debug mode is on and fetch fails.
Refactor wttrin-requery: extract wttrin--requery-location so the
core kill-buffer-and-query logic is testable without mocking
completing-read.
267 tests total (was 217), all passing.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Replace TTL-based cache invalidation with proactive scheduled refresh.
Both mode-line and buffer systems now follow: timer refreshes cache,
display reads from cache, staleness indicated when data is old.
Phase 1 - Mode-line cache formalization + staleness display:
- Replace wttrin--mode-line-tooltip-data with wttrin--mode-line-cache
as (timestamp . data) cons cell matching buffer cache pattern
- Add wttrin--format-age helper for human-readable age strings
- Rewrite wttrin--mode-line-update-display to take no arguments,
read from cache, compute staleness (age > 2x refresh interval),
dim emoji gray when stale, show staleness info in tooltip
- Rewrite wttrin--mode-line-fetch-weather to write cache on success,
show stale display on failure with cache, error placeholder without
- Add wttrin--mode-line-update-placeholder-error for first-launch failure
Phase 2 - Remove TTL, add proactive buffer refresh:
- Rename wttrin-cache-ttl to wttrin-refresh-interval (default 3600s)
with define-obsolete-variable-alias for backward compatibility
- Change wttrin-mode-line-refresh-interval default from 900 to 3600
- Remove TTL check from wttrin--get-cached-or-fetch; serve cached data
regardless of age, background timer keeps it fresh
- Add buffer refresh timer (wttrin--buffer-cache-refresh)
Phase 3 - Buffer staleness display:
- Add wttrin--format-staleness-header for buffer age display
- Insert staleness line in wttrin--display-weather before instructions
Phase 4 - Cleanup:
- Remove all references to wttrin--mode-line-tooltip-data
- Update README.org cache settings and mode-line documentation
- Update tests for new API (198 tests across 21 files, all passing)
|
| |
|
|
|
|
| |
Display ⏳ with "Fetching weather..." tooltip immediately when
mode-line mode starts, so the user sees wttrin is active before
the first API response arrives.
|
| |
|
|
|
|
| |
Reject empty or malformed wttr.in responses to prevent blank icon and
tooltip. Fix tooltip lambda to treat empty string as falsy. Add debug
logging for nil-location and invalid-response paths.
|
| |
|
|
| |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Expand testutil-wttrin.el with shared fixtures and macros
(testutil-wttrin-with-clean-weather-buffer,
testutil-wttrin-mock-http-response, sample ANSI/weather constants)
- Consolidate cache tests: port unique tests from cleanup-cache-constants
and cleanup-cache-refactored into cleanup-cache-if-needed, delete
obsolete files
- Extract startup-delay tests into dedicated file
- Add setup/teardown and (require 'testutil-wttrin) to all test files
- Rename all 160 tests to follow
test-<module>-<category>-<scenario>-<expected-result> convention
- Rename integration test file and add detailed docstrings
- Update Makefile glob to discover new integration test naming pattern
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
| |
|
|
|
|
|
|
| |
wttrin-favorite-location
Renamed variable to remove 'mode-line' prefix, making it usable for
future location-based features beyond mode-line display. Updated all
references in code, tests, and documentation. All 187 tests passing.
|
| |
|
|
|
|
| |
Extracted wttrin--extract-response-body and wttrin--handle-fetch-callback
from wttrin--fetch-url to improve testability and separation of concerns.
Added comprehensive unit tests for both new functions.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Move xterm-color from top-level require to on-demand loading within
functions that actually use it. This simplifies user configuration
by eliminating the need for separate xterm-color use-package declarations.
Changes:
- Replace top-level (require 'xterm-color) with declare-function
- Add (require 'xterm-color) in wttrin--process-weather-content
- Add (require 'xterm-color) in wttrin--display-weather
- Update smoke test to check loadability vs. feature presence
Benefits:
- Simpler use-package config (no :after xterm-color needed)
- xterm-color still auto-installed via Package-Requires on MELPA
- Load time optimization (loads only when displaying weather)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
conventions
- Create test-wttrin-smoke.el with 15 smoke tests for package sanity checks
- Delete test-wttrin-integration.el (misnamed, contained smoke tests not integration tests)
- Remove redundant functional tests already covered in dedicated unit test files
- URL building: covered by test-wttrin--build-url.el (12 tests)
- Cache operations: covered by test-wttrin--get-cached-or-fetch.el (11 tests)
- Mode-line display: covered by test-wttrin--mode-line-map.el
Smoke tests verify:
- Package loads without errors
- Dependencies available (xterm-color, url)
- Public API exists and is interactive
- Configuration variables defined
- Keymaps exist and are valid
- Package metadata correct (version, autoload cookies)
Final test organization: 18 files, 162 tests (15 smoke + 142 unit + 5 integration)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Cache Refactorings:
- Extract wttrin--get-cache-entries-by-age helper function
- Refactor wttrin--cleanup-cache-if-needed to use helper
- Improves code clarity with descriptive variable names
- Makes cache logic independently testable
- Add 15 new tests (8 for helper, 7 for refactored cleanup)
Input Validation:
- Add range validation to wttrin-mode-line-startup-delay (1-10 seconds)
- Prevents invalid values (0, negative, or excessive delays)
- Uses restricted-sexp type for enforcement
Test Fixes:
- Fix debug function naming (use public wttrin-debug-clear-log)
- Ensure wttrin-debug module loads in test setup
- Make mocks synchronous for batch mode compatibility
- Update test expectations to match actual debug messages
- Fix startup delay test to check defcustom default value
Linter/Compiler Fixes:
- Add declare-function for wttrin--debug-log
- Add defvar/declare-function in wttrin-debug.el
- Fix docstring line lengths (wrap at 80 chars)
- Fix checkdoc warnings (imperative mood, escaping)
- Disambiguate temporary-file-directory reference
All 165 tests passing. Clean byte-compile, package-lint, checkdoc.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Renamed private debug functions to public API:
- wttrin--debug-show-log → wttrin-debug-show-log
- wttrin--debug-clear-log → wttrin-debug-clear-log
Added ;;;###autoload to both functions for proper autoloading.
Updated all references:
- README.org (2 occurrences)
- tests/README-DEBUG-TESTS.md (4 occurrences)
- tests/test-wttrin-integration-with-debug.el (8 occurrences)
These are user-facing commands that should be discoverable via M-x,
so they follow the public API naming convention (single hyphen).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Enhanced wttrin-debug.el:
- Added wttrin--debug-log() function for timestamped logging
- Added wttrin--debug-clear-log() to clear log
- Added wttrin--debug-show-log() to display log in buffer
- Debug log structure: list of (timestamp . message) pairs
Added debug logging to key functions in wttrin.el:
- wttrin--fetch-url: Logs start, success (bytes), and errors
- wttrin--mode-line-fetch-weather: Logs start, URL, data received
- wttrin--mode-line-update-display: Logs display update, emoji extraction
Created comprehensive integration tests:
- test-wttrin-integration-with-debug.el (5 tests, 3 passing)
- Tests fetch, mode-line display, error handling with debug logging
- Includes mocked network calls to avoid external dependencies
- Example debug output shows complete flow:
[wttrin-debug 11:51:46.490] mode-line-fetch: Starting fetch for Berkeley, CA
[wttrin-debug 11:51:46.490] mode-line-fetch: Received data = "Berkeley, CA: ☀️ +62°F Clear"
[wttrin-debug 11:51:46.490] mode-line-display: Extracted emoji = "☀", font = Noto Color Emoji
[wttrin-debug 11:51:46.490] mode-line-display: Complete. mode-line-string set = YES
Added test fixtures:
- tests/fixtures/test-init.el: Minimal config with debug enabled
- tests/README-DEBUG-TESTS.md: Documentation for using debug features
Usage:
(setq wttrin-debug t) ; Before loading wttrin
(require 'wttrin)
M-x wttrin--debug-show-log ; View all logged events
This provides complete visibility into wttrin's operation for troubleshooting.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add 18 integration tests to verify wttrin loads correctly:
Package Loading:
- Package loads without errors
- Feature is properly provided
- Dependencies available (xterm-color, url)
Function Availability:
- Main commands defined and interactive (wttrin, wttrin-clear-cache)
- Modes defined (wttrin-mode, wttrin-mode-line-mode)
Configuration:
- All defcustom variables exist
- Internal variables defined
- Keymaps exist and valid
Package Metadata:
- Version information present
- Autoload cookies in place
Smoke Tests:
- URL building works
- Cache operations function
- Mode-line display works
All 18 tests passing - package loads correctly when dependencies available.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Replace inline keymap construction with shared wttrin--mode-line-map defvar.
Before (line 474-479): Keymap recreated on every mode-line update
- (let ((map (make-sparse-keymap))) ...)
- Allocates new keymap object each time
- 6 lines of repetitive code
After (line 183-190 + line 483): Shared keymap created once
- (defvar wttrin--mode-line-map ...)
- Reference: 'local-map wttrin--mode-line-map
- Single allocation, no repeated construction
Added comprehensive tests (8 tests, all passing):
- Keymap existence and structure verification
- Keybinding tests (mouse-1, mouse-3, no mouse-2)
- Integration test verifying mode-line uses shared map
Benefits:
- More efficient (no allocation on every update)
- Clearer code structure
- Easier to add new keybindings
- Self-documenting with inline documentation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Replace two magic numbers with self-documenting constants:
1. Cache cleanup percentage (line 395):
- Before: (dotimes (_ (/ (length entries) 5))
- After: (dotimes (_ (floor (* (length entries) wttrin--cache-cleanup-percentage)))
- Added: wttrin--cache-cleanup-percentage constant (0.20 = 20%)
- Explains WHY 20%: provides buffer before next cleanup cycle
2. Mode-line startup delay (line 508):
- Before: (run-at-time 3 nil #'wttrin--mode-line-fetch-weather)
- After: (run-at-time wttrin-mode-line-startup-delay nil ...)
- Added: wttrin-mode-line-startup-delay defcustom (default 3 seconds)
- Now user-customizable, range 1-5 seconds recommended
Added comprehensive tests (8 tests, all passing):
- 5 tests verify cache cleanup behavior (removes ~20% of oldest entries)
- 3 tests verify startup delay defcustom exists and has reasonable value
Benefits:
- Self-documenting code (explains WHY these values exist)
- Startup delay is now user-customizable
- Easier for future maintainers to understand rationale
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Add 34 new tests covering the three helper functions extracted from
wttrin--display-weather:
- test-wttrin--validate-weather-data.el (12 tests)
- test-wttrin--process-weather-content.el (12 tests)
- test-wttrin--add-buffer-instructions.el (10 tests)
Tests follow Normal/Boundary/Error pattern and all pass.
Co-Authored-By: Claude <noreply@anthropic.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
- Enhanced test-wttrin-additional-url-params with clearer test organization
- Enhanced test-wttrin--build-url with comprehensive boundary and error cases
- Added tests for Unicode, special characters, GPS coordinates, domains
- Fixed domain name test to check for URL-encoded @ symbol (%40)
- Enhanced test-wttrin--make-cache-key with extensive boundary tests
- Critical test: same location with different units produces different keys
- Added tests for special chars, Unicode, empty strings, pipe characters
All 29 tests for these three pure functions now pass (6 + 12 + 11)
Combined with wttrin--fetch-url tests: 38 total tests passing
|
| |
|
|
|
|
|
|
|
|
|
| |
- Created wttrin--fetch-url helper to eliminate code duplication
- Refactored wttrin-fetch-raw-string to use helper (27 lines -> 3 lines)
- Refactored wttrin--mode-line-fetch-weather to use helper (~30 lines -> ~10 lines)
- Added comprehensive ERT test suite with 9 tests covering normal, boundary, and error cases
- All tests passing
This refactoring provides a single point of truth for async URL fetching,
making the code more maintainable and reducing duplication by ~40 lines.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Introduce asynchronous data fetching to the wttrin.el Emacs package.
This enhancement avoids blocking Emacs during data retrieval by
using `url-retrieve` for async calls. The behavior is controlled via
a new customizable variable `wttrin-use-async`. Tests have been
added for the new async behavior to ensure proper functionality.feat:makefile): Add package initialization for Emacs batch
Enhance Makefile with package support by loading and initializing
MELPA archive before validating and compiling, ensuring required
packages are available during these operations.
feat(tests): Add unit tests for `wttrin--display-weather`
Introduce comprehensive tests for `wttrin--display-weather` function
to validate buffer creation, content, keybindings, and error
handling.
|
|
|
Session 1: Testing infrastructure and initial test coverage
Bug fixes in wttrin.el:
- Fix wttrin-additional-url-params to handle nil unit system
- Remove incorrect callback parameter to url-retrieve-synchronously
- Add nil buffer check for network failures
- Strip HTTP headers before decoding response
- Kill buffer after fetch to prevent memory leaks
- Fix double concatenation of URL params in cache function
- Add proper URL encoding via new wttrin--build-url function
Refactoring:
- Extract wttrin--build-url as pure, testable function
- Separate URL building logic from network I/O
Test infrastructure (33 tests, 100% passing):
- tests/testutil-wttrin.el: Shared test utilities
- tests/test-wttrin-additional-url-params.el: 7 tests
- tests/test-wttrin--make-cache-key.el: 9 tests
- tests/test-wttrin--build-url.el: 10 tests
- tests/test-wttrin--cleanup-cache-if-needed.el: 7 tests
Documentation:
- docs/testing-plan.org: Comprehensive testing roadmap
- docs/bugs.org: Bug analysis from code review
- docs/NOTES.org: Session tracking and guidelines
- docs/session-1-summary.org: Detailed session summary
Next session: Cache workflow tests, parsing logic extraction, integration tests
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|