Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Standard 'filtering' mechanism?
- X-seq: zsh-users 14833
- From: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Standard 'filtering' mechanism?
- Date: Sun, 14 Feb 2010 15:05:17 -0500 (EST)
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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
files:
document.tex document.tmp document.tuo
document.tuc document.pdf document.log
document-mpgraph.mp
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} )
reply=()
if (( $#tex )) ; then
for f in $argv ; do
include=true
for t in $tex ; do
if (( $f[(I)$t*] )) ; then
[[ $f:e == tex ]] || include=false
fi
done
$include && reply+=( $f )
done
else
reply=( $argv )
fi
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.
--
Best,
Ben
Messages sorted by:
Reverse Date,
Date,
Thread,
Author