Live preview
Implementing live preview requires the definition of a state or preview function as defined by ‘consult--with-preview’. The preview function receives the candidate and some action to perform (e.g., ‘'preview’). In its simplest form supporting live preview, it looks something like this:
emacs-lisp
(defun testibus--preview (action cand)
(pcase action
('preview
(with-current-buffer-window " *testibus*" 'action nil
(erase-buffer)
(insert (format "input: %s\n" cand))))))See the docstring of ‘consult--with-preview’ for the lifecycle of the action argument. Once defined, we can use this preview function in ‘consult--read’: