Function: eca-chat--buffer-completion-items

eca-chat--buffer-completion-items is a natively compiled function defined in eca-chat-context.el.

Signature

(eca-chat--buffer-completion-items)

Documentation

Return completion items for eligible buffers not already added.

Items are recomputed only when the buffer list changes; the already-added filter always runs against the live context list.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat-context.el
(defun eca-chat--buffer-completion-items ()
  "Return completion items for eligible buffers not already added.
Items are recomputed only when the buffer list changes; the
already-added filter always runs against the live context list."
  (let ((tick eca-chat--buffer-list-tick))
    (unless (and eca-chat--buffer-completion-items-cache
                 (eq (car eca-chat--buffer-completion-items-cache) tick))
      (setq eca-chat--buffer-completion-items-cache
            (cons tick
                  (-map (lambda (context)
                          (eca-chat--context-to-completion nil nil context))
                        (eca-chat--all-buffer-contexts)))))
    (let ((items (cdr eca-chat--buffer-completion-items-cache))
          (added-text-contexts (-filter (lambda (context)
                                          (equal "text" (plist-get context :type)))
                                        eca-chat--context)))
      (if added-text-contexts
          (-remove (lambda (item)
                     (member (get-text-property 0 'eca-chat-completion-item item)
                             added-text-contexts))
                   items)
        items))))