From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27004 invoked from network); 18 Aug 2004 15:09:18 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 18 Aug 2004 15:09:18 -0000 Received: (qmail 19095 invoked from network); 18 Aug 2004 15:09:12 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 Aug 2004 15:09:12 -0000 Received: (qmail 7603 invoked by alias); 18 Aug 2004 15:09:00 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20268 Received: (qmail 7594 invoked from network); 18 Aug 2004 15:08:59 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by 130.225.247.90 with SMTP; 18 Aug 2004 15:08:59 -0000 Received: (qmail 18343 invoked from network); 18 Aug 2004 15:07:39 -0000 Received: from homer.w3.org (128.30.52.30) by a.mx.sunsite.dk with SMTP; 18 Aug 2004 15:07:38 -0000 Received: from buena (localhost [127.0.0.1]) by homer.w3.org (Postfix) with ESMTP id C517F4F00B; Wed, 18 Aug 2004 11:07:36 -0400 (EDT) Received: by buena (Postfix, from userid 1000) id 7955113A7A; Wed, 18 Aug 2004 11:07:36 -0400 (EDT) Date: Wed, 18 Aug 2004 11:07:36 -0400 From: Hugo Haas To: Clint Adams Cc: zsh-workers@sunsite.dk, 262247@bugs.debian.org Subject: Re: Bug#262247: zsh: Improved make completion Message-ID: <20040818150736.GI4753@larve.net> References: <20040730101751.GA11905@larve.net> <20040730153054.GA4059@scowler.net> <20040730165133.GL12279@larve.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="72k7VsmfIboquFwl" Content-Disposition: inline In-Reply-To: <20040730165133.GL12279@larve.net> User-Agent: Mutt/1.5.6+20040722i X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-4.9 required=6.0 tests=BAYES_00 autolearn=no version=2.63 X-Spam-Hits: -4.9 --72k7VsmfIboquFwl Content-Type: multipart/mixed; boundary="hABqaeELJqnDDeDE" Content-Disposition: inline --hABqaeELJqnDDeDE Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Hugo Haas [2004-07-30 18:51+0200] > * Clint Adams [2004-07-30 11:30-0400] > > > Attached is a Perl script that can be used as a replacement of the > > > Perl script appearing in the make completion code (_make) to follow > > > include statements in Makefiles. > >=20 > > You mean it should replace the expression > >=20 > > '@matches =3D /^(?:([a-zA-Z0-9]+[^\/\t=3D\s]+)\s*)+:/ and > > print join(" ", @matches); > > if (/^\.include\s+\/ || > > /^\.include\s+\".*mk\/bsd\.pkg\.(subdir\.)?mk\"/) { > > print "fetch fetch-list extract patch configure build install reins= tall dein > > stall package describe checkpatch checksum makesum\n"; > > } > > ' > >=20 > > in _make? >=20 > Yes, it basically does the same, but follows include statements. It > doesn't work for something like "include $(MYFILE)", but works for > "include myfile" =E2=80=94 resolving variable seemed complex. >=20 > > Maybe the perl and awk bits should be replaced by some native Z-Shell p= arsing. >=20 > I agree, but that sounds complex to do. :-) Attached is an attempt at doing this. It seems to work, though I only enabled it for the gnu case. Let me know what you think. Regards, Hugo --=20 Hugo Haas - http://larve.net/people/hugo/ --hABqaeELJqnDDeDE Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch-make Content-Transfer-Encoding: quoted-printable --- _make 2004-08-18 10:10:24.000000000 -0400 +++ /usr/share/zsh/4.2.0/functions/Completion/Unix/_make 2004-08-18 11:03:5= 2.000000000 -0400 @@ -1,5 +1,26 @@ #compdef make gmake pmake dmake =20 +parseMakefile() { + local input + while read input; do + case $input in + [[:alnum:]]##:) + echo $input| cut -d: -f1 + ;; + include\ *) + local f + f=3D$(echo $input| cut -d\ -f2) + if [ $f !=3D '/*' ]; then + f=3D$dir/$f + fi + if [ -r $f ]; then + parseMakefile < $f + fi + ;; + esac + done +} + local prev=3D"$words[CURRENT-1]" file expl tmp is_gnu cmdargs useperl =20 zstyle -t ":completion:${curcontext}:" use-perl && useperl=3D1 @@ -24,14 +45,10 @@ fi =20 if [[ -n "$file" ]] && _tags targets; then - if [[ $is_gnu =3D gnu ]] && - zstyle -t ":completion:${curcontext}:targets" call-command; then - if [[ -n $useperl ]]; then - cmdargs=3D(perl -F: -ane '/^[a-zA-Z0-9][^\/\t=3D]+:/ && print "$F[= 0]\n"') - else - cmdargs=3D(awk '/^[a-zA-Z0-9][^\/\t=3D]+:/ {print $1}' FS=3D:) - fi - tmp=3D( $(_call_program targets "$words[1]" -nsp --no-print-directo= ry -f "$file" .PHONY 2> /dev/null | $cmdargs) ) + if [[ $is_gnu =3D gnu ]]; then + dir=3D$(dirname $file) + tmp=3D( $(parseMakefile < $file) ) + _wanted targets expl 'make target' compadd -a tmp && return 0 elif [[ -n $useperl ]]; then tmp=3D( $(perl -ne '@matches =3D /^(?:([a-zA-Z0-9]+[^\/\t=3D\s]+)\s*)+:/ and --hABqaeELJqnDDeDE-- --72k7VsmfIboquFwl Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iQCVAwUBQSNwuKN/9WeKWvkNAQFxcgQAugFTwlgJwjSHC0WdWEt3KC3815Lzt5Sk e4eZYUpaBDMCx31/7MERWTorhTgNWuWuLxFPRzkB02PhAyaYUnXaMT84jzvtllA4 PU47Fea+vB6Ctk26s4uZq7PGIbQBmsfkHn763enjF6XvILV1yTU+AB8WPqYCu4yD eAqqK92KOX0= =jnkd -----END PGP SIGNATURE----- --72k7VsmfIboquFwl--