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

Standard 'filtering' mechanism?

I'm still getting acquainted with the intricacies of Zsh completion and 
pattern matching.  One thing I've wanted to do for a while is prevent 
'vim' completion from matching the various 'junk' files that are 
associated with various phases of TeX compilation.

For example, given the input file 'document.tex', I get the following 

document.tex    document.tmp    document.tuo
document.tuc    document.pdf    document.log

But, if I have other files in the directory , I don't want to exclude 
them.  So, my goal is to filter the list of matches via something like 
this function (that does what I want):

function filter-tex {
    local f tex include
    tex=( ${${(M)^argv:#*.tex}:r} )
    if (( $#tex )) ; then
        for f in $argv ; do
            for t in $tex ; do
                if (( $f[(I)$t*] )) ; then
                    [[ $f:e == tex ]] || include=false
            $include && reply+=( $f )
        reply=( $argv )
    print -l $reply

But, I don't understand how to integrate this with completion.  Is there 
some standard mechanism to roughly 'filter the list of matches with this 
function'?  The various 'file-patterns'-like options all seem to want 
just a straight pattern.

I don't necessarily want to just override normal argument completion 
(though it'd work fine for this case, since I don't need _vim's 
+line-number completion, and I generally don't use many other arguments 
to start 'vim').

I also suspect the function might be 'compressible' into a complicated 
pattern, but that's definitely out of my league right now.


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