aboutsummaryrefslogtreecommitdiff
path: root/wttrin.el
Commit message (Collapse)AuthorAgeFilesLines
* feat: add wttrin-display-options for wttr.in flag customization (closes #3)Craig Jennings2026-05-051-1/+25
| | | | | | | | | | | | 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.
* docs: explain mode-line state and update flowCraig Jennings2026-04-261-0/+20
| | | | | | Four variables hold the mode-line's runtime state: the cache, the rendered string, the stale-render flag, and the refresh timer. They get updated in a specific order across three different functions. Anyone reading `wttrin--mode-line-tooltip` for the first time hits a clever bit on every hover: the tooltip re-evaluates staleness and triggers a re-render of the icon if it flipped. Without a comment that ties this to the rest of the update flow, you have to trace through three other functions to understand why. The new comment block above the defvars lays out the order and the hover-driven re-render in one place, so future readers don't have to reconstruct it from the call graph.
* refactor: extract wttrin--mode-line-extract-emoji helperCraig Jennings2026-04-261-4/+10
| | | | | | | | 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).
* refactor: extract wttrin--mode-line-stale-p helperCraig Jennings2026-04-261-5/+13
| | | | | | | | 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.
* bump version to 0.3.2v0.3.2Craig Jennings2026-04-261-1/+1
|
* fix: omit :foreground from emoji icon face when no color providedCraig Jennings2026-04-261-4/+7
| | | | | | The font branch of wttrin--make-emoji-icon built its face plist with `:foreground foreground` even when foreground was nil, producing a literal `(:family ... :height 1.0 :foreground nil)`. The mode-line redisplays many times per second, and Emacs validates faces on every redisplay. A single fresh-cache state produced hundreds of "Invalid face attribute :foreground nil" warnings in *Messages*. The bug's been live since 2026-02-21 (b74b98f). The 130bbc07 helper extraction kept it in place. Switch to backquote splicing so the :foreground key is included only when foreground is non-nil. Behavior is identical on the colored path. On the nil path the emoji renders with the default mode-line color, the same visible result as before, without the warning flood.
* feat: add IP geolocation command for setting wttrin-favorite-locationCraig Jennings2026-04-221-0/+34
| | | | | | | | | | | | 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.
* bump version to 0.3.1v0.3.1Craig Jennings2026-04-041-1/+1
|
* fix: weather ASCII art wraps when window is narrowCraig Jennings2026-04-041-0/+2
| | | | | Enable truncate-lines in wttrin-mode so the fixed-width weather art clips at the window edge instead of wrapping and breaking the layout.
* fix: weather buffer shows location in lowercaseCraig Jennings2026-04-041-0/+4
| | | | | | 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.
* feat: specific error messages for fetch failuresCraig Jennings2026-04-041-29/+65
| | | | | | | | | | | | | | 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.
* bump version to 0.3.0v0.3.0Craig Jennings2026-04-041-1/+1
| | | | | | Dynamic mode-line tooltip, staleness dimming, location casing fix, debug guard refactor, expanded test suite (307 tests), and multiple bug fixes since 0.2.3.
* fix: clean byte-compilation warningsCraig Jennings2026-04-041-2/+2
| | | | | | | Move define-obsolete-variable-alias before its referent defcustom to fix "alias should be declared before its referent" warning. Add defvar for wttrin--force-refresh in wttrin-debug.el so the byte-compiler knows the dynamic variable is intentional.
* doc: note wttr.in update frequency in refresh interval docstringsCraig Jennings2026-04-041-2/+5
| | | | | | wttr.in updates its data roughly every 10 minutes (max-age=600). Add a note to both refresh interval defcustoms so users know not to poll more aggressively than the service can provide.
* doc: improve source comments for senior developer audienceCraig Jennings2026-04-041-23/+21
| | | | | | | | | | Remove obvious comments that restate what the code does ("save debug data if enabled", "temporarily allow editing", "align buffer to top"). Add comments explaining non-obvious decisions: why risky-local-variable is needed, why user-agent is curl, what wttr.in format codes mean, what the emoji extraction regex matches, and why after-init-time matters. Fix stale docstrings that no longer match the no-op stub pattern.
* fix: emoji dimming can disagree with tooltip stalenessCraig Jennings2026-04-041-0/+10
| | | | | | | | | | 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.
* fix: cache timestamp reflects request time, not response timeCraig Jennings2026-04-041-3/+2
| | | | | | | 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.
* fix: validate-weather-data corrupts match dataCraig Jennings2026-04-041-1/+1
| | | | | string-match modifies global match data as a side effect. A predicate should not do this. Use string-match-p instead.
* fix: mode-line tooltip always shows "Updated just now"Craig Jennings2026-04-041-14/+26
| | | | | | | | | | | 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".
* fix: mode-line tooltip shows location in lowercaseCraig Jennings2026-04-041-1/+11
| | | | | | | 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.
* doc: update copyright years to 2026 and add missing author fieldCraig Jennings2026-04-041-1/+1
| | | | | Update copyright headers across all 37 .el files to include 2026. Add missing Author field to testutil-wttrin.el for consistency.
* refactor: remove malformed autoload cookie for risky-local-variableCraig Jennings2026-04-041-1/+0
| | | | | | The ;;;###autoload(put ...) form on the same line was never processed by the autoload generator. The actual (put ...) call on the next line handles this at load time. Remove the dead cookie.
* refactor: extract mode-line icon and string helpersCraig Jennings2026-04-041-40/+32
| | | | | | | | 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.
* refactor: replace debug guard blocks with self-guarding no-op stubsCraig Jennings2026-04-041-62/+43
| | | | | | | | | Define wttrin--debug-log and wttrin--debug-mode-line-info as no-op stubs in wttrin.el that get overridden when wttrin-debug.el loads. Remove all 24 (when (featurep 'wttrin-debug) ...) guard blocks. Reduces cyclomatic complexity across 12 functions and eliminates visual clutter without changing behavior.
* refactor: remove dead wttrin-exit functionCraig Jennings2026-04-041-5/+0
| | | | | Never called anywhere. The 'q' keybinding in wttrin-mode inherits quit-window from special-mode, making this function redundant.
* test: add 50 tests for untested functions; fix nil crash in save-debug-dataCraig Jennings2026-04-041-4/+8
| | | | | | | | | | | | | | | | | 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.
* feat: unified cache and staleness handling for mode-line and bufferCraig Jennings2026-02-211-60/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* feat: mode-line: show hourglass placeholder before first weather fetchCraig Jennings2026-02-201-0/+17
| | | | | | Display ⏳ with "Fetching weather..." tooltip immediately when mode-line mode starts, so the user sees wttrin is active before the first API response arrives.
* fix: mode-line: validate API response before updating displayCraig Jennings2026-02-201-4/+19
| | | | | | 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.
* refactor: core: rename wttrin-mode-line-favorite-location to ↵Craig Jennings2025-11-131-15/+16
| | | | | | | | 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.
* doc: core: fix checkdoc warnings in docstringsCraig Jennings2025-11-131-2/+2
| | | | | | Fixed two checkdoc issues in recently added functions: - Added double space after period in wttrin--extract-response-body - Quoted url-retrieve symbol in wttrin--handle-fetch-callback
* feat: mode-line: defer network requests until after Emacs initializationCraig Jennings2025-11-131-1/+7
| | | | | | Prevents mode-line from making network requests during Emacs startup. Network activity now deferred to after-init-hook when Emacs is not yet fully initialized, improving startup performance.
* refactor: fetch: extract response parsing into separate testable functionsCraig Jennings2025-11-131-29/+50
| | | | | | 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.
* refactor: core: lazy-load xterm-color dependencyCraig Jennings2025-11-081-1/+5
| | | | | | | | | | | | | | | | | 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)
* refactor: debug: route all debug output to debug log instead of MessagesCraig Jennings2025-11-081-13/+12
| | | | | | | | - Remove (message ...) call from wttrin--debug-log function - Replace 9 debug message calls in wttrin.el with wttrin--debug-log - All debug output now goes to debug log for review with M-x wttrin-debug-show-log - User-facing error messages preserved (network errors, processing errors) - Updated docstring to clarify messages are stored for later review
* refactor: Improve cache cleanup clarity and add input validationCraig Jennings2025-11-081-19/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* feat: debug: add comprehensive debug logging and integration testsCraig Jennings2025-11-081-11/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* refactor: mode-line: extract inline keymap to shared defvarCraig Jennings2025-11-081-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* refactor: config: replace magic numbers with named constantsCraig Jennings2025-11-081-5/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* refactor: render: split wttrin--display-weather into focused helper functionsCraig Jennings2025-11-081-12/+25
| | | | | | | | | | | | | - Extracted wttrin--validate-weather-data for data validation - Extracted wttrin--process-weather-content for ANSI filtering and cleanup - Extracted wttrin--add-buffer-instructions for UI instructions - Refactored main function to use helpers (improved readability) Benefits: - Each function has single, clear purpose - Easier to test individual components - Better code organization and maintainability - Main function reduced from ~40 lines to ~20 lines
* refactor: fetch: extract duplicate URL fetching logic into wttrin--fetch-urlCraig Jennings2025-11-081-35/+19
| | | | | | | | | | | - 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.
* fix(wttrin): Fix ANSI color rendering on fresh Emacs launchCraig Jennings2025-11-041-15/+15
| | | | | | | | | | | | | | | | | | | | 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
* feat:wttrin: Add auto-enable option for mode-line weather displayCraig Jennings2025-11-041-0/+12
| | | | | | | Introduce `wttrin-mode-line-auto-enable` customization option. When set to non-nil, this automatically enables the mode-line weather display upon loading wttrin. Users can still manually toggle the display with `wttrin-mode-line-mode`.
* refactor:debug: Rename and enhance wttrin debug functionsCraig Jennings2025-11-041-5/+224
| | | | | | | | | | - Reorganized debugging utilities by renaming `debug-wttrin.el` to `wttrin-debug.el` and adding new functions. - The updated module now supports `debug-wttrin-mode-line` for detailed mode-line diagnostics and introduces customizable mode-line weather display with new configuration options. - Additionally, extended debugging capabilities ensure concise emoji-based weather info and tooltip data management, incorporated with auto-loaded conditional debug logic.
* refactor:wttrin: Make asynchronous loading standardCraig Jennings2025-11-041-78/+11
| | | | | Make asynchronous loading the only mode of operation. It's well tested and doesn't lock up Emacs during fetching. Synchronous loading code has been removed.
* feat:debug: Add debugging utilities for wttrinCraig Jennings2025-11-041-17/+32
| | | | | | | | | | | Introduce debugging features to assist with wttrin display issues. New utility functions enable developers to view raw weather data with line numbers, facilitate easy debugging of header parsing. Includes debug mode toggle functions to save raw weather responses to timestamped files for bug reporting and diagnostics. Updated URL-building tests to confirm correct URL formats with additional 'F' parameter, ensuring comprehensive coverage for various input scenarios.
* feat:wttrin-mode: Add major mode for weather displayCraig Jennings2025-11-041-39/+52
| | | | | | | | | Introduce `wttrin-mode`, a derived major mode for displaying weather information from wttr.in. This includes keybindings for refreshing and querying new locations, and sets up the buffer with a custom font and read-only settings. Existing display logic has been refactored to utilize this mode for improved usability and code organization.
* feat(emacs): Add asynchronous weather fetching to wttrinCraig Jennings2025-11-041-54/+142
| | | | | | | | | | | | | | | | | | 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.
* Add comprehensive ERT test suite and fix critical bugsCraig Jennings2025-11-041-11/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add caching system for weather dataCraig Jennings2025-09-251-11/+93
| | | | | | | | | | | | | | Implement a caching mechanism to reduce API calls and improve performance. The cache stores weather data with configurable TTL (15 minutes default) and automatic cleanup when exceeding max entries (50 default). - Add cache configuration options for TTL and max entries - Store fetched data with timestamps in hash table - Add force refresh functionality with 'r' key binding - Implement automatic cache cleanup to prevent unbounded growth - Fall back to stale cache on network errors - Also, fixed URL parameter concatenation in fetch function