Function: kkp--pre-delete-frame

kkp--pre-delete-frame is a natively compiled function defined in kkp.el.

Signature

(kkp--pre-delete-frame &optional FRAME &rest _)

Documentation

Disable KKP before FRAME's terminal loses its connection.

On client frames (e.g. emacsclient -nw), delete-terminal-functions can fire too late for send-string-to-terminal to reach the tty, leading to mangled keystrokes in the outer terminal. Running the teardown from a :before advice on delete-frame guarantees the CSI bytes land while the frame, terminal, and output pipe are all still live. Only acts when FRAME is the last frame on its terminal.

Source Code

;; Defined in /nix/store/0igl9q4k4n87vg4h2gnnrlha21kx9biv-emacs-packages-deps/share/emacs/site-lisp/elpa/kkp-20260706.858/kkp.el
(defun kkp--pre-delete-frame (&optional frame &rest _)
  "Disable KKP before FRAME's terminal loses its connection.
On client frames (e.g. `emacsclient -nw'), `delete-terminal-functions' can fire
too late for `send-string-to-terminal' to reach the tty, leading to mangled
keystrokes in the outer terminal. Running the teardown from a `:before' advice
on `delete-frame' guarantees the CSI bytes land while the frame, terminal, and
output pipe are all still live. Only acts when FRAME is the last frame on its
terminal."
  (let* ((frame (or frame (selected-frame)))
         (terminal (and (frame-live-p frame)
                        (frame-terminal frame))))
    (when (and (kkp--active-p terminal)
               (null (cdr (frames-on-display-list terminal))))
      (kkp--terminal-teardown terminal))))