I can read a string in the minibuffer, with completion, using completing-read
:
(completing-read "Chose one: " '("Han Solo" "Chewbacca" "Lando Calrissian"))
I would like to use my own completion function, which searches some of my files, instead of a list. The Programmed Completion page of the manual details just how to do that, but does not give any example.
The best I could achieve is this :
(defun completion-function (input-string predicate flag)
(if flag
'("Chewbacca" "C3-PO" "Calrissian")
"C3-PO"))
(completing-read "Chose one: " 'completion-function)
However, this does not behave at all like I would :
- it suggests only one choice on the first
TAB
press (I would like all of them to be shown, as what shows a secondTAB
push) - it does not filter the results on the input string (do I need to implement that as well?)
Can someone give a better, more complete example?