Function: gptel-abort
gptel-abort is an interactive and natively compiled function defined
in gptel-request.el.
Signature
(gptel-abort BUF)
Documentation
Stop any active gptel process associated with buffer BUF.
BUF defaults to the current buffer.
Key Bindings
This command is not in any keymaps.
Source Code
;; Defined in /nix/store/q3r7g81pvghw7a523kjk2k2zih3pfk8z-emacs-packages-deps/share/emacs/site-lisp/elpa/gptel-20261002.545/gptel-request.el
(defun gptel-abort (buf)
"Stop any active gptel process associated with buffer BUF.
BUF defaults to the current buffer."
(interactive (list (current-buffer)))
(when-let* ((proc-attrs
(cl-find-if
(lambda (entry)
;; each entry has the form (PROC . (FSM ABORT-FN))
(eq (thread-first (cadr entry) ; FSM
(gptel-fsm-info)
(plist-get :buffer))
buf))
gptel--request-alist))
(proc (car proc-attrs))
(fsm (cadr proc-attrs))
(info (gptel-fsm-info fsm))
(abort-fn (cddr proc-attrs)))
;; Run :callback with abort signal
(with-demoted-errors "Callback error: %S"
(and-let* ((cb (plist-get info :callback))
((functionp cb)))
(funcall cb 'abort info)))
(funcall abort-fn)
(setf (alist-get proc gptel--request-alist nil 'remove) nil)
(gptel--fsm-transition fsm 'ABRT)
(message "Stopped gptel request in buffer %S" (buffer-name buf))))