Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug in _approximate with ~/



On Aug 16,  4:54pm, martin.ebourne@xxxxxxxxxxxx wrote:
} Subject: Bug in _approximate with ~/
}
} % zstyle ":completion:*" completer _complete _approximate
} % mkdir -p ~/test/test{1,2}
} % ~/test/f
} 
} Press tab immediately after the 'f', and I get:
} 
} % \!
} \!      *       -       .       0       1       :       @       X       \[
} e       r       test1/  test2/  w       \{      \}
} ~/test/f
} 
} Which wasn't quite what I expected! ;)

~/test/f is in command position. Therefore it gets compared to parameter
names, reserved words, aliases, command names, file names, job specifiers
(%1, %2, etc.), and some other things I've forgotten.  It doesn't match
any of the above, so you get offered a bunch of possibilites, some from
each of those sources.  If you were to menu-complete through the list
so that you could see the suffixes that get auto-appended to each one,
you'd get some idea where they came from; for example, X e r w : - and
dot are commands.

In _approximate there's this snippet:

    ### This distinction doesn't seem to be needed anymore
    # if [[ "$PREFIX" = \~*/* ]]; then
    #   PREFIX="${PREFIX%%/*}/(#a${_comp_correct})${PREFIX#*/}"
    # else
      PREFIX="(#a${_comp_correct})$PREFIX"
    # fi

This results in a PREFIX that looks like `(#a1)~/test/f'.  _path_files
does the right thing with this -- it peels off the (#a1), expands the
tilde, and then applies (#a1) to each path element.  However, none of
the other completions that are attempted in command position are this
intelligent -- they all interpret `(#a1)~/test/f' as `(#a1)()~/test/f',
that is, allow one correction to the empty string as long as that does
not match `/test/f'.  Consequently you get all the one-letter commands,
parameters, reserved words, etc.

You're right, this is a bug.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



Messages sorted by: Reverse Date, Date, Thread, Author