Because Emacs built-ins (and of course VOMPECCC) are so strong, they can be used to support ISR use-cases. Everything we demonstrated in prior posts is relevant here, most of all the consult package.
The key enabler of ISR is the fact that completing-read's candidate collection can be a function: Emacs passes your input to a function, and that function returns the inferred suggestions. That's powerful in the abstract, and concretely it enables our semantic retreival and generative synthesis use cases.
Because Emacs clearly already supports this abstraction, everything downstream of the source (everything we've demonstrated in this series up until this point) is re-usable. In line with a common theme in Emacs, our precious, hard-earned muscle memory transfers perfectly from ICR to ISR.
consult is especially enabling of ISR because it is functionally optimized to supply candidates from a backend rather than a materialized list. We've already shown how we can hand consult a function (that hits an API) and consult supplies asynchronous fetching, keystroke debouncing, live preview, grouping, narrowing, and (optionally) Embark actions.
There are already public examples of ISR in action:
In the generative syntehsis case, an integration between 2 packages provides a beautful example. Armin's consult-omni ships with a consult interface to karthink's gptel in gptel source. This integration with gptel's suggesting backend is defined the same way as it would be with a completing backend, whether that's ripgrep or a search API. Another generative synthesis example would be completing for the possible LLM expansions of inline code or prose (think GitHub Copilot's Emacs extensions).
In the semantic retreival case, I implemented an example borrowing from John Kitchin's org-db-v3 for the embeddings.
The point of this section is that the existing ICR machinery (especially consult in this case) can be re-used for ISR. Below you can see how I reuse it. Pay special attention to consult--read and consult--dynamic-collection in my chiply-isr-semantic-read command:
(defun chiply-isr--collection (input) (mapcar (lambda (r) (cons (format "%-22s %s" (file-name-nondirectory (alist-get 'filename r)) (alist-get 'chunk_text r)) (alist-get 'filename r))) (chiply-isr--search input))) ; embedding search over my sample corpus ;; consult drives that function as a live, per-keystroke source. (defun chiply-isr-semantic-read () (interactive) (find-file (consult--read (consult--dynamic-collection #'chiply-isr--collection :min-input 3 :debounce 0.3) :prompt "Suggesting read (by meaning): " :lookup #'consult--lookup-cdr :require-match t :sort nil)))
The suggesting --collection function is the only thing that differs from a completing character-matching source. The full chiply-isr module lives in my Emacs config, but I built it for this demo, so I don't recommend you use it.
> # [Beyond ICR: Incremental 'Suggesting' Read in Emacs](https://www.chiply.dev/post-incremental-suggesting-read)