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

Re: Standard 'filtering' mechanism?



"Benjamin R. Haskell" wrote:
> 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.

If I've worked out correctly what you're trying to do (exclude files
which have the same basename as a .tex file), how about something like
this...


vim-files() {
  local dir
  if [[ $PREFIX = */* ]]; then
    if [[ $PREFIX[-1] = / ]]; then
      dir=$PREFIX[1,-2]
    else
      dir=${PREFIX:h}
    fi
  else
    dir=.
  fi
  local -a texfiles nontexfiles
  local -aU suffixes
  texfiles=($dir/*.tex(N))
  if (( $#texfiles )); then
    notexfiles=(${texfiles:r}.*)
    suffixes=(${${notexfiles:e}:#tex})
    reply=("^*.(${(j.|.)suffixes})")
  fi
}
zstyle -e ':completion:*:*:vim:*' file-patterns vim-files


-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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