From 25b760d805e98ff3c0f0f9b29f75a108fb1dce10 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 4 Apr 2026 13:00:19 -0500 Subject: 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. --- wttrin.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'wttrin.el') 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 -- cgit v1.2.3