Function: eca-chat--materialize-context

eca-chat--materialize-context is a natively compiled function defined in eca-chat-context.el.

Signature

(eca-chat--materialize-context CONTEXT)

Documentation

Return CONTEXT filled with content needed right before sending.

Text contexts get fresh buffer content by label, sliced to their lines range when present (the range is resolved client-side and not sent); contexts of killed buffers return nil so callers can drop them. Cursor contexts with no tracked position return nil too.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat-context.el
(defun eca-chat--materialize-context (context)
  "Return CONTEXT filled with content needed right before sending.
Text contexts get fresh buffer content by label, sliced to their
lines range when present (the range is resolved client-side and
not sent); contexts of killed buffers return nil so callers can
drop them.  Cursor contexts with no tracked position return nil
too."
  (pcase (plist-get context :type)
    ("text" (let* ((label (plist-get context :label))
                   (buffer (get-buffer label)))
              (if (buffer-live-p buffer)
                  (list :type "text"
                        :label label
                        :content (eca-chat--buffer-context-content
                                  buffer (plist-get context :linesRange)))
                (progn (eca-info "Skipping killed buffer context: %s" label)
                       nil))))
    ("cursor" (when (plist-get context :position)
                context))
    (_ context)))