Function: eca-chat-fork

eca-chat-fork is an interactive and natively compiled function defined in eca-chat.el.

Signature

(eca-chat-fork)

Documentation

Fork the active chat from its latest message into a new chat.

The forked chat is announced by the server via chat/opened and gets its own buffer.

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat.el
;;;###autoload
(defun eca-chat-fork ()
  "Fork the active chat from its latest message into a new chat.
The forked chat is announced by the server via `chat/opened' and
gets its own buffer."
  (interactive)
  (let ((session (eca-session)))
    (eca-assert-session-running session)
    (eca-chat--with-current-buffer (eca-chat--get-active-buffer session)
      (let ((last-id nil)
            (last-pos -1))
        (dolist (ov (overlays-in (point-min) (point-max)))
          (when-let* ((id (overlay-get ov 'eca-chat--user-message-id))
                      (pos (overlay-start ov)))
            (when (> pos last-pos)
              (setq last-id id
                    last-pos pos))))
        (unless last-id
          (user-error "Nothing to fork in this chat"))
        (eca-chat--fork-from-flag session last-id)))))