I'm trying to write a function for complete in minibuffer with history.
(Terminal equivalent of
"\e[5~": history-search-backward in
With the below function I can get the last command that start with the prefix in the minibuffer. I want to validate this candidate or search the next candidate.
(defun history-search-forward () (interactive) (setq prefix (minibuffer-contents)) (loop for elt in extended-command-history do ;; history starts with word-at-point (and (string-match (rx-to-string `(: bos ,prefix) t) elt) (progn (delete-region (point) (line-beginning-position)) (insert elt) ;; here a want to launch the command if <Enter> ;; or continue looping if <prior> (return))))) (define-key minibuffer-local-completion-map (kbd "<prior>") 'history-search-forward)
How can I wait for user input at that point in the loop?