1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-10 12:40:58 +02:00

26021: tweak for glob qualifier completion

This commit is contained in:
Peter Stephenson 2008-11-08 23:34:11 +00:00
parent 29852fe214
commit 399cf6312e
2 changed files with 34 additions and 14 deletions

View file

@ -1,3 +1,10 @@
2008-11-08 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 26021: Completion/Unix/Type/_path_files: complete glob
qualifiers where they don't mess up the rest of the word,
don't complete a bare glob qualifier if there's nothing
before it.
2008-11-08 Clint Adams <clint@zsh.org>
* unposted: Src/glob.c: revert 26014.

View file

@ -1,5 +1,30 @@
#autoload
local -a match mbegin mend
# Look for glob qualifiers. Do this first: if we're really
# in a glob qualifier, we don't actually want to expand
# the earlier part of the path. We can't expand inside
# parentheses otherwise, so as we test that successfully
# we should be able to commit to glob qualifiers here.
#
# Extra nastiness to be careful about a quoted parenthesis.
# The initial tests look for parentheses with zero or an
# even number of backslashes in front. We also require that
# there was at least one character before the parenthesis for
# a bare glob qualifier.
# The later test looks for an outstanding quote.
if [[ ( -o bareglobqual && \
$PREFIX = (#b)((*[^\\]|)(\\\\)#\()([^\)]#) && \
${#match[1]} -gt 1 || \
-o extendedglob && \
$PREFIX = (#b)((*[^\\]|)(\\\\)#"(#q")([^\)]#) \
) && -z $compstate[quote] ]]; then
compset -p ${#match[1]}
_globquals
return
fi
# Utility function for in-path completion. This allows `/u/l/b<TAB>'
# to complete to `/usr/local/bin'.
@ -9,7 +34,7 @@ local pats haspats ignore pfx pfxsfx sopt gopt opt sdirs ignpar cfopt listsfx
local nm=$compstate[nmatches] menu matcher mopts sort mid accex fake
local listfiles listopts tmpdisp origtmp1 Uopt
integer npathcheck
local -a match mbegin mend Mopts
local -a Mopts
typeset -U prepaths exppaths
@ -383,19 +408,7 @@ for prepath in "$prepaths[@]"; do
tmp2=( "$tmp1[@]" )
# Look for glob qualifiers.
# Extra nastiness to be careful about a quoted parenthesis.
# The initial tests look for parentheses with zero or an
# even number of backslashes in front.
# The later test looks for an outstanding quote.
if [[ ( -o bareglobqual && \
"$tpre/$tsuf" = (#b)((*[^\\]|)(\\\\)#\()([^\)]#) || \
-o extendedglob && \
"$tpre/$tsuf" = (#b)((*[^\\]|)(\\\\)#"(#q")([^\)]#) \
) && -z $compstate[quote] ]]; then
compset -p ${#match[1]}
_globquals
elif [[ "$tpre$tsuf" = */* ]]; then
if [[ "$tpre$tsuf" = */* ]]; then
compfiles -P$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" "$sdirs" fake
elif [[ "$sopt" = *[/f]* ]]; then
compfiles -p$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" "$sdirs" fake "$pats[@]"