Skip to content

Commit cf1d268

Browse files
committed
Add functions to expand or collapse all chat blocks
Fixes #109
1 parent acc209e commit cf1d268

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

eca-chat.el

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,6 +2326,30 @@ Just open if FORCE-OPEN? is non-nil."
23262326
(when-let ((ov (eca-chat--expandable-content-at-point)))
23272327
(eca-chat--expandable-content-toggle (overlay-get ov 'eca-chat--expandable-content-id) (when force-open? t) (not force-open?)))))
23282328

2329+
;;;###autoload
2330+
(defun eca-chat-expand-all-blocks ()
2331+
"Expand all expandable blocks in current chat."
2332+
(interactive)
2333+
(eca-assert-session-running (eca-session))
2334+
(eca-chat--with-current-buffer (eca-chat--get-last-buffer (eca-session))
2335+
(let ((expandable-overlays
2336+
(-filter (lambda (ov) (overlay-get ov 'eca-chat--expandable-content-id))
2337+
(overlays-in (point-min) (point-max)))))
2338+
(seq-doseq (ov expandable-overlays)
2339+
(eca-chat--expandable-content-toggle (overlay-get ov 'eca-chat--expandable-content-id) t nil)))))
2340+
2341+
;;;###autoload
2342+
(defun eca-chat-collapse-all-blocks ()
2343+
"Collapse all expandable blocks in current chat."
2344+
(interactive)
2345+
(eca-assert-session-running (eca-session))
2346+
(eca-chat--with-current-buffer (eca-chat--get-last-buffer (eca-session))
2347+
(let ((expandable-overlays
2348+
(-filter (lambda (ov) (overlay-get ov 'eca-chat--expandable-content-id))
2349+
(overlays-in (point-min) (point-max)))))
2350+
(seq-doseq (ov expandable-overlays)
2351+
(eca-chat--expandable-content-toggle (overlay-get ov 'eca-chat--expandable-content-id) t t)))))
2352+
23292353
;;;###autoload
23302354
(defun eca-chat-add-context-to-system-prompt ()
23312355
"Add context to system prompt in chat in a DWIM manner.

0 commit comments

Comments
 (0)