aboutsummaryrefslogtreecommitdiff
path: root/wttrin.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-28 04:11:45 -0400
committerCraig Jennings <c@cjennings.net>2026-06-28 04:11:45 -0400
commitda7ee0841924dfbd91c9a944e0bfeff6903bd8a1 (patch)
treeb3461a7d9aa3971b55bfeeab9aeddb06d1b088fe /wttrin.el
parentce74e30562dfac3f599a94a45ac16c3c2319ab41 (diff)
downloademacs-wttrin-da7ee0841924dfbd91c9a944e0bfeff6903bd8a1.tar.gz
emacs-wttrin-da7ee0841924dfbd91c9a944e0bfeff6903bd8a1.zip
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.
Diffstat (limited to 'wttrin.el')
-rw-r--r--wttrin.el6
1 files changed, 5 insertions, 1 deletions
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)