* Hugo Haas <hugo@xxxxxxxxx> [2004-07-30 18:51+0200] > * Clint Adams <schizo@xxxxxxxxxx> [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/
--- _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:
signature.asc
Description: Digital signature