Thanks a lot Drew. Exactly what I was looking for!
1. Use lax completion (`completing-read' with nil as the REQUIRE-MATCH argument.> I'm looking for a function that is a mix of read-string
> and completing-read. I want completion and I want to be
> able to input anything, such as spaces. Is there any such
> function or do I have to write one myself?
2. Use a keymap that has SPC bound to `self-insert-command'.
You can do #2 by binding `minibuffer-local-completion-map' (so it is restored
afterward), and doing (define-key minibuffer-local-completion-map " "
'self-insert-command).
IOW, something like this:
(defun my-read-string-completing (prompt collection
&optional predicate
init hist def i-i-m)
"..."
(let ((minibuffer-local-completion-map
minibuffer-local-completion-map))
(define-key minibuffer-local-completion-map
" " 'self-insert-command)
(completing-read prompt collection
predicate nil init def hist i-i-m)))
You would call the function with a COLLECTION argument that is a list of strings
(Emacs 22+) or a list of singleton string lists (all versions). E.g.:
(my-read-string-completing "String: "
'(("alpha") ("beta") ("gamma")))
(If you use Icicles, `icicle-read-string-completing' does this.)