[net.emacs] Minibuffer completion update for

earle@smeagol.UUCP (Greg Earle) (12/18/85)

In article <5428@mit-eddie.UUCP>, Bruce Israel <israel@tove.umd.edu> writes:
> Here is a really useful function that I wrote for minibuffer
> completion.  It will complete as much as possible, exiting if there is
> only one possibility.  If there are two or more, then it completes
> until the two choices differ.  If there aren't any possibilities, then
> it removes characters off the end of the completion string until it
> gets to a point where completions are possible and stops there.
> 
> I bind it to the SPACE key in the minibuffer, since I don't really
> like completion by single words at all.  Following the function is the
> function call that will bind it to the SPACE key.  Change the
> character there if you want to bind it to something else.  Enjoy.
> 
> (defun minibuffer-complete-exit-backup nil
>    "Minibuffer completion, exiting on unique completion with backup."
>    (interactive)
>    (let (comp (complete t))
>      (set-mark (dot-min))
>      (while (null (setq comp (all-completions
> 			      (region-to-string)
> 			      minibuffer-completion-table
> 			      minibuffer-completion-predicate)))
>        (setq complete nil)
>        (delete-backward-char 1 nil))
>      (and complete (if (null (cdr comp)) (minibuffer-complete-and-exit)
> 			(minibuffer-complete)))))
> ;
> (define-key minibuffer-local-must-match-map " "
>      (define-key minibuffer-local-completion-map " "
> 	  'minibuffer-complete-exit-backup))

If you want this useful little guy to work under GNU Emacs 17.30, do this:
(1) Remove the line with "(set-mark (dot-min))".
(2) Change the line containing "(region-to-string)" to :
    "(buffer-substring (dot-min) (dot))".

----------
	Greg Earle
	JPL
	sdcrdcf!smeagol!earle (UUCP)
	ia-sun2!smeagol!earle@cit-vax.arpa (ARPA)

=> Know Your Culture <=
"Chronos", a silent (no-talking) film about our history - at an IMAX theatre
near you.  (What? No IMAX near you?  Aye, there's the pity)  Makes all the
movies discussed in net.movies ( :=+ ) totally irrelevant and meaningless.