Function: eglot--async-request
eglot--async-request is a byte-compiled function defined in
eglot.el.gz.
Signature
(eglot--async-request SERVER METHOD PARAMS &key (SUCCESS-FN nil SUCCESS-FN-SUPPLIED-P) (ERROR-FN nil ERROR-FN-SUPPLIED-P) (TIMEOUT-FN nil TIMEOUT-FN-SUPPLIED-P) (TIMEOUT nil TIMEOUT-SUPPLIED-P) HINT)
Documentation
Like jsonrpc-async-request, but for Eglot LSP requests.
SUCCESS-FN, ERROR-FN and TIMEOUT-FN run in buffer of call site.
HINT argument is a symbol passed as DEFERRED to jsonrpc-async-request
and also used as a hint of the request cancellation mechanism (see
eglot-advertise-cancellation).
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/eglot.el.gz
(cl-defun eglot--async-request (server
method
params
&key
(success-fn nil success-fn-supplied-p)
(error-fn nil error-fn-supplied-p)
(timeout-fn nil timeout-fn-supplied-p)
(timeout nil timeout-supplied-p)
hint
&aux moreargs id
(buf (current-buffer))
(inflight eglot--inflight-async-requests))
"Like `jsonrpc-async-request', but for Eglot LSP requests.
SUCCESS-FN, ERROR-FN and TIMEOUT-FN run in buffer of call site.
HINT argument is a symbol passed as DEFERRED to `jsonrpc-async-request'
and also used as a hint of the request cancellation mechanism (see
`eglot-advertise-cancellation')."
(cl-labels
((wrapfn (fn)
(lambda (&rest args)
(eglot--when-live-buffer buf
(cond (eglot-advertise-cancellation
(when-let* ((tail (and fn (plist-member inflight hint))))
(when (memq id (cadr tail))
(apply fn args))
(setf (cadr tail) (delete id (cadr tail)))))
(t
(apply fn args)))))))
(eglot--cancel-inflight-async-requests (list hint))
(when timeout-supplied-p
(setq moreargs (nconc `(:timeout ,timeout) moreargs)))
(when hint
(setq moreargs (nconc `(:deferred ,hint) moreargs)))
(setq id
(car (apply #'jsonrpc-async-request
server method params
:success-fn (wrapfn success-fn)
:error-fn (wrapfn error-fn)
:timeout-fn (wrapfn timeout-fn)
moreargs)))
(when (and hint eglot-advertise-cancellation)
(push id (cl-getf inflight hint)))
id))