Function: ghostel-xterm-paste

ghostel-xterm-paste is an interactive and natively compiled function defined in ghostel.el.

Signature

(ghostel-xterm-paste EVENT)

Documentation

Forward an xterm-paste EVENT to the terminal via bracketed paste.

The default xterm-paste command inserts into the current buffer, which is wrong for ghostel: the terminal renderer owns the buffer and wipes the inserted text on the next redraw, so the shell never sees it. This handler extracts the pasted text from EVENT and pushes it to the subprocess through ghostel--paste-text instead. When xterm-store-paste-on-kill-ring is non-nil (the stock default), the text is also pushed onto the kill ring for parity with xterm-paste.

Key Bindings

ghostel-mode-map <xterm-paste>

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel-xterm-paste (event)
  "Forward an xterm-paste EVENT to the terminal via bracketed paste.
The default `xterm-paste' command inserts into the current buffer,
which is wrong for ghostel: the terminal renderer owns the buffer
and wipes the inserted text on the next redraw, so the shell
never sees it.  This handler extracts the pasted text from EVENT
and pushes it to the subprocess through `ghostel--paste-text'
instead.  When `xterm-store-paste-on-kill-ring' is non-nil (the
stock default), the text is also pushed onto the kill ring for
parity with `xterm-paste'."
  (interactive "e")
  (unless (eq (car-safe event) 'xterm-paste)
    (error "This command must be bound to an xterm-paste event"))
  (when-let* ((text (nth 1 event)))
    (ghostel--on-user-input)
    (when (bound-and-true-p xterm-store-paste-on-kill-ring)
      (kill-new text))
    (ghostel--paste-text text)))