Skip to content

Echo typed input in interactive ghostel-compile runs - #591

Merged
dakra merged 1 commit into
mainfrom
fix/compile-interactive-echo
Aug 1, 2026
Merged

dakra merged 1 commit into
mainfrom
fix/compile-interactive-echo

Conversation

@dakra

@dakra dakra commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Problem

Interactive input worked in ghostel-compile buffers, but typed characters never appeared: the PTY was always spawned with -echo, and the C-c C-j toggle (ghostel-compile-switch-to-interactive) only swapped keymaps without touching termios. Typing at a read-style prompt was invisible.

Fix

  • Interactive spawns (C-u M-x ghostel-compile) configure the PTY with ghostel--default-stty (echo on), so input is visible from the first keystroke.
  • The mid-run toggle flips ECHO out-of-band on the live PTY via stty against process-tty-name (Emacs has no termios API). Local runs only — for TRAMP the process tty is the local connection pty, not the remote pty the command reads from.
  • The enable is skipped when:
    • the tty is in non-canonical mode — a full-screen program (htop, less) owns the display and echoed keystrokes would splatter over it;
    • the cursor row matches ghostel-password-prompt-regex — the pty state cannot distinguish a program-set -echo (ssh, sudo, read -s) from the compile spawn default, but the prompt text can. Typed secrets must not render into the buffer.
  • Compilation-style runs keep -echo: the buffer is a pure log, and echoed terminal query replies (DA1, DSR, OSC color reports) would render as escape-sequence garbage.

Known residual: a password prompt whose text doesn't match the regex and is already on screen at toggle time gets echoed — the same residual every comint-based mode has.

Tests

Four new native tests: interactive spawn echoes typed input before the program responds (the script blocks in read, so the text can only come from tty echo), the toggle enables echo mid-run, the raw-mode guard leaves a TUI's terminal alone, and a Password: prompt keeps ECHO off across the toggle. Test markers are assembled from printf fragments so the command line echoed in the buffer header can't satisfy the wait predicates.

Verified live in a TTY Emacs: typed input echoes at the prompt (including DEL erase), and typing at a password prompt after C-c C-j renders nothing while still reaching the program.

Interactive input worked in compile buffers but typed characters
never appeared: the PTY was always spawned with -echo, and the
C-c C-j toggle only swapped keymaps without touching termios.

Spawn interactive runs with echo on, and flip ECHO out-of-band on
the live PTY when toggling mid-run.  The toggle leaves echo off when
the tty is in non-canonical mode (a full-screen program owns the
display) or the cursor row matches ghostel-password-prompt-regex
(the pty state cannot distinguish a program-set -echo from the
spawn default, but the prompt text can).  Compilation-style runs
keep -echo so terminal query replies don't render as garbage in
the log.
@dakra
dakra merged commit f3da49c into main Aug 1, 2026
29 checks passed
@dakra
dakra deleted the fix/compile-interactive-echo branch August 1, 2026 15:12

This branch was previously deployed

1 inactive deployment
github-pages — f3da49c5 Deployed Aug 1, 2026 by dakra via deploy #140
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.

1 participant