Function: kkp--query-terminal-async
kkp--query-terminal-async is a natively compiled function defined in
kkp.el.
Signature
(kkp--query-terminal-async QUERY HANDLERS TERMINAL)
Documentation
Send QUERY string to TERMINAL and register HANDLERS for a response.
HANDLERS is an alist with elements of the form (STRING . FUNCTION).
We run the first FUNCTION whose STRING matches the input events.
This function code is copied from xterm--query.
Source Code
;; Defined in /nix/store/0igl9q4k4n87vg4h2gnnrlha21kx9biv-emacs-packages-deps/share/emacs/site-lisp/elpa/kkp-20260706.858/kkp.el
(defun kkp--query-terminal-async (query handlers terminal)
"Send QUERY string to TERMINAL and register HANDLERS for a response.
HANDLERS is an alist with elements of the form (STRING . FUNCTION).
We run the first FUNCTION whose STRING matches the input events.
This function code is copied from `xterm--query'."
(with-selected-frame (car (frames-on-display-list terminal))
(let ((register
(lambda (handlers)
(dolist (handler handlers)
(define-key input-decode-map (car handler)
(lambda (&optional _prompt)
;; Unregister the handler, since we don't expect
;; further answers.
(dolist (handler handlers)
(define-key input-decode-map (car handler) nil))
(funcall (cdr handler))
[]))))))
(funcall register handlers)
;; A `read-key-sequence' already in progress snapshotted `input-decode-map'
;; before we registered our handler, so it would read the reply with the
;; stale map and let `CSI ?' leak into a buffer as keys (issue #21/#32).
;; Injecting a `switch-frame' event forces that read to restart
;; (`replay_entire_sequence' in the C reader), re-reading `input-decode-map'
;; -- now with our handler -- before it reads the reply.
(push (list 'switch-frame (selected-frame)) unread-command-events)
(kkp--verbose "query (async): sending CSI %S to terminal" query)
(send-string-to-terminal (kkp--csi-escape query) terminal)
(kkp--flush-standard-output))))