1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-02 22:11:54 +02:00

22205: patch from R.Ramkumar to use the argument to -C in make completion.

This commit is contained in:
Clint Adams 2006-02-09 14:51:24 +00:00
parent c80682a850
commit 21fb933522
2 changed files with 44 additions and 10 deletions

View file

@ -1,3 +1,9 @@
2006-02-09 Clint Adams <clint@zsh.org>
* 22205: Completion/Unix/Command/_make: patch from
R.Ramkumar to use the argument to -C in make
completion.
2006-02-07 Wayne Davison <wayned@users.sourceforge.net> 2006-02-07 Wayne Davison <wayned@users.sourceforge.net>
* unposted: Completion/Unix/Command/_rsync: One last new option * unposted: Completion/Unix/Command/_rsync: One last new option

View file

@ -92,6 +92,28 @@ parseMakefile() {
done done
} }
findBasedir () {
local file index basedir
basedir=$PWD
for ((index=0; index<$#@; index++)); do
if [[ $@[index] = -C ]]; then
file=${~@[index+1]};
if [[ -z $file ]]; then
# make returns with an error if an empty arg is given
# even if the concatenated path is a valid directory
return
elif [[ $file = /* ]]; then
# Absolute path, replace base directory
basedir=$file
else
# Relative, concatenate path
basedir=$basedir/$file
fi
fi
done
print -- $basedir
}
_pick_variant -r is_gnu gnu=GNU unix -v -f _pick_variant -r is_gnu gnu=GNU unix -v -f
if [[ $is_gnu = gnu ]]; then if [[ $is_gnu = gnu ]]; then
@ -100,21 +122,27 @@ else
incl=.include incl=.include
fi fi
if [[ "$prev" = -[CI] ]]; then if [[ "$prev" = -[CI] ]]; then
_files -/ _files -W ${(q)$(findBasedir ${words[1,CURRENT-1]})} -/
elif [[ "$prev" = -[foW] ]]; then elif [[ "$prev" = -[foW] ]]; then
_files _files -W ${(q)$(findBasedir $words)}
else else
file="$words[(I)-f]" file="$words[(I)-f]"
if (( file )); then if (( file )); then
file="$words[file+1]" file=${~words[file+1]}
elif [[ -e Makefile ]]; then [[ $file = [^/]* ]] && file=${(q)$(findBasedir $words)}/$file
file=Makefile [[ -r $file ]] || file=
elif [[ -e makefile ]]; then
file=makefile
elif [[ $is_gnu = gnu && -e GNUmakefile ]]; then
file=GNUmakefile
else else
file='' local basedir
basedir=${(q)$(findBasedir $words)}
if [[ $is_gnu = gnu && -r $basedir/GNUmakefile ]]; then
file=$basedir/GNUmakefile
elif [[ -r $basedir/makefile ]]; then
file=$basedir/makefile
elif [[ -r $basedir/Makefile ]]; then
file=$basedir/Makefile
else
file=''
fi
fi fi
if [[ -n "$file" ]] && _tags targets; then if [[ -n "$file" ]] && _tags targets; then