| Age | Commit message (Collapse) | Author |
|
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>
|