aboutsummaryrefslogtreecommitdiff
path: root/wttrin.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-04 13:00:19 -0500
committerCraig Jennings <c@cjennings.net>2026-04-04 13:00:19 -0500
commit25b760d805e98ff3c0f0f9b29f75a108fb1dce10 (patch)
tree5ada9a76c1a5424043f721e2c3aeb2cd069eacbf /wttrin.el
parent622ae39ad1e2544980cff73af8a5d5b2a64dacc8 (diff)
downloademacs-wttrin-25b760d805e98ff3c0f0f9b29f75a108fb1dce10.tar.gz
emacs-wttrin-25b760d805e98ff3c0f0f9b29f75a108fb1dce10.zip
fix: mode-line tooltip shows location in lowercase
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.
Diffstat (limited to 'wttrin.el')
-rw-r--r--wttrin.el12
1 files changed, 11 insertions, 1 deletions
diff --git a/wttrin.el b/wttrin.el
index c93aae2..972a2e8 100644
--- a/wttrin.el
+++ b/wttrin.el
@@ -507,6 +507,14 @@ This creates headroom to avoid frequent cleanups."
;;; Mode-line weather display
+(defun wttrin--replace-response-location (response location)
+ "Replace the API's location prefix in RESPONSE with LOCATION.
+The wttr.in API returns locations in lowercase. This substitutes the
+user's original casing so tooltips display what the user expects."
+ (if (string-match ":" response)
+ (concat location (substring response (match-beginning 0)))
+ response))
+
(defun wttrin--make-emoji-icon (emoji &optional foreground)
"Create EMOJI string with optional font face and FOREGROUND color.
Uses `wttrin-mode-line-emoji-font' when configured."
@@ -571,7 +579,9 @@ On failure with no cache, shows error placeholder."
(wttrin--debug-log "mode-line-fetch: Received data = %S" trimmed-data)
(if (wttrin--mode-line-valid-response-p trimmed-data)
(progn
- (setq wttrin--mode-line-cache (cons (float-time) trimmed-data))
+ (setq wttrin--mode-line-cache
+ (cons (float-time)
+ (wttrin--replace-response-location trimmed-data location)))
(wttrin--mode-line-update-display))
(wttrin--debug-log "mode-line-fetch: Invalid response, keeping previous display")))
;; Network error / nil data