Function: eca-chat-inline--select-chat

eca-chat-inline--select-chat is a natively compiled function defined in eca-chat-inline.el.

Signature

(eca-chat-inline--select-chat SESSION)

Documentation

Ask which chat of SESSION to attach the inline prompt to.

Returns a chat buffer, or the symbol new for a fresh chat. When the session has no chats yet, returns new directly.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat-inline.el
(defun eca-chat-inline--select-chat (session)
  "Ask which chat of SESSION to attach the inline prompt to.
Returns a chat buffer, or the symbol `new' for a fresh chat.
When the session has no chats yet, returns `new' directly."
  (let* ((buf-by-label (make-hash-table :test 'equal))
         (labels
          (-keep (lambda (buffer)
                   (when (and (buffer-live-p buffer)
                              (not (buffer-local-value 'eca-chat--closed
                                                       buffer)))
                     (with-current-buffer buffer
                       (let* ((label (concat (eca-chat--chat-status-prefix)
                                             (eca-chat-title)))
                              (label (if (gethash label buf-by-label)
                                         (concat label " (" eca-chat--id ")")
                                       label)))
                         (puthash label buffer buf-by-label)
                         label))))
                 (eca-vals (eca--session-chats session)))))
    (if (null labels)
        'new
      (let ((choice (completing-read "Select a chat for this prompt: "
                                     (append labels
                                             (list eca-chat-new-chat-label))
                                     nil t)))
        (or (gethash choice buf-by-label) 'new)))))