From bf989bb594680eb2e3b69f55752353aa33cb47bb Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 13 Nov 2025 14:14:45 -0600 Subject: refactor: core: rename wttrin-mode-line-favorite-location to 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. --- README.org | 10 +++++----- tests/fixtures/test-init.el | 2 +- tests/test-wttrin--mode-line-map.el | 2 +- tests/test-wttrin-ansi-color-rendering.el | 4 ++-- tests/test-wttrin-integration-with-debug.el | 2 +- tests/test-wttrin-smoke.el | 2 +- wttrin.el | 31 +++++++++++++++-------------- 7 files changed, 27 insertions(+), 26 deletions(-) diff --git a/README.org b/README.org index 2b4904c..d7ebd72 100644 --- a/README.org +++ b/README.org @@ -188,7 +188,7 @@ To enable the mode-line weather display, set your favorite location and enable a (use-package wttrin :ensure t :custom - (wttrin-mode-line-favorite-location "Berkeley, CA") + (wttrin-favorite-location "Berkeley, CA") (wttrin-mode-line-auto-enable t)) #+end_src @@ -211,7 +211,7 @@ You can customize several aspects of the mode-line weather display: #+begin_src emacs-lisp ;; Set your favorite location (required for mode-line display) - (setq wttrin-mode-line-favorite-location "New Orleans, LA") + (setq wttrin-favorite-location "New Orleans, LA") ;; Auto-enable mode-line weather on startup (setq wttrin-mode-line-auto-enable t) @@ -242,7 +242,7 @@ If wttrin isn't working as expected, enable debug mode to see detailed logging o ;; Set debug BEFORE wttrin loads (setq wttrin-debug t) :custom - (wttrin-mode-line-favorite-location "Your City")) + (wttrin-favorite-location "Your City")) #+end_src *❌ This will NOT work* (debug set too late): @@ -251,7 +251,7 @@ If wttrin isn't working as expected, enable debug mode to see detailed logging o :ensure t :custom (wttrin-debug t) ;; TOO LATE - wttrin already loaded! - (wttrin-mode-line-favorite-location "Your City")) + (wttrin-favorite-location "Your City")) #+end_src **** For manual/development installations: @@ -262,7 +262,7 @@ If wttrin isn't working as expected, enable debug mode to see detailed logging o ;; Set debug BEFORE wttrin loads (setq wttrin-debug t) :custom - (wttrin-mode-line-favorite-location "Your City")) + (wttrin-favorite-location "Your City")) #+end_src *** Viewing Debug Output diff --git a/tests/fixtures/test-init.el b/tests/fixtures/test-init.el index 26e8395..c635887 100644 --- a/tests/fixtures/test-init.el +++ b/tests/fixtures/test-init.el @@ -8,7 +8,7 @@ ;; Configure wttrin (setq wttrin-default-locations '("Berkeley, CA" "New Orleans, LA")) (setq wttrin-unit-system "m") ; Metric -(setq wttrin-mode-line-favorite-location "Berkeley, CA") +(setq wttrin-favorite-location "Berkeley, CA") (setq wttrin-mode-line-startup-delay 0) ; No delay for tests (setq wttrin-mode-line-refresh-interval 3600) ; 1 hour diff --git a/tests/test-wttrin--mode-line-map.el b/tests/test-wttrin--mode-line-map.el index ed227cf..7a1052e 100644 --- a/tests/test-wttrin--mode-line-map.el +++ b/tests/test-wttrin--mode-line-map.el @@ -64,7 +64,7 @@ "Test that mode-line display uses wttrin--mode-line-map after refactoring. This test verifies the refactoring eliminated inline keymap construction." ;; Set up minimal mode-line state - (let ((wttrin-mode-line-favorite-location "Test, CA") + (let ((wttrin-favorite-location "Test, CA") (wttrin--mode-line-tooltip-data "Test weather")) ;; Update the mode-line display (wttrin--mode-line-update-display "☀️") diff --git a/tests/test-wttrin-ansi-color-rendering.el b/tests/test-wttrin-ansi-color-rendering.el index 0945a2f..656971b 100644 --- a/tests/test-wttrin-ansi-color-rendering.el +++ b/tests/test-wttrin-ansi-color-rendering.el @@ -120,7 +120,7 @@ This reproduces the bug where mode-line click shows white text." (let* ((location "Paris") (cache-key (wttrin--make-cache-key location)) (now 1000.0) - (wttrin-mode-line-favorite-location location)) + (wttrin-favorite-location location)) ;; Mock the async fetch to return ANSI-coded data (cl-letf (((symbol-function 'float-time) @@ -259,7 +259,7 @@ This is the exact user workflow that exposes the bug." (unwind-protect (let* ((location "Tokyo") (now 1000.0) - (wttrin-mode-line-favorite-location location) + (wttrin-favorite-location location) (mode-line-fetch-count 0) (main-fetch-count 0)) diff --git a/tests/test-wttrin-integration-with-debug.el b/tests/test-wttrin-integration-with-debug.el index 4b122bf..0330bb3 100644 --- a/tests/test-wttrin-integration-with-debug.el +++ b/tests/test-wttrin-integration-with-debug.el @@ -43,7 +43,7 @@ ;; Clear cache (wttrin-clear-cache) ;; Set test configuration - (setq wttrin-mode-line-favorite-location "Berkeley, CA") + (setq wttrin-favorite-location "Berkeley, CA") (setq wttrin-mode-line-startup-delay 1) ; Minimum valid value (setq wttrin-unit-system "m")) diff --git a/tests/test-wttrin-smoke.el b/tests/test-wttrin-smoke.el index acf7fd5..b3c7eee 100644 --- a/tests/test-wttrin-smoke.el +++ b/tests/test-wttrin-smoke.el @@ -71,7 +71,7 @@ This is a REQUIRED dependency - wttrin cannot function without it." (should (boundp 'wttrin-unit-system)) (should (boundp 'wttrin-cache-ttl)) (should (boundp 'wttrin-cache-max-entries)) - (should (boundp 'wttrin-mode-line-favorite-location)) + (should (boundp 'wttrin-favorite-location)) (should (boundp 'wttrin-mode-line-refresh-interval)) (should (boundp 'wttrin-mode-line-startup-delay))) diff --git a/wttrin.el b/wttrin.el index 85eb5c3..2eed429 100644 --- a/wttrin.el +++ b/wttrin.el @@ -104,10 +104,11 @@ When cache reaches `wttrin-cache-max-entries', remove the oldest 20% to avoid frequent cleanup cycles. This value (0.20) means remove 1/5 of entries, providing a reasonable buffer before the next cleanup.") -(defcustom wttrin-mode-line-favorite-location nil - "Favorite location to display weather for in the mode-line. -When nil, mode-line weather display is disabled. -Set to a location string (e.g., \"New Orleans, LA\") to enable. +(defcustom wttrin-favorite-location nil + "Favorite location to display weather for. +When nil, favorite location features are disabled. +Set to a location string (e.g., \"New Orleans, LA\") to enable mode-line +weather display and other location-based features. The weather icon and tooltip will update automatically in the background." :group 'wttrin :type '(choice (const :tag "Disabled" nil) @@ -144,7 +145,7 @@ Set to nil to use default font (may render as monochrome)." (defcustom wttrin-mode-line-auto-enable nil "If non-nil, automatically enable mode-line weather display when loading wttrin. -When enabled, weather for `wttrin-mode-line-favorite-location' will appear +When enabled, weather for `wttrin-favorite-location' will appear in the mode-line automatically. You can also manually toggle the mode-line display with `wttrin-mode-line-mode'." :group 'wttrin @@ -479,9 +480,9 @@ This creates headroom to avoid frequent cleanups." "Fetch weather for favorite location and update mode-line display. Uses wttr.in custom format for concise weather with emoji." (when (featurep 'wttrin-debug) - (wttrin--debug-log "mode-line-fetch: Starting fetch for %s" wttrin-mode-line-favorite-location)) - (when wttrin-mode-line-favorite-location - (let* ((location wttrin-mode-line-favorite-location) + (wttrin--debug-log "mode-line-fetch: Starting fetch for %s" wttrin-favorite-location)) + (when wttrin-favorite-location + (let* ((location wttrin-favorite-location) ;; Custom format: location + emoji + temp + conditions ;; %l=location, %c=weather emoji, %t=temp, %C=conditions ;; Note: unit system must come BEFORE format in query string @@ -533,7 +534,7 @@ e.g., \"Paris: ☀️ +61°F Clear\"." 'help-echo (lambda (_window _object _pos) (or wttrin--mode-line-tooltip-data (format "Weather for %s\nClick to refresh" - wttrin-mode-line-favorite-location))) + wttrin-favorite-location))) 'mouse-face 'mode-line-highlight 'local-map wttrin--mode-line-map))) (force-mode-line-update t) @@ -546,14 +547,14 @@ e.g., \"Paris: ☀️ +61°F Clear\"." "Handle left-click on mode-line weather widget. Check cache, refresh if needed, then open weather buffer." (interactive) - (when wttrin-mode-line-favorite-location - (wttrin wttrin-mode-line-favorite-location))) + (when wttrin-favorite-location + (wttrin wttrin-favorite-location))) (defun wttrin-mode-line-force-refresh () "Handle right-click on mode-line weather widget. Force-refresh cache and update tooltip without opening buffer." (interactive) - (when wttrin-mode-line-favorite-location + (when wttrin-favorite-location (let ((wttrin--force-refresh t)) (wttrin--mode-line-fetch-weather)))) @@ -561,9 +562,9 @@ Force-refresh cache and update tooltip without opening buffer." "Start mode-line weather display and refresh timer." (when (featurep 'wttrin-debug) (wttrin--debug-log "wttrin mode-line: Starting mode-line display (location=%s, interval=%s)" - wttrin-mode-line-favorite-location + wttrin-favorite-location wttrin-mode-line-refresh-interval)) - (when wttrin-mode-line-favorite-location + (when wttrin-favorite-location ;; Delay initial fetch to allow network to initialize during startup (run-at-time wttrin-mode-line-startup-delay nil #'wttrin--mode-line-fetch-weather) ;; Set up refresh timer (starts after the interval from now) @@ -592,7 +593,7 @@ Force-refresh cache and update tooltip without opening buffer." ;;;###autoload (define-minor-mode wttrin-mode-line-mode "Toggle weather display in mode-line. -When enabled, shows weather for `wttrin-mode-line-favorite-location'." +When enabled, shows weather for `wttrin-favorite-location'." :global t :lighter (:eval wttrin-mode-line-string) (if wttrin-mode-line-mode -- cgit v1.2.3