Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
complete (real C) tags
- X-seq: zsh-workers 11443
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx (Zsh hackers list)
- Subject: complete (real C) tags
- Date: Wed, 17 May 2000 15:54:14 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
I don't think I ever posted this; it allows the new completion system to
complete tags from a TAGS or tags file (i.e. the tags used by Emacs and vi,
nothing to do with completion tags). I have it bound to ^Xt.
I was going to send it to zshu, until I realised it didn't use style tags,
and tried to make it by sticking the _wanted stuff in front, which failed,
so I took it off again. Only one man will know why...
--
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxxx>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
#compdef -k complete-word \C-xt
# Complete tags using either TAGS or tags. Looks up your directory
# hierarchy to find one. If both exist, uses TAGS.
#
# You can override the choice of tags file with $TAGSFILE (for TAGS)
# or $tagsfile (for tags).
#
# Could be rewritten by some sed expert to use sed instead of perl.
# setopt localoptions xtrace
# Tags file to look for
local c_Tagsfile=${TAGSFILE:-TAGS} c_tagsfile=${tagsfile:-tags} expl
# Max no. of directories to scan up through
integer c_maxdir=10
local c_path=
integer c_idir
while [[ ! -f $c_path$c_Tagsfile &&
! -f $c_path$c_tagsfile && $c_idir -lt $c_maxdir ]]; do
(( c_idir++ ))
c_path=../$c_path
done
if [[ -f $c_path$c_Tagsfile ]]; then
# prefer the more comprehensive TAGS, which unfortunately is a
# little harder to parse.
# could do this with sed, just can't be bothered to work out how,
# after quarter of an hour of trying, except for
# rm -f =sed; ln -s /usr/local/bin/perl /usr/bin/sed
# but that's widely regarded as cheating.
# _wanted etags expl 'emacs tags'
compadd - \
$(perl -ne '/([a-zA-Z_0-9]+)[ \t:;,\(]*\x7f/ &&
print "$1\n"' $c_path$c_Tagsfile)
elif [[ -f $c_tagspath ]]; then
# tags doesn't have as much in, but the tag is easy to find.
# we can use awk here.
# _wanted vtags expl 'vi tags'
compadd - \
$(awk '{ print $1 }' $c_path$c_Tagsfile)
else
return 1
fi
Messages sorted by:
Reverse Date,
Date,
Thread,
Author