From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33 invoked by alias); 11 Jul 2013 10:05:08 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17856 Received: (qmail 12662 invoked from network); 11 Jul 2013 10:05:02 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at samsung.com does not designate permitted sender hosts) X-AuditID: cbfec7f5-b7f376d000001ec6-42-51de80ee19ea Date: Thu, 11 Jul 2013 10:54:53 +0100 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: Make Completion Message-id: <20130711105453.1615bb3b@pwslap01u.europe.root.pri> In-reply-to: <51DD616D.2090200@goots.org> References: <51DD616D.2090200@goots.org> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplluLIzCtJLcpLzFFi42I5/e/4Fd13DfcCDZoWaVvsOLmS0YHRY9XB D0wBjFFcNimpOZllqUX6dglcGYtX3WUp2ChecazlKVsD41XBLkZODgkBE4kde/awQthiEhfu rWfrYuTiEBJYyihxec1OdiiHSeLb5k/MIFUsAqoSv7rmgnWwCRhKTN00mxHEFhEQlVi+YjM7 iC0sICNxZMUuNhCbV8Be4s6662BxTgFNiR+nvoPNERLQkDh64wQLiM0voC9x9e8nJogr7CVm XjnDCNErKPFj8j2wGmYBLYnN25pYIWx5ic1r3jJPYBSYhaRsFpKyWUjKFjAyr2IUTS1NLihO Ss810itOzC0uzUvXS87P3cQICcKvOxiXHrM6xCjAwajEw9sQfzdQiDWxrLgy9xCjBAezkgiv k8+9QCHelMTKqtSi/Pii0pzU4kOMTBycUg2MnZfPs3yPUJxscDNFp/C9UP1X1djHVzrvM/mv rVH4toM36lNwfNGyJLVJuVszF3f99bwW9Ttd1aopdF9A8cGUOy1JggtusHBxLnL8z9rYa7hx 4wL10E7Z39aak29NfdO+7rxP5xbhKcfLvN9sLCuSffz43XLulsf3XmQcW3iF81yp8vnD61a7 KLEUZyQaajEXFScCAOg+3LAgAgAA On Wed, 10 Jul 2013 14:28:13 +0100 Nick Cross wrote: > Am I right in thinking that the make completion under ZSH (5.0.2 on > Fedora18) does not complete the command line -* options (as opposed to > Bash which does) ? I have tried "make -" and nothing happens - in > bash it prints out a menu of the - options (e.g. --debug). Yes, it's fairly basic in terms of options, though quite smart about looking inside makefiles. Currently it's quite hard to update since it doesn't use _arguments. As a first step, this fixes that problem, so it should be much easier to add further GNU option handling as a next step (or further variants if desired). Lightly tested --- I don't think I've completely broken it but 100% satisfaction not guaranteed. diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make index 53e2e1b..72d16bb 100644 --- a/Completion/Unix/Command/_make +++ b/Completion/Unix/Command/_make @@ -148,7 +148,9 @@ _make-findBasedir () { _make() { local prev="$words[CURRENT-1]" file expl tmp is_gnu dir incl match - local -A TARGETS VARIABLES + local context state line + local -a option_specs + local -A TARGETS VARIABLES opt_args local ret=1 _pick_variant -r is_gnu gnu=GNU unix -v -f @@ -156,21 +158,43 @@ _make() { if [[ $is_gnu == gnu ]] then incl="(-|)include" + # TBD: update option_specs + option_specs=( + '-C[change directory first]:directory:->dir' + '-I[include directory for makefiles]:directory:->dir' + '-f[specify makefile]:makefile:->file' + '-o[specify file not to remake]:file not to remake:->file' + '-W[pretend file was modified]:file to treat as modified:->file' + ) else + # Basic make options only. incl=.include + option_specs=( + '-C[change directory first]:directory:->dir' + '-I[include directory for makefiles]:directory:->dir' + '-f[specify makefile]:makefile:->file' + '-o[specify file not to remake]:file not to remake:->file' + '-W[pretend file was modified]:file to treat as modified:->file' + ) fi - if [[ "$prev" == -[CI] ]] - then + _arguments -s $option_specs \ + '*:make target:->target' && ret=0 + + case $state in + (dir) _files -W ${(q)$(_make-findBasedir ${words[1,CURRENT-1]})} -/ && ret=0 - elif [[ "$prev" == -[foW] ]] - then + ;; + + (file) _files -W ${(q)$(_make-findBasedir $words)} && ret=0 - else - file="$words[(I)-f]" - if (( file )) + ;; + + (target) + file=($opt_args[(K)(-f|--file|--makefile)]) + file=$file[1] + if [[ -n $file ]] then - file=${~words[file+1]} [[ $file == [^/]* ]] && file=${(q)$(_make-findBasedir $words)}/$file [[ -r $file ]] || file= else @@ -222,7 +246,7 @@ _make() { compadd -S '=' -- ${(k)VARIABLES} && ret=0 done fi - fi + esac return ret } pws