Function: eca-chat--add-expandable-content
eca-chat--add-expandable-content is a natively compiled function
defined in eca-chat-expandable.el.
Signature
(eca-chat--add-expandable-content ID LABEL CONTENT &optional PARENT-ID AT-POINT)
Documentation
Add LABEL to the chat current position for ID as a interactive text.
When expanded, shows CONTENT. Applies ICON-FACE to open/close icons. If PARENT-ID is provided, adds as a nested block under that parent. If AT-POINT is provided, inserts at that buffer position instead of the default content insertion point.
Source Code
;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat-expandable.el
(defun eca-chat--add-expandable-content (id label content &optional parent-id at-point)
"Add LABEL to the chat current position for ID as a interactive text.
When expanded, shows CONTENT.
Applies ICON-FACE to open/close icons.
If PARENT-ID is provided, adds as a nested block under that parent.
If AT-POINT is provided, inserts at that buffer position instead of
the default content insertion point."
(if parent-id
(when-let* ((parent-ov (eca-chat--get-expandable-content parent-id)))
(let* ((segments (overlay-get parent-ov 'eca-chat--expandable-content-segments))
(existing-spec (-first (lambda (s) (and (eq 'child (plist-get s :type))
(string= id (plist-get s :id))))
segments)))
(if existing-spec
;; Child spec already exists (e.g. parent was collapsed destroying
;; the overlay but keeping the spec); delegate to update to avoid
;; duplicating the entry.
(eca-chat--update-expandable-content id label content nil parent-id)
(let* ((icon-face (get-text-property 0 'font-lock-face label))
(child-spec (list :type 'child :id id :label label :content content :icon-face icon-face))
;; Capture any unsegmented text that was appended to content
;; since the last segment, and add it as a text segment first
(ov-content (overlay-get parent-ov 'eca-chat--expandable-content-ov-content))
(full-content (overlay-get ov-content 'eca-chat--expandable-content-content))
(segmented-text (eca-chat--segments-total-text segments))
(unsegmented-text (when (> (length full-content) (length segmented-text))
(substring full-content (length segmented-text))))
(new-segments (append segments
(when unsegmented-text
(list (list :type 'text :content unsegmented-text)))
(list child-spec))))
(overlay-put parent-ov 'eca-chat--expandable-content-segments new-segments)
(when (overlay-get parent-ov 'eca-chat--expandable-content-toggle)
(eca-chat--render-nested-block parent-ov child-spec))))))
(save-excursion
(let* ((start-point (or at-point (eca-chat--content-insertion-point)))
(icon-face (get-text-property 0 'font-lock-face label))
(icons (eca-chat--make-expandable-icons icon-face)))
(goto-char start-point)
(unless (bolp) (eca-chat--insert "\n"))
(eca-chat--insert-expandable-block id label content
(car icons) (cdr icons)
eca-chat--expandable-content-base-indent)))))