From 7e17ea8016744fa7066d58eb008e30d3796f755d Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 11 Jul 2013 11:14:38 +0100 Subject: users/17856: rewrite _make to use _arguments. No new option handling yet, but this should make it easier to add. --- Completion/Unix/Command/_make | 44 +++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) (limited to 'Completion/Unix/Command/_make') diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make index 53e2e1b3e..72d16bb7d 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 } -- cgit v1.2.3 From a71b8df9b21bfa3e3cb11ca7c72a56adf5dde7ee Mon Sep 17 00:00:00 2001 From: Nick Cross Date: Thu, 11 Jul 2013 22:07:18 +0100 Subject: Update make completion with gnu options --- ChangeLog | 5 +++++ Completion/Unix/Command/_make | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 8 deletions(-) (limited to 'Completion/Unix/Command/_make') diff --git a/ChangeLog b/ChangeLog index d7cefb3c9..141f048d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-07-12 Peter Stephenson + + * Nick Cross: 31512: Completion/Unix/Command/_make: + extra GNU options plus fix to makefile completion. + 2013-07-11 Peter Stephenson * users/17856: Completion/Command/Unix/_make: rewrite to use diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make index 72d16bb7d..5dd0a21a4 100644 --- a/Completion/Unix/Command/_make +++ b/Completion/Unix/Command/_make @@ -158,13 +158,36 @@ _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' + {-B,--always-make}'[Unconditionally make all targets]' + {-C,--directory=}'[change directory first]:directory:->dir' + '-d[Print lots of debug information]' + '--debug=-[Print various types of debug information]:FLAGS' + {-e,--environment-overrides}'[Environment variables override makefiles]' + '--eval=-[Evaluate STRING as a makefile statement]:STRING' + {-f,--file=,--makefile=}'[Read FILE as a makefile]:file:->file' + '-h[Print this message and exit]' + {-i,--ignore-errors}'[Ignore errors from recipes]' + {-I,--include-dir=}'[Search DIRECTORY for included makefiles]:directory:->dir' + {-j,--jobs=}'[Allow N jobs at once; infinite jobs with no arg]:number of jobs' + {-k,--keep-going}"[Keep going when some targets can't be made]" + {-l,--load-average=,--max-load}"[Don't start multiple jobs unless load is below N]:load" + {-L,--check-symlink-times}'[Use the latest mtime between symlinks and target]' + {-n,--just-print,--dry-run,--recon}"[Don't actually run any recipe; just print them]" + {-o,--old-file=,--assume-old=}"[Consider FILE to be very old and don't remake it]:file not to remake:->file" + {-p,--print-data-base}'[Print makes internal database]' + {-q,--question}'[Run no recipe; exit status says if up to date]' + {-r,--no-builtin-rules}'[Disable the built-in implicit rules]' + {-R,--no-builtin-variables}'[Disable the built-in variable settings]' + {-s,--silent,--quiet}"[Don't echo recipes]" + {-S,--no-keep-going,--stop}'[Turns off -k]' + {-t,--touch}'[Touch targets instead of remaking them]' + {-v,--version}'[Print the version number of make and exit]' + {-w,--print-directory}'[Print the current directory]' + '--no-print-directory[Turn off -w, even if it was turned on implicitly]' + {-W,--what-if=,--new-file=,--asume-new=}'[Consider FILE to be infinitely new]:file to treat as modified:->file' + '--warn-undefined-variables[Warn when an undefined variable is referenced]' + '--warn-undefined-functions[Warn when an undefined user function is called]' ) else # Basic make options only. @@ -191,8 +214,7 @@ _make() { ;; (target) - file=($opt_args[(K)(-f|--file|--makefile)]) - file=$file[1] + file=${(v)opt_args[(I)(-f|--file|--makefile)]} if [[ -n $file ]] then [[ $file == [^/]* ]] && file=${(q)$(_make-findBasedir $words)}/$file -- cgit v1.2.3 From 29256a7c9656e20fc44ebeb257230ba41c23e74e Mon Sep 17 00:00:00 2001 From: Jun T Date: Thu, 18 Jul 2013 00:40:02 +0900 Subject: 31525: Fix some options in _make --- ChangeLog | 5 +++++ Completion/Unix/Command/_make | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'Completion/Unix/Command/_make') diff --git a/ChangeLog b/ChangeLog index 141f048d4..a2e4d120b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-07-17 Peter Stephenson + + * Jun T: 31525: Completion/Unix/Command/_make: fix some option + handling. + 2013-07-12 Peter Stephenson * Nick Cross: 31512: Completion/Unix/Command/_make: diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make index 5dd0a21a4..355c68e13 100644 --- a/Completion/Unix/Command/_make +++ b/Completion/Unix/Command/_make @@ -160,7 +160,7 @@ _make() { incl="(-|)include" option_specs=( {-B,--always-make}'[Unconditionally make all targets]' - {-C,--directory=}'[change directory first]:directory:->dir' + '*'{-C,--directory=}'[change directory first]:directory:->dir' '-d[Print lots of debug information]' '--debug=-[Print various types of debug information]:FLAGS' {-e,--environment-overrides}'[Environment variables override makefiles]' @@ -168,13 +168,13 @@ _make() { {-f,--file=,--makefile=}'[Read FILE as a makefile]:file:->file' '-h[Print this message and exit]' {-i,--ignore-errors}'[Ignore errors from recipes]' - {-I,--include-dir=}'[Search DIRECTORY for included makefiles]:directory:->dir' + '*'{-I,--include-dir=}'[Search DIRECTORY for included makefiles]:directory:->dir' {-j,--jobs=}'[Allow N jobs at once; infinite jobs with no arg]:number of jobs' {-k,--keep-going}"[Keep going when some targets can't be made]" {-l,--load-average=,--max-load}"[Don't start multiple jobs unless load is below N]:load" {-L,--check-symlink-times}'[Use the latest mtime between symlinks and target]' {-n,--just-print,--dry-run,--recon}"[Don't actually run any recipe; just print them]" - {-o,--old-file=,--assume-old=}"[Consider FILE to be very old and don't remake it]:file not to remake:->file" + '*'{-o,--old-file=,--assume-old=}"[Consider FILE to be very old and don't remake it]:file not to remake:->file" {-p,--print-data-base}'[Print makes internal database]' {-q,--question}'[Run no recipe; exit status says if up to date]' {-r,--no-builtin-rules}'[Disable the built-in implicit rules]' @@ -185,7 +185,7 @@ _make() { {-v,--version}'[Print the version number of make and exit]' {-w,--print-directory}'[Print the current directory]' '--no-print-directory[Turn off -w, even if it was turned on implicitly]' - {-W,--what-if=,--new-file=,--asume-new=}'[Consider FILE to be infinitely new]:file to treat as modified:->file' + '*'{-W,--what-if=,--new-file=,--asume-new=}'[Consider FILE to be infinitely new]:file to treat as modified:->file' '--warn-undefined-variables[Warn when an undefined variable is referenced]' '--warn-undefined-functions[Warn when an undefined user function is called]' ) -- cgit v1.2.3 From c5d9abc6c8f818a3823c70696e412c4496f6a5be Mon Sep 17 00:00:00 2001 From: Jun T Date: Thu, 25 Jul 2013 01:14:22 +0900 Subject: 31756: further make completion improvements. ake care of mutually exclusive options. Add _description using $state_descr. Add completions for --debug=flag. Fix typo (pointed out by Daniel Shahaf). --- ChangeLog | 5 +++ Completion/Unix/Command/_make | 76 +++++++++++++++++++++++++------------------ 2 files changed, 49 insertions(+), 32 deletions(-) (limited to 'Completion/Unix/Command/_make') diff --git a/ChangeLog b/ChangeLog index 913585d06..289b61120 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2013-07-25 Peter Stephenson + * Jun T.: 31756: Completion/Unix/Command/_make: further make + completion improvements: tke care of mutually exclusive options; + add _description using $state_descr; add completions for + --debug=flag; fix typo (pointed out by Daniel Shahaf). + * 31574: Src/parse.c: alternative fix to 31545 if FD_CLOEXEC is not available, removing dump records more consistently. diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make index 355c68e13..0c5371dad 100644 --- a/Completion/Unix/Command/_make +++ b/Completion/Unix/Command/_make @@ -148,7 +148,7 @@ _make-findBasedir () { _make() { local prev="$words[CURRENT-1]" file expl tmp is_gnu dir incl match - local context state line + local context state state_descr line local -a option_specs local -A TARGETS VARIABLES opt_args local ret=1 @@ -159,35 +159,35 @@ _make() { then incl="(-|)include" option_specs=( - {-B,--always-make}'[Unconditionally make all targets]' - '*'{-C,--directory=}'[change directory first]:directory:->dir' - '-d[Print lots of debug information]' - '--debug=-[Print various types of debug information]:FLAGS' - {-e,--environment-overrides}'[Environment variables override makefiles]' - '--eval=-[Evaluate STRING as a makefile statement]:STRING' - {-f,--file=,--makefile=}'[Read FILE as a makefile]:file:->file' - '-h[Print this message and exit]' - {-i,--ignore-errors}'[Ignore errors from recipes]' - '*'{-I,--include-dir=}'[Search DIRECTORY for included makefiles]:directory:->dir' - {-j,--jobs=}'[Allow N jobs at once; infinite jobs with no arg]:number of jobs' - {-k,--keep-going}"[Keep going when some targets can't be made]" - {-l,--load-average=,--max-load}"[Don't start multiple jobs unless load is below N]:load" - {-L,--check-symlink-times}'[Use the latest mtime between symlinks and target]' - {-n,--just-print,--dry-run,--recon}"[Don't actually run any recipe; just print them]" - '*'{-o,--old-file=,--assume-old=}"[Consider FILE to be very old and don't remake it]:file not to remake:->file" - {-p,--print-data-base}'[Print makes internal database]' - {-q,--question}'[Run no recipe; exit status says if up to date]' - {-r,--no-builtin-rules}'[Disable the built-in implicit rules]' - {-R,--no-builtin-variables}'[Disable the built-in variable settings]' - {-s,--silent,--quiet}"[Don't echo recipes]" - {-S,--no-keep-going,--stop}'[Turns off -k]' - {-t,--touch}'[Touch targets instead of remaking them]' - {-v,--version}'[Print the version number of make and exit]' - {-w,--print-directory}'[Print the current directory]' - '--no-print-directory[Turn off -w, even if it was turned on implicitly]' - '*'{-W,--what-if=,--new-file=,--asume-new=}'[Consider FILE to be infinitely new]:file to treat as modified:->file' - '--warn-undefined-variables[Warn when an undefined variable is referenced]' - '--warn-undefined-functions[Warn when an undefined user function is called]' + '(-B --always-make)'{-B,--always-make}'[unconditionally make all targets]' + '*'{-C,--directory=}'[change directory first]:change to directory:->dir' + '-d[print lots of debug information]' + '--debug=-[print various types of debug information]:debug options:->debug' + '(-e --environment-overrides)'{-e,--environment-overrides}'[environment variables override makefiles]' + '--eval=-[evaluate STRING as a makefile statement]:STRING' + '(-f --file --makefile)'{-f,--file=,--makefile=}'[read FILE as a makefile]:makefile:->file' + '(- *)'{-h,--help}'[print help message and exit]' + '(-i --ignore-errors)'{-i,--ignore-errors}'[ignore errors from recipes]' + '*'{-I,--include-dir=}'[search DIRECTORY for included makefiles]:search path for included makefile:->dir' + '(-j --jobs)'{-j,--jobs=}'[allow N jobs at once; infinite jobs with no arg]:number of jobs' + '(-k --keep-going)'{-k,--keep-going}"[keep going when some targets can't be made]" + '(-l --load-average --max-load)'{-l,--load-average=,--max-load}"[don't start multiple jobs unless load is below N]:load" + '(-L --check-symlik-times)'{-L,--check-symlink-times}'[use the latest mtime between symlinks and target]' + '(-n --just-print --dry-run --recon)'{-n,--just-print,--dry-run,--recon}"[don't actually run any recipe; just print them]" + '*'{-o,--old-file=,--assume-old=}"[consider FILE to be very old and don't remake it]:file not to remake:->file" + '(-p --print-data-base)'{-p,--print-data-base}'[print makes internal database]' + '(-q --question)'{-q,--question}'[run no recipe; exit status says if up to date]' + '(-r --no-builtin-rules)'{-r,--no-builtin-rules}'[disable the built-in implicit rules]' + '(-R --no-builtin-variables)'{-R,--no-builtin-variables}'[disable the built-in variable settings]' + '(-s --silent --quiet)'{-s,--silent,--quiet}"[don't echo recipes]" + '(-S --no-keep-going --stop)'{-S,--no-keep-going,--stop}'[turns off -k]' + '(-t --touch)'{-t,--touch}'[touch targets instead of remaking them]' + '(- *)'{-v,--version}'[print the version number of make and exit]' + '(-w --print-directory)'{-w,--print-directory}'[print the current directory]' + '--no-print-directory[turn off -w, even if it was turned on implicitly]' + '*'{-W,--what-if=,--new-file=,--assume-new=}'[consider FILE to be infinitely new]:file to treat as modified:->file' + '--warn-undefined-variables[warn when an undefined variable is referenced]' + '--warn-undefined-functions[warn when an undefined user function is called]' ) else # Basic make options only. @@ -206,11 +206,23 @@ _make() { case $state in (dir) - _files -W ${(q)$(_make-findBasedir ${words[1,CURRENT-1]})} -/ && ret=0 + _description directories expl "$state_descr" + _files "$expl[@]" -W ${(q)$(_make-findBasedir ${words[1,CURRENT-1]})} -/ && ret=0 ;; (file) - _files -W ${(q)$(_make-findBasedir $words)} && ret=0 + _description files expl "$state_descr" + _files "$expl[@]" -W ${(q)$(_make-findBasedir $words)} && ret=0 + ;; + + (debug) + _values -s , 'debug options' \ + '(b v i j m)a[all debugging output]' \ + 'b[basic debugging output]' \ + '(b)v[one level above basic]' \ + '(b)i[describe implicit rule searches (implies b)]' \ + 'j[show details on invocation of subcommands]' \ + 'm[enable debugging while remaking makefiles]' && ret=0 ;; (target) -- cgit v1.2.3 From 1a4730b8eecc8f0b098203d79b787799770da179 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 29 Aug 2013 10:46:52 +0100 Subject: based on 31641, 31642: completion for more make variants --- ChangeLog | 5 +++++ Completion/Unix/Command/_make | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'Completion/Unix/Command/_make') diff --git a/ChangeLog b/ChangeLog index 8f594b45b..77c1991f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-08-29 Peter Stephenson + + * based on 31641, 31642: Completion/Unix/Command/_make: support + a couple of different variants of make. + 2013-08-26 Peter Stephenson * 31672: Src/Modules/zpty.c, Test/V08zpty.ztst: add test that diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make index 0c5371dad..7b4c22466 100644 --- a/Completion/Unix/Command/_make +++ b/Completion/Unix/Command/_make @@ -1,4 +1,4 @@ -#compdef make gmake pmake dmake +#compdef make gmake pmake dmake freebsd-make bmake # TODO: Based on targets given on the command line, show only variables that # are used in those targets and their dependencies. -- cgit v1.2.3 From 87c482d751b9c8211974352139cf7fedb9797f5f Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Fri, 18 Oct 2013 08:35:22 -0700 Subject: 31840: "read" needs IFS unset to avoid stripping whitespace in makefiles --- ChangeLog | 4 ++++ Completion/Unix/Command/_make | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'Completion/Unix/Command/_make') diff --git a/ChangeLog b/ChangeLog index 9bcf6913c..84fa900ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-10-18 Barton E. Schaefer + + * 31840: Completion/Unix/Command/_make: "read" used wrong $IFS + 2013-10-17 Barton E. Schaefer * 31836 (cf. 31823): Doc/Zsh/params.yo, Src/hist.c: add diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make index 7b4c22466..e5a513f64 100644 --- a/Completion/Unix/Command/_make +++ b/Completion/Unix/Command/_make @@ -59,7 +59,7 @@ _make-expandVars() { } _make-parseMakefile () { - local input var val target dep TAB=$'\t' dir=$1 tmp + local input var val target dep TAB=$'\t' dir=$1 tmp IFS= while read input do -- cgit v1.2.3