Function: ghostel-line-mode-send

ghostel-line-mode-send is an interactive and natively compiled function defined in ghostel-line-mode.el.

Signature

(ghostel-line-mode-send)

Documentation

Send the current in-progress input line to the shell.

Deletes the local input, writes it to the PTY, then submits Return.

The encoded Return matters for TUI apps that distinguish a literal newline (Shift-Enter) from submit (e.g. claude-code, pi). Shells accept the same CR as accept-line.

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel-line-mode.el
(defun ghostel-line-mode-send ()
  "Send the current in-progress input line to the shell.
Deletes the local input, writes it to the PTY, then submits Return.

The encoded Return matters for TUI apps that distinguish a literal
newline (Shift-Enter) from submit (e.g. claude-code, pi).  Shells
accept the same CR as `accept-line'."
  (interactive)
  (unless (eq ghostel--input-mode 'line)
    (user-error "Not in line mode"))
  (let ((input (ghostel--line-mode-input-text)))
    (ghostel--line-mode-delete-input)
    (when (and (> (length input) 0)
               (or (null ghostel--line-mode-history)
                   (not (string= input (car ghostel--line-mode-history)))))
      (push input ghostel--line-mode-history)
      (when (> (length ghostel--line-mode-history)
               ghostel-line-mode-history-size)
        (setcdr (nthcdr (1- ghostel-line-mode-history-size)
                        ghostel--line-mode-history)
                nil)))
    (setq ghostel--line-mode-history-index nil)
    ;; Erase any prefix the shell already had in its readline buffer
    ;; (adopted on line-mode entry) before sending — otherwise the
    ;; shell would concatenate ours after that prefix and echo a
    ;; duplicated line.
    (ghostel--line-mode-clear-shell-readline)
    (when (> (length input) 0)
      (ghostel--write-pty ghostel--term input))
    (ghostel--send-encoded "return" "")
    ;; Drop this line's undo history so the next line starts clean.
    (setq buffer-undo-list nil)))