diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-04 13:00:19 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-04 13:00:19 -0500 |
| commit | 25b760d805e98ff3c0f0f9b29f75a108fb1dce10 (patch) | |
| tree | 5ada9a76c1a5424043f721e2c3aeb2cd069eacbf /wttrin.el | |
| parent | 622ae39ad1e2544980cff73af8a5d5b2a64dacc8 (diff) | |
| download | emacs-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.el | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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 |
