Ack first argument is file if --match used
Complete all non-option arguments as file names if the --match argument is present.
This commit is contained in:
parent
adf4e09e0a
commit
7b12d0beaa
20
src/_ack
20
src/_ack
|
@ -43,7 +43,9 @@
|
||||||
|
|
||||||
|
|
||||||
_ack() {
|
_ack() {
|
||||||
local curcontext="$curcontext" state line cmds update_policy ret=1
|
local context curcontext="$curcontext" state line cmds update_policy ret=1
|
||||||
|
integer NORMARG
|
||||||
|
typeset -A opt_args
|
||||||
|
|
||||||
zstyle -s ":completion:${curcontext}:" cache-policy update_policy
|
zstyle -s ":completion:${curcontext}:" cache-policy update_policy
|
||||||
[[ -z "$update_policy" ]] && zstyle ":completion:${curcontext}:" cache-policy _ack_types_caching_policy
|
[[ -z "$update_policy" ]] && zstyle ":completion:${curcontext}:" cache-policy _ack_types_caching_policy
|
||||||
|
@ -54,7 +56,7 @@ _ack() {
|
||||||
[[ $#_ack_raw_types -gt 0 ]] && _store_cache "ack-grep" _ack_raw_types
|
[[ $#_ack_raw_types -gt 0 ]] && _store_cache "ack-grep" _ack_raw_types
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_arguments -C -s -S \
|
_arguments -C -s -S -n \
|
||||||
'(- 1 *)--version[display version and copyright information]' \
|
'(- 1 *)--version[display version and copyright information]' \
|
||||||
'(- 1 *)--help[print a short help statement]' \
|
'(- 1 *)--help[print a short help statement]' \
|
||||||
'(- 1 *)--man[print the manual page]' \
|
'(- 1 *)--man[print the manual page]' \
|
||||||
|
@ -111,13 +113,19 @@ _ack() {
|
||||||
'(-w --word-regexp)'{-w,--word-regexp}'[force the given pattern to match only whole words]' \
|
'(-w --word-regexp)'{-w,--word-regexp}'[force the given pattern to match only whole words]' \
|
||||||
'-1[stops after reporting first match of any kind]' \
|
'-1[stops after reporting first match of any kind]' \
|
||||||
{'--','--no'}${_ack_raw_types/ ##/\[}']' \
|
{'--','--no'}${_ack_raw_types/ ##/\[}']' \
|
||||||
'1: :->patterns' \
|
'*: :->args' \
|
||||||
'*: :_files' \
|
|
||||||
&& ret=0
|
&& ret=0
|
||||||
|
|
||||||
case $state in
|
case $state in
|
||||||
patterns)
|
args)
|
||||||
_message -e patterns 'pattern' && ret=0
|
if [[ CURRENT -eq NORMARG && ${+opt_args[--match]} -eq 0 ]]
|
||||||
|
then
|
||||||
|
# If the current argument is the first non-option argument
|
||||||
|
# and --match isn't present then a pattern is expected
|
||||||
|
_message -e patterns 'pattern' && ret=0
|
||||||
|
else
|
||||||
|
_files
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
colors)
|
colors)
|
||||||
local colors; colors=(
|
local colors; colors=(
|
||||||
|
|
Loading…
Reference in New Issue