Function: eca-chat--raw-prompt-contexts

eca-chat--raw-prompt-contexts is a natively compiled function defined in eca-chat-context.el.

Signature

(eca-chat--raw-prompt-contexts)

Documentation

Return contexts for raw @path tokens typed in the prompt field.

Only workspace-relative tokens are considered: absolute, ~ and dot prefixed mentions are already parsed by the server from the message text, and tokens already linked to a context chip are skipped.

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--raw-prompt-contexts ()
  "Return contexts for raw @path tokens typed in the prompt field.
Only workspace-relative tokens are considered: absolute, ~ and
dot prefixed mentions are already parsed by the server from the
message text, and tokens already linked to a context chip are
skipped."
  (when-let ((prompt-start (eca-chat--prompt-field-start-point)))
    (let ((contexts '())
          (regexp (concat "\\(?:^\\|[^[:alnum:]]\\)"
                          (regexp-quote eca-chat-context-prefix)
                          "\\([^[:space:]]+\\)")))
      (save-excursion
        (goto-char prompt-start)
        (while (re-search-forward regexp nil t)
          (let ((token (match-string-no-properties 1)))
            (unless (or (get-text-property (match-beginning 1) 'eca-chat-context-item)
                        (file-name-absolute-p token)
                        (string-prefix-p "." token))
              (when-let ((path (eca-chat--resolve-path-token token)))
                (let ((context (list :type (if (f-dir? path) "directory" "file")
                                     :path path)))
                  (unless (member context contexts)
                    (push context contexts))))))))
      (nreverse contexts))))