From da7ee0841924dfbd91c9a944e0bfeff6903bd8a1 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 28 Jun 2026 04:11:45 -0400 Subject: fix: don't steal focus when an async weather response renders wttrin--display-weather ran switch-to-buffer from the async callback, so a response arriving after the user moved to another buffer yanked them back to *wttr.in*. It now renders with set-buffer; selecting the buffer is the interactive command's job (wttrin-query already does it at invocation), so a late response updates the buffer in place without changing the selected window. --- wttrin.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'wttrin.el') diff --git a/wttrin.el b/wttrin.el index e34fdb5..c0359d9 100644 --- a/wttrin.el +++ b/wttrin.el @@ -1176,7 +1176,11 @@ coordinates but can name the place)." "Cannot retrieve weather data. Perhaps the location was misspelled?")) (wttrin--add-to-location-history display) (let ((buffer (get-buffer-create (format "*wttr.in*")))) - (switch-to-buffer buffer) + ;; Render into the buffer without selecting it. This runs from an + ;; async callback; the command (wttrin-query) already showed the buffer + ;; at invocation time, so re-selecting here would steal focus if the + ;; user moved away while the fetch was in flight. + (set-buffer buffer) ;; wttrin-mode calls kill-all-local-variables, so it must run ;; before setting any buffer-local state (xterm-color, location) -- cgit v1.2.3