Function: gptel--display-reasoning-stream
gptel--display-reasoning-stream is a natively compiled function
defined in gptel.el.
Signature
(gptel--display-reasoning-stream TEXT INFO)
Documentation
Show reasoning TEXT in an appropriate location.
INFO is the request INFO, see gptel--url-get-response. This is
for streaming responses only.
Source Code
;; Defined in /nix/store/q3r7g81pvghw7a523kjk2k2zih3pfk8z-emacs-packages-deps/share/emacs/site-lisp/elpa/gptel-20261002.545/gptel.el
;;; Reasoning content UI
(defun gptel--display-reasoning-stream (text info)
"Show reasoning TEXT in an appropriate location.
INFO is the request INFO, see `gptel--url-get-response'. This is
for streaming responses only."
(when-let* ((include (plist-get info :include-reasoning)))
(if (stringp include)
(unless (eq text t)
(with-current-buffer (get-buffer-create include)
(save-excursion (goto-char (point-max))
(insert text))))
(let* ((reasoning-marker (plist-get info :reasoning-marker))
(tracking-marker (plist-get info :tracking-marker))
(start-marker (plist-get info :position)))
(with-current-buffer (marker-buffer start-marker)
(if (eq text t) ;end of stream
(progn
(gptel-curl--stream-insert-response
(concat (if (derived-mode-p 'org-mode)
"\n#+end_reasoning"
;; TODO(reasoning) remove properties and strip instead
(propertize "\n```" 'gptel 'ignore
'keymap gptel--markdown-block-map))
gptel-response-separator)
info t)
(ignore-errors ;fold block
(save-excursion
(goto-char tracking-marker)
(if (derived-mode-p 'org-mode)
(progn (search-backward "#+end_reasoning" start-marker t)
(when (looking-at "^#\\+end_reasoning")
(org-cycle)))
(when (re-search-backward "^```" start-marker t)
(gptel-markdown-cycle-block))))))
(unless (and reasoning-marker tracking-marker
(= reasoning-marker tracking-marker))
(let ((separator ;Separate from response prefix if required
(and (not tracking-marker) gptel-mode
(not (string-suffix-p
"\n" (gptel-response-prefix-string)))
"\n")))
(gptel-curl--stream-insert-response
(concat separator
(if (derived-mode-p 'org-mode)
"#+begin_reasoning\n"
;; TODO(reasoning) remove properties and strip instead
(propertize "``` reasoning\n" 'gptel 'ignore
'keymap gptel--markdown-block-map)))
info t)))
(if (eq include 'ignore)
(progn
(add-text-properties
0 (length text) '(gptel ignore front-sticky (gptel)) text)
(gptel-curl--stream-insert-response text info t))
(gptel-curl--stream-insert-response text info)))
(setq tracking-marker (plist-get info :tracking-marker))
(if reasoning-marker
(move-marker reasoning-marker tracking-marker)
(plist-put info :reasoning-marker
(copy-marker tracking-marker nil))))))))