[gnu.emacs.bug] Completion and environment variables don't cooperate

quiroz@cs.rochester.edu (Cesar Quiroz) (09/22/89)

This affects 18.54 and 18.55 at least, but I am sure it was there
long before them.

Suspect is minibuffer-complete-word.  When asked to complete a
filename that contains environment variables, it reduces the entire
filename to "/".

TO REPEAT:

I assume you have a $HOME/.emacs.  Activate the minibuffer of a
freshly started `emacs -q' by doing

C-xC-fC-aC-k

Your minibuffer shows "Find file:[] ".  Now type

$HOME/.emacs

Now, if you type TAB, the completion will succeed in giving you the
filename you expected.  However, if you type SPC, the filename will
be replaced by a /.

WORKAROUND:

Until fixed, use TAB for completions in the minibuffer, never SPC.


-- 
                                      Cesar Augusto Quiroz Gonzalez
                                      Department of Computer Science
                                      University of Rochester
                                      Rochester,  NY 14627

jbw@bucsf.bu.edu (Joe Wells) (09/22/89)

In article <1989Sep21.191411.3071@cs.rochester.edu> quiroz@cs.rochester.edu (Cesar Quiroz) writes:
   Suspect is minibuffer-complete-word.  When asked to complete a
   filename that contains environment variables, it reduces the entire
   filename to "/".

After getting the completion, minibuffer-complete-word looks at what is in
the minibuffer and finds length of the largest suffix of the minibuffer
contents that is a prefix of the completion.  It starts from that
character in the completion and finds the next non-word character.
Everything in the completion up to and including that non-word character
becomes the new contents of the minibuffer.

Normally this works like this:

Contents of minibuffer:  "/usr/jbw/misc/junk"
Completion:              "/usr/jbw/misc/junk-file"
Suffix that is prefix:   "/usr/jbw/misc/junk"
New minibuffer contents: "/usr/jbw/misc/junk-"

In your case, this worked like this:

Contents of minibuffer:  "$HOME/misc/junk"
Completion:              "/usr/jbw/misc/junk-file"
Suffix that is prefix:   ""
New minibuffer contents: "/"

I believe the best solution to this problem would be to automatically
expand the environment variables before trying to do the completion.
Since the current code is not specialized for filename completion, this
might be difficult.

--
Joe Wells <jbw@bucsf.bu.edu>
jbw%bucsf.bu.edu@bu-it.bu.edu
...!harvard!bu-cs!bucsf!jbw