Function: eca-chat--normalize-prompt
eca-chat--normalize-prompt is a natively compiled function defined in
eca-chat.el.
Signature
(eca-chat--normalize-prompt PROMPT)
Documentation
Normalize PROMPT before sending to server.
- If any expandable (@context or #file) is found, expand it.
- Removes # from #files.
Source Code
;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat.el
(defun eca-chat--normalize-prompt (prompt)
"Normalize PROMPT before sending to server.
- If any expandable (@context or #file) is found, expand it.
- Removes # from #files."
(let ((result "")
(pos 0))
(while (< pos (length prompt))
(let* ((next-change (next-single-property-change pos 'eca-chat-expanded-item-str prompt (length prompt)))
(expanded-str (get-text-property pos 'eca-chat-expanded-item-str prompt))
(item-type (get-text-property pos 'eca-chat-item-type prompt)))
(if expanded-str
(setq result (concat result
(cond
((eq item-type 'filepath)
(eca--path-local-to-remote (substring expanded-str 1)))
;; Only path-based contexts go through path
;; translation; labels like buffer names
;; must be kept as-is.
((and (eq item-type 'context)
(let ((ctx (get-text-property pos 'eca-chat-context-item prompt)))
(or (null ctx) (plist-get ctx :path))))
(concat "@" (eca--path-local-to-remote
(substring expanded-str 1))))
(t expanded-str))))
(setq result (concat result (substring prompt pos next-change))))
(setq pos next-change)))
result))