mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-13 01:31:18 +02:00
26021: tweak for glob qualifier completion
This commit is contained in:
parent
29852fe214
commit
399cf6312e
2 changed files with 34 additions and 14 deletions
|
@ -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>
|
2008-11-08 Clint Adams <clint@zsh.org>
|
||||||
|
|
||||||
* unposted: Src/glob.c: revert 26014.
|
* unposted: Src/glob.c: revert 26014.
|
||||||
|
|
|
@ -1,5 +1,30 @@
|
||||||
#autoload
|
#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>'
|
# Utility function for in-path completion. This allows `/u/l/b<TAB>'
|
||||||
# to complete to `/usr/local/bin'.
|
# 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 nm=$compstate[nmatches] menu matcher mopts sort mid accex fake
|
||||||
local listfiles listopts tmpdisp origtmp1 Uopt
|
local listfiles listopts tmpdisp origtmp1 Uopt
|
||||||
integer npathcheck
|
integer npathcheck
|
||||||
local -a match mbegin mend Mopts
|
local -a Mopts
|
||||||
|
|
||||||
typeset -U prepaths exppaths
|
typeset -U prepaths exppaths
|
||||||
|
|
||||||
|
@ -383,19 +408,7 @@ for prepath in "$prepaths[@]"; do
|
||||||
|
|
||||||
tmp2=( "$tmp1[@]" )
|
tmp2=( "$tmp1[@]" )
|
||||||
|
|
||||||
# Look for glob qualifiers.
|
if [[ "$tpre$tsuf" = */* ]]; then
|
||||||
# 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
|
|
||||||
compfiles -P$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" "$sdirs" fake
|
compfiles -P$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" "$sdirs" fake
|
||||||
elif [[ "$sopt" = *[/f]* ]]; then
|
elif [[ "$sopt" = *[/f]* ]]; then
|
||||||
compfiles -p$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" "$sdirs" fake "$pats[@]"
|
compfiles -p$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" "$sdirs" fake "$pats[@]"
|
||||||
|
|
Loading…
Reference in a new issue