Function: eca--switch-to-chat-candidate

eca--switch-to-chat-candidate is a natively compiled function defined in eca.el.

Signature

(eca--switch-to-chat-candidate PROMPT CANDIDATES EMPTY-MESSAGE)

Documentation

Switch to a chat selected from CANDIDATES using PROMPT.

Signal EMPTY-MESSAGE as a user-error when CANDIDATES is nil.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca.el
(defun eca--switch-to-chat-candidate (prompt candidates empty-message)
  "Switch to a chat selected from CANDIDATES using PROMPT.

Signal EMPTY-MESSAGE as a `user-error' when CANDIDATES is nil."
  (unless candidates
    (user-error empty-message))
  (let* ((info (if (= 1 (length candidates))
                   (cdar candidates)
                 (let* ((table (eca--chat-buffer-completion-table candidates))
                        (choice (completing-read prompt table nil t)))
                   (cdr (assoc choice candidates)))))
         (buffer (plist-get info :buffer))
         (session (plist-get info :session)))
    (eca-chat--switch-to-buffer buffer session)))