Function: eca-chat--sibling-chat-buffer

eca-chat--sibling-chat-buffer is a natively compiled function defined in eca-chat.el.

Signature

(eca-chat--sibling-chat-buffer SESSION BUFFER)

Documentation

Return the chat buffer to focus when BUFFER is closed in SESSION.

Prefers the previous chat (the tab to the left of BUFFER); when BUFFER is the leftmost chat, returns the next one (to the right). When BUFFER is not registered, returns any other live chat. Returns nil when SESSION has no other live chat.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat.el
(defun eca-chat--sibling-chat-buffer (session buffer)
  "Return the chat buffer to focus when BUFFER is closed in SESSION.
Prefers the previous chat (the tab to the left of BUFFER); when
BUFFER is the leftmost chat, returns the next one (to the right).
When BUFFER is not registered, returns any other live chat.
Returns nil when SESSION has no other live chat."
  (let* ((chats (-filter #'buffer-live-p
                         (eca-chat--session-chats-oldest-first session)))
         (pos (cl-position buffer chats)))
    (cond
     ((null pos) (-first (lambda (b) (not (eq b buffer))) chats))
     ((> pos 0) (nth (1- pos) chats))
     ((< (1+ pos) (length chats)) (nth (1+ pos) chats))
     (t nil))))