Repository navigation
Add desktop.el session persistence - #627
Merged
Merged
Conversation
Owner
|
Haven't looked too closely but looks good on a quick pass. |
Contributor
Author
|
Thanks! I plan to update all my PRs soon but haven't been able to do so yet. |
A saved terminal records its working directory and identity; desktop-read starts a fresh shell in that directory under the saved buffer name, so restored window configurations find the buffer and identity-based reuse (ghostel-project etc.) carries over the restart. Command buffers and remote terminals are skipped, with a message: a desktop restore runs unattended at startup, where re-running a saved command or opening TRAMP connections would be surprising. Architecture mirrors ghostel-bookmark.el: a lazily loaded ghostel-desktop.el with autoloaded save/restore functions.
dakra
force-pushed
the
desktop-support
branch
2 times, most recently
from
August 16, 2026 08:54
4b8f545 to
9db5153
Compare
Owner
|
@mrcnski thanks. I rebased, fixed the CI, the lint warnings and some other edge cases my clanker complained about (restore when the directory doesn't exists anymore, dead terminals and buffer renames) Merged 🙏 |
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.
Problem
Terminals don't survive an Emacs restart. Even with
desktop-save-modeenabled, every ghostel buffer is simply gone afterdesktop-read. desktop.el skips non-file buffers unless their mode opts in, so a saved session restores files and window layouts only.#625 made a fix straightforward: the desktop handlers persist one
ghostel-identityalist.Fix
A new
ghostel-desktop.el, mirroringghostel-bookmark.el's architecture:ghostel-modepoints the buffer-localdesktop-save-bufferat an autoloaded save function (a quoted symbol, no load-time dependency)desktop-buffer-mode-handlersunderwith-eval-after-load 'desktop.desktop-readloads ghostel itself through the saved major mode and looks the handler up immediately, before anything could load ghostel-desktop.el.Saving records
(DIRECTORY IDENTITY). Restoring reuses a live buffer with the saved slot identity (so a repeateddesktop-readdoesn't spawn duplicates), otherwise starts a fresh shell in the directory under the exact saved buffer name, with the saved identity as itsghostel-identity. Window configurations find the buffer by name, andghostel-projectand friends keep reusing the restored terminal. A failed spawn (e.g. the directory no longer exists) kills the partial buffer and re-signals so desktop.el reports the buffer and moves on.Two kinds of saved terminals are deliberately skipped, with a message:
ghostel-exec,ghostel-compile, eshell visual commands — identities with acommandkey). Unlike a bookmark jump, a desktop restore runs unattended at startup, and automatically re-running a saved command (e.g. a build) seemed like a footgun. Happy to add an opt-in defcustom for respawning such commands if you'd like parity with the bookmark jump.desktop-read. As above, an opt-in is easy if wanted.I kept v1 free of new defcustoms given the API overhaul you mentioned. Both skips are documented in the README's new Desktop section.
Other info
Eleven tests modeled on ghostel-bookmark-test.el.
README section, comparison-table row, and CHANGELOG entry included.
Restoring many terminals spawns one shell per buffer. The README points at the stock
desktop-restore-eagerfor throttling rather than anything ghostel-specific.🤖 Generated with Claude Code