Repository navigation
Add ghostel-control-mode-function for tmux control mode - #792
Merged
Merged
Conversation
A package that shows tmux panes as buffers needs the control-mode stream that `tmux -CC' writes into an ordinary shell's output. Its DCS frame (ESC P 1000 p ... ST) can only be told apart from terminal output by the VT parser, including on the native PTY reader thread. GhostelHandler intercepts that frame: dcs_hook with no intermediates, params [1000] and final `p', then dcs_put and dcs_unhook. Body bytes are buffered and delivered once per input chunk and on unhook, on both inbound paths. Other DCS sequences still reach the standard handler. Elisp receives the frame through ghostel-control-mode-function, called in the terminal's buffer with `enter', `data' and a unibyte string, or `exit'. While it is nil the body is discarded. The native event pipe decodes as utf-8-unix instead of the process coding default, so the body bytes survive a non-UTF-8 locale. Refs #116
dakra
force-pushed
the
feat/control-mode-hook
branch
from
November 6, 2026 21:32
f45aaa4 to
67928cb
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.
Adds a hook that hands tmux control mode (
tmux -CC) output to another package, so tmux panes can be shown as Emacs buffers without tmux-specific code in ghostel. Refs #116.What's new
ghostel-control-mode-function: called in the terminal's buffer withenterwhen the control-mode DCS (ESC P 1000 p) opens,datawith the next part of its body as a unibyte string, andexitwhen it closes. Parts split anywhere, also inside a line or a character. While it is nil the body is discarded.How it works
GhostelHandlerintercepts it. Other DCS sequences still reach libghostty's handler.utf-8-unixinstead of the process coding default. With a non-UTF-8 locale the default corrupted UTF-8 event strings and the control-mode body.Notes
tmux -CCframe is passed to Elisp and dropped there; libghostty used to discard it natively. The terminal shows the same either way.Testing
make -j8 allpasses.test/ghostel-control-mode-test.elcovers a whole frame, split writes including a split character, every byte value, other DCS sequences, no function set, and a round trip through a real PTY on both backends (POSIX only).tmux -CCthrough a package that uses the hook (not published yet): takeover, UTF-8 pane output, resize, detach and reset, on bash, zsh and fish, each on the native and the Emacs PTY path.