mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-08 12:01:21 +02:00
users/17856: rewrite _make to use _arguments.
No new option handling yet, but this should make it easier to add.
This commit is contained in:
parent
669c070efe
commit
7e17ea8016
2 changed files with 39 additions and 10 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2013-07-11 Peter Stephenson <p.stephenson@samsung.com>
|
||||||
|
|
||||||
|
* users/17856: Completion/Command/Unix/_make: rewrite to use
|
||||||
|
_arguments so as to make adding option handling easier.
|
||||||
|
|
||||||
2013-07-03 Peter Stephenson <p.stephenson@samsung.com>
|
2013-07-03 Peter Stephenson <p.stephenson@samsung.com>
|
||||||
|
|
||||||
* 31503: Doc/Zsh/contrib.yo, Functions/Misc/zmv: split words
|
* 31503: Doc/Zsh/contrib.yo, Functions/Misc/zmv: split words
|
||||||
|
|
|
@ -148,7 +148,9 @@ _make-findBasedir () {
|
||||||
_make() {
|
_make() {
|
||||||
|
|
||||||
local prev="$words[CURRENT-1]" file expl tmp is_gnu dir incl match
|
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
|
local ret=1
|
||||||
|
|
||||||
_pick_variant -r is_gnu gnu=GNU unix -v -f
|
_pick_variant -r is_gnu gnu=GNU unix -v -f
|
||||||
|
@ -156,21 +158,43 @@ _make() {
|
||||||
if [[ $is_gnu == gnu ]]
|
if [[ $is_gnu == gnu ]]
|
||||||
then
|
then
|
||||||
incl="(-|)include"
|
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
|
else
|
||||||
|
# Basic make options only.
|
||||||
incl=.include
|
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
|
fi
|
||||||
|
|
||||||
if [[ "$prev" == -[CI] ]]
|
_arguments -s $option_specs \
|
||||||
then
|
'*:make target:->target' && ret=0
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
(dir)
|
||||||
_files -W ${(q)$(_make-findBasedir ${words[1,CURRENT-1]})} -/ && ret=0
|
_files -W ${(q)$(_make-findBasedir ${words[1,CURRENT-1]})} -/ && ret=0
|
||||||
elif [[ "$prev" == -[foW] ]]
|
;;
|
||||||
then
|
|
||||||
|
(file)
|
||||||
_files -W ${(q)$(_make-findBasedir $words)} && ret=0
|
_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
|
then
|
||||||
file=${~words[file+1]}
|
|
||||||
[[ $file == [^/]* ]] && file=${(q)$(_make-findBasedir $words)}/$file
|
[[ $file == [^/]* ]] && file=${(q)$(_make-findBasedir $words)}/$file
|
||||||
[[ -r $file ]] || file=
|
[[ -r $file ]] || file=
|
||||||
else
|
else
|
||||||
|
@ -222,7 +246,7 @@ _make() {
|
||||||
compadd -S '=' -- ${(k)VARIABLES} && ret=0
|
compadd -S '=' -- ${(k)VARIABLES} && ret=0
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
esac
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue