Function: gptel-end-of-response
gptel-end-of-response is an interactive and natively compiled function
defined in gptel.el.
Signature
(gptel-end-of-response &optional BEG END ARG)
Documentation
Move point to end of LLM response.
With BEG, start search from BEG when ARG is negative. With END, start search from END when ARG is positive. Otherwise move ARG times, defaulting to 1.
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.el
(defun gptel-end-of-response (&optional beg end arg)
"Move point to end of LLM response.
With BEG, start search from BEG when ARG is negative.
With END, start search from END when ARG is positive.
Otherwise move ARG times, defaulting to 1."
(interactive (list nil nil
(prefix-numeric-value current-prefix-arg)))
(unless arg (setq arg 1))
(let* ((search (if (> arg 0)
#'text-property-search-forward
#'text-property-search-backward))
(goto-prefix-end
(lambda () (when-let* ((prefix (gptel-prompt-prefix-string))
((not (string-empty-p prefix)))
((looking-at (concat "\n\\{1,2\\}"
(regexp-quote prefix) "?"))))
(goto-char (match-end 0)))))
(goto-prefix-beg
(lambda () (when-let* ((prefix (gptel-response-prefix-string))
((not (string-empty-p prefix)))
((looking-back (concat (regexp-quote prefix) "?")
(point-min))))
(goto-char (match-beginning 0))))))
(cond
((and end (> arg 0)) (goto-char end) (cl-decf arg) (funcall goto-prefix-end))
((and beg (< arg 0)) (goto-char beg) (cl-incf arg) (funcall goto-prefix-beg)))
(dotimes (_ (abs arg))
(funcall search 'gptel 'response t)
(if (> arg 0)
(funcall goto-prefix-end)
(funcall goto-prefix-beg)))))