Function: eca-chat--insert-expandable-block
eca-chat--insert-expandable-block is a natively compiled function
defined in eca-chat-expandable.el.
Signature
(eca-chat--insert-expandable-block ID LABEL CONTENT OPEN-ICON CLOSE-ICON CONTENT-INDENT &optional NESTED-PROPS)
Documentation
Insert an expandable block with ID, LABEL, CONTENT, icons and indent.
OPEN-ICON and CLOSE-ICON are the toggle icons. CONTENT-INDENT is the `line-prefix` for content. NESTED-PROPS is a plist with :parent-id and :label-indent for nested blocks.
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--insert-expandable-block (id label content open-icon close-icon content-indent &optional nested-props)
"Insert an expandable block with ID, LABEL, CONTENT, icons and indent.
OPEN-ICON and CLOSE-ICON are the toggle icons.
CONTENT-INDENT is the `line-prefix` for content.
NESTED-PROPS is a plist with :parent-id and :label-indent for nested blocks."
(let ((ov-label (make-overlay (point) (point) (current-buffer)))
(label-indent (plist-get nested-props :label-indent)))
(overlay-put ov-label 'eca-chat--expandable-content-id id)
(puthash id ov-label eca-chat-expandable--id->ov)
(overlay-put ov-label 'eca-chat--expandable-content-open-icon open-icon)
(overlay-put ov-label 'eca-chat--expandable-content-close-icon close-icon)
(overlay-put ov-label 'eca-chat--expandable-content-toggle nil)
(when nested-props
(overlay-put ov-label 'eca-chat--expandable-content-nested t)
(overlay-put ov-label 'eca-chat--expandable-content-parent-id (plist-get nested-props :parent-id)))
(unless nested-props
(overlay-put ov-label 'eca-chat--expandable-content-segments nil))
(eca-chat--insert (propertize (eca-chat--propertize-only-first-word label
'line-prefix (cond
((not (string-empty-p content)) open-icon)
(label-indent (concat label-indent
(make-string (length eca-chat-expandable-block-open-symbol) ?\s)))))
'keymap (let ((km (make-sparse-keymap)))
(define-key km (kbd "<mouse-1>") (lambda () (interactive) (eca-chat--expandable-content-toggle id)))
(define-key km (kbd "TAB") (lambda () (interactive) (eca-chat--expandable-content-toggle id)))
(define-key km (kbd "RET") (lambda () (interactive) (eca-chat--expandable-content-toggle id)))
km)
'help-echo "mouse-1 / tab / RET: expand/collapse"))
(eca-chat--insert "\n")
(let* ((start-point (point))
(_ (eca-chat--insert "\n"))
(ov-content (make-overlay start-point start-point (current-buffer) nil t))
(nested? (plist-get nested-props :parent-id)))
(overlay-put ov-content 'eca-chat--expandable-content-content (propertize content 'line-prefix content-indent))
(overlay-put ov-content 'eca-chat--expandable-block-nested nested?)
(overlay-put ov-content 'priority (if nested? 1 0))
(overlay-put ov-label 'eca-chat--expandable-content-ov-content ov-content))))