1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-07-23 20:51:02 +02:00

17535: use-perl style for _make

This commit is contained in:
Peter Stephenson 2002-08-14 15:18:19 +00:00
parent fc88981cf7
commit 513088857a
3 changed files with 34 additions and 2 deletions
ChangeLog
Completion/Unix/Command
Doc/Zsh

View file

@ -1,3 +1,8 @@
2002-08-14 Peter Stephenson <pws@csr.com>
* 17535: Completion/Unix/Command/_make, Doc/Zsh/compsys.yo:
use-perl style avoids awk frustration.
2002-08-10 Clint Adams <clint@zsh.org>
* 17206 (Bruno Bonfils), 17207 (Oliver):

View file

@ -1,7 +1,8 @@
#compdef make gmake pmake dmake
local prev="$words[CURRENT-1]" file expl tmp is_gnu
local prev="$words[CURRENT-1]" file expl tmp is_gnu cmdargs useperl
zstyle -t ":completion:${curcontext}:" use-perl && useperl=1
_pick_variant -r is_gnu gnu=GNU unix -v -f
if [[ "$prev" = -[CI] ]]; then
@ -25,7 +26,22 @@ else
if [[ -n "$file" ]] && _tags targets; then
if [[ $is_gnu = gnu ]] &&
zstyle -t ":completion:${curcontext}:targets" call-command; then
tmp=( $(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" .PHONY 2> /dev/null | awk '/^[a-zA-Z0-9][^\/\t=]+:/ {print $1}' FS=:) )
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) )
elif [[ -n $useperl ]]; then
tmp=(
$(perl -ne '@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 deinstall package describe checkpatch checksum makesum\n";
}
' $file)
)
else
tmp=(
$(awk '/^[a-zA-Z0-9][^\/\t=]+:/ {print $1}

View file

@ -2315,6 +2315,17 @@ example, while completing arguments to the command tt(foo), if this was
handled by a command function tt(_foo), tt(compctl) would never be tried,
while if it was handled by tt(_default), tt(compctl) would be tried.
)
kindex(use-perl, completion style)
item(tt(use-perl))(
Various parts of the function system use awk to extract words from
files or command output as this universally available. However, many
versions of awk have arbitrary limits on the size of input. If this
style is set, perl will be used instead. This is almost always
preferable if perl is available on your system.
Currently this is only used in completions for `make', but it may be
extended depending on authorial frustration.
)
kindex(users, completion style)
item(tt(users))(
This may be set to a list of names that should be completed whenever