Skip to content

Fix buffer-local window-change hooks before Emacs 31 - #798

Merged
dakra merged 2 commits into
mainfrom
fix/anchor-unselected-window-pre-31
Nov 8, 2026
Merged

dakra merged 2 commits into
mainfrom
fix/anchor-unselected-window-pre-31

Conversation

@dakra

@dakra dakra commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Until Emacs 31, a buffer-local window-buffer-change-functions entry runs in whatever buffer is current, not in its own buffer (Emacs commit 1434bc97dc9 changed that). Two ghostel hooks assumed their own buffer:

  • ghostel--window-buffer-change compared the window's buffer with the current one, so a ghostel buffer shown in an unselected window (e.g. display-buffer from another buffer) was never anchored. The comparison now applies only from Emacs 31, where the hook also runs for the buffer the window lost; ghostel--anchor-window already resolves the window's buffer itself.
  • ghostel--sync-tty-composition set auto-composition-mode in the current buffer, so on a TTY frame it turned composition off in the calling buffer and left the ghostel buffer unset. It now sets it in the window's buffer, only for a ghostel buffer.

The pre-31 hook behaviour was confirmed with a standalone copy of the anchoring guard on Emacs 29.4 and 30.2 (Docker) against 32.0.50. Both new tests fail on the old code.

Caveat: Emacs master builds reporting 31.0.50 from before 2025-10-06 lack the upstream change and keep the old anchoring behaviour.

dakra added 2 commits November 8, 2026 00:54
Until Emacs 31 a buffer-local `window-buffer-change-functions' entry runs
in whatever buffer is current, so comparing the window's buffer with the
current one skipped anchoring a ghostel buffer displayed in a window that
is not selected, e.g. via `display-buffer' from another buffer.  Keep the
comparison from Emacs 31, where the hook runs in its own buffer and also
for the buffer the window lost.
`ghostel--sync-tty-composition' is a buffer-local
`window-buffer-change-functions' entry but set `auto-composition-mode'
in the current buffer.  Before Emacs 31 that is whatever buffer is
current, so showing a ghostel buffer on a TTY frame via `display-buffer'
turned composition off in the calling buffer and left the ghostel buffer
unset.  Set it in the window's buffer, and only for a ghostel buffer.
@dakra
dakra merged commit 4bed2ce into main Nov 8, 2026
33 checks passed
@dakra
dakra deleted the fix/anchor-unselected-window-pre-31 branch November 8, 2026 11:15

This branch was previously deployed

1 inactive deployment
github-pages — 4bed2cea Deployed Nov 8, 2026 by dakra via deploy #258
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant