Repository navigation
Key buffer reuse on structured identities - #625
Merged
Merged
Conversation
Two projects sharing a directory basename rendered the same project-prefixed buffer name, so ghostel-project reused one project's terminal for the other and the project cycle commands conflated them. Replace the name-string ghostel--buffer-identity with a structured ghostel-identity alist: a mandatory kind (term, compile, exec, eshell, or a third-party symbol), composable scope keys such as project-root and the plain-terminal name, and an instance number on reusable slots. Slot reuse compares whole identities; scoped listings match subsets via the new ghostel-identity-match-p. ghostel and ghostel-project become thin wrappers over a shared ghostel--start core. The buffer name is now purely cosmetic; the new buffer-local ghostel--initial-name records the creation name as the title-clear revert target. Bookmarks store the identity alist and reuse live buffers only through slot identities, so shared kind-only identities cannot hijack an unrelated buffer; legacy string records restore identity-less. ghostel-exec gains an optional IDENTITY argument for third-party kinds. Remote project roots are keyed verbatim, since TRAMP path normalization depends on connection state.
ghostel-exec records its program and arguments in the identity's command key; callers passing IDENTITY store it verbatim and add their own command key for restorable bookmarks. The eshell visual-command integration does the same. Jumping to such a bookmark reattaches to a live ghostel buffer whose identity command equals the record's -- buffer names may have been uniquified or changed since -- and otherwise respawns the recorded command in the bookmarked directory, killing the partial buffer if the spawn fails. The typed cd on reuse is limited to shells; command buffers are left alone. Restored buffers are plain ghostel-exec buffers without kind-specific wiring, and the argv is saved to the bookmark file in plaintext.
dakra
force-pushed
the
feat/structured-identity
branch
2 times, most recently
from
August 12, 2026 14:21
75c119c to
fd53e45
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 #432.
Problem
ghostel-projectkeyed terminals by a buffer name derived from the project directory's basename, so two projects sharing a basename (~/a/band~/d/b) mapped to the same*b-ghostel*identity: the second project reused the first project's terminal, and the project cycle commands conflated the two.Change
Buffer identity becomes a structured alist instead of a name string (
ghostel-identity, public):kind(mandatory):term,compile,exec,eshell, or a third-party symbol.project-rootfor project terminals,namefor plain terminals,command(program + args) for exec-style buffers; room for future scopes (tab, workspace).instancemarks reusable slots.Slot reuse compares whole identities; scoped listings match subsets via the new
ghostel-identity-match-p.ghostelandghostel-projectare thin wrappers over a shared core; the buffer name is purely cosmetic. The identity-scope cycle commands include numbered instances and exclude non-terminal buffers (e.g. a runningghostel-compile).ghostel-execgains an optional IDENTITY argument so third-party packages can tag and filter their own buffers.Bookmarks store the identity alist. Bookmarks of exec/eshell-visual buffers become restorable: the recorded
commandreattaches to a live buffer running that command, or respawns it in the bookmarked directory (restored buffers are plainghostel-execbuffers without kind-specific wiring; the argv is saved to the bookmark file in plaintext).Behavior changes
*ghostel*<1>buffer).ghostel-buffer-name-function, a title clear reverts to the creation-time name recorded in the newghostel--initial-name.Testing
make -j8 all(elisp, native, zig, evil suites). New ERT coverage: same-basename collision repro, subset matching, numbered-instance scoping, next-free instances, kind exclusion, bookmark reattach/respawn/failure-cleanup, render-free title-clear revert. Live-verified in sandboxed Emacs sessions: plain slots, project flows (includingcdcross-contamination), compile identity across the view-mode switch, eshell visual commands, bookmark reattach/respawn.