From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21412 invoked from network); 18 May 2000 10:47:11 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 May 2000 10:47:11 -0000 Received: (qmail 23444 invoked by alias); 18 May 2000 10:46:59 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11459 Received: (qmail 23427 invoked from network); 18 May 2000 10:46:53 -0000 Date: Thu, 18 May 2000 12:46:15 +0200 (MET DST) Message-Id: <200005181046.MAA04207@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Peter Stephenson's message of Wed, 17 May 2000 15:54:14 +0100 Subject: PATCH: Re: complete (real C) tags Peter Stephenson wrote: > 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... This showed a problem with _wanted and friends: they need some setup done by _main_complete. But one way of fixing this gives a nice enhancement to _main_complete, as in the patch below. If it is called with arguments and the first one is a `-', then the second one is taken as a name to stuff into the completer field of the context and the other arguments give a command with its arguments to call to generate the matches. So, this would be the patch to _complete_tag (not committed because there is no _complete_tag yet): --- _complete_tag.old Thu May 18 11:54:39 2000 +++ _complete_tag Thu May 18 12:26:26 2000 @@ -14,6 +14,14 @@ local c_Tagsfile=${TAGSFILE:-TAGS} c_tagsfile=${tagsfile:-tags} expl # Max no. of directories to scan up through integer c_maxdir=10 +# Context. +local curcontext="$curcontext" + +if [[ -z "$curcontext" ]]; then + curcontext="complete-tag:::" +else + curcontext="complete-tag:${curcontext#*:}" +fi local c_path= integer c_idir @@ -30,16 +38,16 @@ # 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) + _main_complete - '' _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) + _main_complete - '' _wanted vtags expl 'vi tags' \ + compadd - \ + $(awk '{ print $1 }' $c_path$c_Tagsfile) else return 1 fi And here is the patch for the change to _main_complete... Bye Sven Index: Completion/Core/_main_complete =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Core/_main_complete,v retrieving revision 1.20 diff -u -r1.20 _main_complete --- Completion/Core/_main_complete 2000/05/17 06:50:03 1.20 +++ Completion/Core/_main_complete 2000/05/18 10:46:21 @@ -20,7 +20,7 @@ unsetopt markdirs globsubst shwordsplit nounset ksharrays exec