Skip to content

Add Org links to ghostel terminals - #692

Merged
dakra merged 3 commits into
mainfrom
feat/org-links
Sep 16, 2026
Merged

dakra merged 3 commits into
mainfrom
feat/org-links

Conversation

@dakra

@dakra dakra commented Sep 16, 2026

Copy link
Copy Markdown
Owner

Adds an opt-in ghostel-org.el registering the ghostel: Org link type, plus two changes it leans on. Fixes #653.

Org links (ghostel-org.el, enable with (use-package ghostel-org :after org))

  • ghostel:DIR pops to a live shell terminal whose working directory is DIR, or starts one there.
  • ghostel:DIR::NAME behaves like a bookmark: it reuses buffer NAME, typing a cd when it sits elsewhere, or starts NAME in DIR. org-store-link in a ghostel buffer stores this form; org-insert-link completes with a directory prompt.

Bookmarks

  • The typed cd is gated on an idle shell: not on the alternate screen, no OSC 133 command running, cursor at the start of an empty input line. A busy shell is still switched to, with a message.
  • A shell created for a record without identity gets the plain-terminal slot for its name, so ghostel can claim it instead of opening a second buffer.
  • A directory that only differs in spelling (symlink, abbreviation) no longer earns a cd.

Fixes

  • Starting a terminal in a local directory that no longer exists signals a user-error from ghostel--init-buffer. Before, the native child exited at once and the buffer vanished silently. Desktop restore relies on this instead of its own check.
  • ghostel-create kills its buffer and re-signals when the spawn fails.

On the native PTY a child that cannot chdir exits at once, and with
`ghostel-kill-buffer-on-exit' the buffer vanishes before the error can
be read.  `ghostel--init-buffer' now signals a `user-error' for a
missing local directory, covering `ghostel', bookmarks, and desktop
restore alike; remote directories are left to TRAMP, which reports
them itself.  desktop.el's own skip goes away, as it logs the error the
same way.

`ghostel-create' kills its buffer and re-signals when the spawn fails,
instead of leaving an empty ghostel-mode buffer behind.
The `cd' typed into a reused bookmark buffer assumed the shell sat at an
empty prompt; mid-command or inside a full-screen program it corrupted
the input.  It is now gated on `ghostel-bookmark--shell-idle-p': not on
the alternate screen, no OSC 133 command running, and the cursor at the
start of an empty input line.  A busy shell is still switched to, with a
message.

The shell create branch goes through `ghostel-create', so a record
without a recorded identity gets the plain-terminal slot for its name
and `ghostel' can claim the buffer instead of opening a second one.
A new opt-in ghostel-org.el registers the `ghostel:' Org link type.
`ghostel:DIR' pops to a live terminal in that directory or starts a
shell there; `ghostel:DIR::NAME' behaves like a bookmark, reusing the
named buffer or starting it in DIR.  `org-store-link' in a ghostel
buffer stores the latter, and `org-insert-link' completes with a
directory prompt.

Fixes #653
@dakra
dakra merged commit 9ba6fb3 into main Sep 16, 2026
33 checks passed
@dakra
dakra deleted the feat/org-links branch September 16, 2026 11:45

This branch was successfully deployed

1 active deployment
github-pages — 9ba6fb30 Deployed Sep 16, 2026 by dakra via deploy #193
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.

Add Org links for Ghostel terminals

1 participant