# -*- shell-script -*-

# $Id: compctls,v 1.1 1996/07/02 12:03:25 stephens Exp stephens $

# Completions for BSP commands

# This file will work only with a recent version of the Z shell (zsh).
# tcsh has a similar mechanism, but I don't know it, and what's below
# will surely not work.  Check your version using "echo $ZSH_VERSION".
# Tested with 3.0-pre1, so presumably things from about 2.6 upwards
# will work.  Either stick in a file that gets read automatically, or
# read it explicitly using "source" or ".".

# Supplied with absolutely no warranty, etc.: this compctl stuff does
# my head in, and I make no claims to understand any of it.

# Bruce Stephens <B.Stephens@math.ruu.nl>

bsp_archs=($(bsparch -help |& sed '1,/^tested architectures/d
    /^$/,$d'))

# bspprof accepts any of the options -comm, -predict, etc.
# -arch must be followed by a valid BSP architecture (as given in bsp_archs)
# The first argument should match *.bsp file, and if all else fails default
# completion should be used (this allows args 1 and 2 to be expanded like
# filenames)
compctl -x 's[-]' -k '(comm predict ggraph title zoom \
    letter color colour bytes packets ignore outline slg arch nhalfmodel \
    hgmodel bisselingmodel ceilingg hrelgl)' - \
    'c[-1,-arch]' -k bsp_archs - 'p[1]' -g '*.bsp' + -- bspprof

compctl -g '*.(lc|c|lf|f|o|a)' -x 's[-L]' -g '*(-/)' - \
    's[-l]' -s '${(s.:.)^LD_LIBRARY_PATH}/lib*.a(:t:r:s/lib//)' - \
    's[-]' -k '(D v c o cflags f77flags overridecc overridef77 \
    overrideld g debug stat prof p O O2 O3 bspbuffer bspnobuffers bspfifo \
    fcombine-puts fnocombine-puts fcombine-puts-buffer fcontention-resolve \
    fnocontention-resolve f77 cplusplus ldflags tune nof77munging)' - \
    'C[-1,-override*]' -c - 'c[-1,-o]' -f \
    -- bspfront

compctl -x 's[-]' -k '(arch device help)' -- bsparch
