minibuffer

How to select a word in a list with minibuffer completion in Emacs Lisp?

September 16, 2023
(defun select-word-with-minibuffer-completion ()
  "Select a word with minibuffer completion."
  (interactive)

  (let ((word (completing-read "Select word: " '("foo" "bar" "baz"))) ;; match not required
        ;; (word (completing-read "Select word: " '("foo" "bar" "baz") nil t)) ;; match required
        )
    (message "%s" word)))

(global-set-key (kbd "C-<f1>") #'select-word-with-minibuffer-completion)