Function: ghostel--spawn-via-emacs
ghostel--spawn-via-emacs is a natively compiled function defined in
ghostel.el.
Signature
(ghostel--spawn-via-emacs PROGRAM PROGRAM-ARGS &optional REMOTE-P)
Documentation
Spawn PROGRAM with PROGRAM-ARGS through Emacs process machinery.
PROGRAM is wrapped in /bin/sh -c so that stty (with
ghostel--default-stty) can configure the PTY line discipline before
PROGRAM reads its terminal attributes; the screen is then cleared to
hide the stty output and exec replaces the wrapper so only PROGRAM
remains. See ghostel--default-stty for the default flag set and
rationale. REMOTE-P is passed as :file-handler so TRAMP can run
remote commands, and selects an on-remote TERM probe preamble. The
returned process owns the PTY and receives ghostel--filter and
ghostel--sentinel.
Source Code
;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--spawn-via-emacs (program program-args &optional remote-p)
"Spawn PROGRAM with PROGRAM-ARGS through Emacs process machinery.
PROGRAM is wrapped in `/bin/sh -c' so that `stty' (with
`ghostel--default-stty') can configure the PTY line discipline before
PROGRAM reads its terminal attributes; the screen is then cleared to
hide the stty output and `exec' replaces the wrapper so only PROGRAM
remains. See `ghostel--default-stty' for the default flag set and
rationale. REMOTE-P is passed as `:file-handler' so TRAMP can run
remote commands, and selects an on-remote TERM probe preamble. The
returned process owns the PTY and receives `ghostel--filter' and
`ghostel--sentinel'."
(let* ((shell-command
(list "/bin/sh" "-c"
(concat
;; Remote spawns: pick TERM via an on-remote probe
(and remote-p (ghostel--remote-term-preamble))
"stty " ghostel--default-stty " 2>/dev/null; "
"printf '\033[H\033[2J'; exec "
(shell-quote-argument program)
(and program-args
(concat " "
(mapconcat #'shell-quote-argument
program-args " "))))))
(proc (make-process
:name "ghostel"
:buffer (current-buffer)
:command shell-command
:connection-type 'pty
:file-handler remote-p
:filter #'ghostel--filter
:sentinel #'ghostel--sentinel
:noquery t)))
(setq ghostel--pid (process-id proc))
;; Raw binary I/O — no encoding/decoding by Emacs
(set-process-coding-system proc 'binary 'binary)
;; Set the PTY's actual window size (ioctl TIOCSWINSZ) so that
;; the program's line editor (readline/ZLE) can render properly.
(set-process-window-size proc ghostel--term-rows ghostel--term-cols)
;; `ghostel--adjust-size' owns sizing; `ignore' (nil would fall
;; back to the default) opts out of core's all-frames
;; `window--adjust-process-windows'.
(process-put proc 'adjust-window-size-function #'ignore)
proc))