Skip to content

Keep sentinel cleanup in the terminal buffer after exit functions run - #658

Merged
dakra merged 1 commit into
mainfrom
fix/exit-hook-wrong-buffer
Aug 28, 2026
Merged

dakra merged 1 commit into
mainfrom
fix/exit-hook-wrong-buffer

Conversation

@dakra

@dakra dakra commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Fixes #630 (the remaining variant after #632).

An exit function may delete the terminal's selected window or kill its buffer. Deleting the selected window selects another window, which also switches the current buffer, so the sentinel's remaining cleanup ran in whatever buffer that window showed: ghostel--sync-read-only locked it read-only (the reported symptom — the buffer the user came from turned read-only after C-d/exit) and its desktop-save-buffer was clobbered. This bypassed ghostel--enter-readonly*, which is why the read-only logging advice in the issue never fired.

The sentinel now runs the post-hook cleanup in an explicit with-current-buffer on the terminal buffer, skipping it when an exit function already killed the buffer.

Includes a regression test reproducing the exact scenario (window-deleting exit hook, origin buffer in the surviving window); it fails against the previous sentinel and passes now. make -j8 all is green, and the fix was verified in a live session: with a window-deleting ghostel-exit-functions hook, the origin buffer stays writable after the shell exits.

An exit function may delete the terminal's selected window or kill its
buffer.  Deleting the selected window selects another window, which also
switches the current buffer, so the sentinel's remaining cleanup ran in
whatever buffer that window showed: ghostel--sync-read-only locked it
read-only and its desktop-save-buffer was clobbered.  Run the cleanup in
an explicit with-current-buffer on the terminal buffer, skipping it when
an exit function already killed the buffer.

Fixes #630
@dakra
dakra force-pushed the fix/exit-hook-wrong-buffer branch 2 times, most recently from bf46d62 to 7c4cbd9 Compare August 28, 2026 12:12
@dakra
dakra merged commit 7c4cbd9 into main Aug 28, 2026
33 checks passed
@dakra
dakra deleted the fix/exit-hook-wrong-buffer branch August 28, 2026 12:15

This branch was previously deployed

1 inactive deployment
github-pages — 7c4cbd9f Deployed Aug 28, 2026 by dakra via deploy #176
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.

Overly aggressive read-only mode

1 participant