Repository navigation
Keep sentinel cleanup in the terminal buffer after exit functions run - #658
Merged
Merged
Conversation
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
force-pushed
the
fix/exit-hook-wrong-buffer
branch
2 times, most recently
from
August 28, 2026 12:12
bf46d62 to
7c4cbd9
Compare
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-onlylocked it read-only (the reported symptom — the buffer the user came from turned read-only afterC-d/exit) and itsdesktop-save-bufferwas clobbered. This bypassedghostel--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-bufferon 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 allis green, and the fix was verified in a live session: with a window-deletingghostel-exit-functionshook, the origin buffer stays writable after the shell exits.