diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-28 04:11:45 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-28 04:11:45 -0400 |
| commit | da7ee0841924dfbd91c9a944e0bfeff6903bd8a1 (patch) | |
| tree | b3461a7d9aa3971b55bfeeab9aeddb06d1b088fe /wttrin.el | |
| parent | ce74e30562dfac3f599a94a45ac16c3c2319ab41 (diff) | |
| download | emacs-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.el | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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) |
