zsh-workers
 help / color / mirror / code / Atom feed
From: Hugo Haas <hugo@larve.net>
To: Clint Adams <schizo@debian.org>
Cc: zsh-workers@sunsite.dk, 262247@bugs.debian.org
Subject: Re: Bug#262247: zsh: Improved make completion
Date: Wed, 18 Aug 2004 11:07:36 -0400	[thread overview]
Message-ID: <20040818150736.GI4753@larve.net> (raw)
In-Reply-To: <20040730165133.GL12279@larve.net>


[-- Attachment #1.1: Type: text/plain, Size: 1317 bytes --]

* Hugo Haas <hugo@larve.net> [2004-07-30 18:51+0200]
> * Clint Adams <schizo@debian.org> [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.
> > 
> > You mean it should replace the expression
> > 
> > '@matches = /^(?:([a-zA-Z0-9]+[^\/\t=\s]+)\s*)+:/  and
> >         print join(" ", @matches);
> > if (/^\.include\s+\<bsd\.port\.(subdir\.|pre\.)?mk>/ ||
> >     /^\.include\s+\".*mk\/bsd\.pkg\.(subdir\.)?mk\"/) {
> >     print "fetch fetch-list extract patch configure build install reinstall dein
> > stall package describe checkpatch checksum makesum\n";
> >     }
> > '
> > 
> > in _make?
> 
> Yes, it basically does the same, but follows include statements. It
> doesn't work for something like "include $(MYFILE)", but works for
> "include myfile" — resolving variable seemed complex.
> 
> > Maybe the perl and awk bits should be replaced by some native Z-Shell parsing.
> 
> 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

-- 
Hugo Haas - http://larve.net/people/hugo/

[-- Attachment #1.2: patch-make --]
[-- Type: text/plain, Size: 1510 bytes --]

--- _make	2004-08-18 10:10:24.000000000 -0400
+++ /usr/share/zsh/4.2.0/functions/Completion/Unix/_make	2004-08-18 11:03:52.000000000 -0400
@@ -1,5 +1,26 @@
 #compdef make gmake pmake dmake
 
+parseMakefile() {
+    local input
+    while read input; do
+	case $input in
+	    [[:alnum:]]##:)
+		echo $input| cut -d: -f1
+		;;
+	    include\ *)
+                local f
+		f=$(echo $input| cut -d\  -f2)
+		if [ $f != '/*' ]; then
+		    f=$dir/$f
+		fi
+		if [ -r $f ]; then
+		    parseMakefile < $f
+		fi
+		;;
+	esac
+    done
+}
+
 local prev="$words[CURRENT-1]" file expl tmp is_gnu cmdargs useperl
 
 zstyle -t ":completion:${curcontext}:" use-perl && useperl=1
@@ -24,14 +45,10 @@
   fi
 
   if [[ -n "$file" ]] && _tags targets; then
-    if [[ $is_gnu = gnu ]] &&
-       zstyle -t ":completion:${curcontext}:targets" call-command; then
-       if [[ -n $useperl ]]; then
-        cmdargs=(perl -F: -ane '/^[a-zA-Z0-9][^\/\t=]+:/ && print "$F[0]\n"')
-       else
-        cmdargs=(awk '/^[a-zA-Z0-9][^\/\t=]+:/ {print $1}' FS=:)
-       fi
-       tmp=( $(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" .PHONY 2> /dev/null | $cmdargs) )
+    if [[ $is_gnu = gnu ]]; then
+      dir=$(dirname $file)
+      tmp=( $(parseMakefile < $file) )
+      _wanted targets expl 'make target' compadd -a tmp && return 0
     elif [[ -n $useperl ]]; then
       tmp=(
       $(perl -ne '@matches = /^(?:([a-zA-Z0-9]+[^\/\t=\s]+)\s*)+:/  and

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 307 bytes --]

  reply	other threads:[~2004-08-18 15:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040730101751.GA11905@larve.net>
2004-07-30 15:30 ` Clint Adams
2004-07-30 16:51   ` Hugo Haas
2004-08-18 15:07     ` Hugo Haas [this message]
2004-08-18 17:04       ` Wayne Davison
2004-08-21 18:09       ` Wayne Davison
2004-08-22  1:47         ` Bart Schaefer
2004-08-26 16:10         ` Hugo Haas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040818150736.GI4753@larve.net \
    --to=hugo@larve.net \
    --cc=262247@bugs.debian.org \
    --cc=schizo@debian.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).