Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug#262247: zsh: Improved make completion



> 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?

Maybe the perl and awk bits should be replaced by some native Z-Shell parsing.
sub match() {
    my ($fn) = @_;
    @matches = /^(?:([a-zA-Z0-9]+[^\/\t=\s]+)\s*)+:/  and 
    print join(" ", @matches);
    if (/^include\s+(\S+)/) {
	my $i = $1;;
	if ($fn =~ m|/|) {
	    $fn =~ s|/[^/]+$|/$i|;
	} else {
	    $fn = $i;
	}
	&parse($fn);
    }
    elsif (/^\.include\s+\<bsd\.port\.(subdir\.|pre\.)?mk>/ ||
	     /^\.include\s+\".*mk\/bsd\.pkg\.(subdir\.)?mk\"/) {
	print "fetch fetch-list extract patch configure build install reinstall deinstall package describe checkpatch checksum makesum\n";
    }
}

sub parse() {
    my ($fn) = @_;
    my $f;
    open($f, $fn) || return;
    while (<$f>) {
	&match($fn);
    }
    close($f);
}

&parse($ARGV[0]);


Messages sorted by: Reverse Date, Date, Thread, Author