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

Re: globcomplete desctroys file completion



On Feb 21,  2:18pm, Jorg wrote:
}
} when I set the option globcomplete, file completion doesn't work in all
} cases.

Based just on the _complete_debug output you sent, I'd say that the
correct thing is happening WITH globcomplete, and without it you're
somehow getting disambiguation that you shouldn't.

For example, T*/t*/t* should among other files match Tmp/texlive/tlpkg
and Tmp/texlive2008/tlpkg, but when you complete without globcomplete
you're offered Tmp/texlive/te as a unique prefix.  How can that be
correct?
 
} % zsh -f
} ibook% autoload -Uz compinit
} ibook% compinit

You might try using "compinit -D" here when testing, to avoid reading
an existing zcompdump file.  Probably doesn't matter here.

} ibook% print -l T/t/t<TAB>          --> Tmp/texlive/te
} ibook% setopt globcomplete 
} ibook% print -l T/t/t<TAB>          --> nothing, failure
} % zsh --version
} zsh 4.3.9 (powerpc-unknown-linux-gnu)
} 
} A log for this is available at
} http://alioth.debian.org/~jo-guest/zsh5117print1

What is helpful in these cases is TWO logs, e.g. one with globcomplete
set and the other with globcomplete NOT set, for comparison.

I created the set of files shown at _path_files:449 in your debug trace:

schaefer<513> print -C 2 T*/t*/t*
Tmp/texlive2008/texmf            Tmp/texlive/texmf
Tmp/texlive2008/texmf-dist       Tmp/texlive/texmf.cnf
Tmp/texlive2008/texmf-doc        Tmp/texlive/texmf-config
Tmp/texlive2008/texmf-var        Tmp/texlive/texmf-dist
Tmp/texlive2008/tlpkg            Tmp/texlive/texmf-doc
Tmp/texlive2008/tl-portable      Tmp/texlive/texmf-local
Tmp/texlive2008/tl-portable.bat  Tmp/texlive/texmf-var
Tmp/texlive/temp                 Tmp/texlive/tlpkg
schaefer<514> zsh -f
torch% autoload -Uz compinit
torch% compinit -D
torch% print T/t/t<C-x?>
torch% print Tmp/texlive/t
                        ^
			cursor is here, on the slash, because
			texlive is ambiguous with texlive2008
torch% setopt globcomplete
torch% print T/t/t<C-x?>
Trace output left in /tmp/zsh12830print2 (up-history to view)
torch% print T/t/t<C-d>
texlive/      texlive2008/

Interesting.  Comparing the traces I find that at _path_files:238 with
globcomplete, menu=yes is being set, and at _path_files:623 the value
of $compstate[pattern_match] is "*" so the code branches to line 667
instead of 629.  This sends us around the (for i in "$tmp1[@]"; do)
loop at line 673 a bunch of times, each time adding either "texlive"
or "texlive2008" as a completion with a different path tail as a hidden
suffix.  When we finally get to the end of _path_files at line 813,
$compstate[nmatches] is greater than zero so _path_files returns 1.

I'm not sure why an empty $compstate[pattern_match] means that the
function should behave as if NOT inserting the match into the command
line (see comments around lines 627 and 666), but that's what causes
the "correct" branch at 621-623.  It also seems to be the case that
xtrace output is omitting short-circuited branches of conditionals
when printing, which makes it hard to follow the and/or logic in the
trace.

-- 



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