1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-04 20:40:57 +02:00

44200 (tweaked): Completion: Append to precommands in _normal

This commit is contained in:
Matthew Martin 2019-04-04 18:45:19 -05:00
parent bb790c8f81
commit 5facfd3280
8 changed files with 26 additions and 23 deletions

View file

@ -1,5 +1,12 @@
2019-04-04 Matthew Martin <phy1729@gmail.com> 2019-04-04 Matthew Martin <phy1729@gmail.com>
* 44200 (tweaked): Completion/Base/Core/_normal,
Completion/Linux/Command/_setsid,
Completion/Zsh/Command/_builtin,
Completion/Zsh/Command/_command, Completion/Zsh/Command/_exec,
Completion/Zsh/Command/_precommand, Doc/Zsh/compsys.yo: Append
to precommands in _normal.
* 44199: Completion/Base/Core/_normal: Use zparseopts. * 44199: Completion/Base/Core/_normal: Use zparseopts.
2019-04-01 dana <dana@dana.is> 2019-04-01 dana <dana@dana.is>

View file

@ -1,10 +1,11 @@
#compdef -command-line- #compdef -command-line-
local _comp_command1 _comp_command2 _comp_command local _comp_command1 _comp_command2 _comp_command precommand
local -A opts local -A opts
zparseopts -A opts -D - s zparseopts -A opts -D - p+:-=precommand s
(( $+opts[-s] )) || _compskip= (( $+opts[-s] )) || _compskip=
(( $#precommand )) && precommands+=(${precommand#-p})
# Check for a history reference to complete modifiers. # Check for a history reference to complete modifiers.
# $PREFIX has a quoted form of the !, so we can't test that # $PREFIX has a quoted form of the !, so we can't test that

View file

@ -1,7 +1,5 @@
#compdef setsid #compdef setsid
[[ $service == setsid ]] && precommands+=( setsid )
_arguments -s -S -A '-*' : \ _arguments -s -S -A '-*' : \
'(: * -)'{-h,--help}'[display help information]' \ '(: * -)'{-h,--help}'[display help information]' \
'(: * -)'{-V,--version}'[display version information]' \ '(: * -)'{-V,--version}'[display version information]' \
@ -9,4 +7,4 @@ _arguments -s -S -A '-*' : \
'(-f --fork)'{-f,--fork}'[always fork]' \ '(-f --fork)'{-f,--fork}'[always fork]' \
'(-w --wait)'{-w,--wait}'[wait for program to exit, and use same return code]' \ '(-w --wait)'{-w,--wait}'[wait for program to exit, and use same return code]' \
'1: :_path_commands' \ '1: :_path_commands' \
'*:: : _normal' '*:: : _normal -p $service'

View file

@ -1,11 +1,9 @@
#compdef builtin #compdef builtin
precommands+=(builtin)
if (( $CURRENT > 2 )); then if (( $CURRENT > 2 )); then
shift words shift words
(( CURRENT -- )) (( CURRENT -- ))
_normal _normal -p $service
else else
local expl local expl

View file

@ -1,11 +1,8 @@
#compdef command #compdef command
# indicate if this is a precommand modifier
[[ $service = command ]] && precommands+=(command)
_arguments \ _arguments \
'-v[indicate result of command search]:*:command:_path_commands' \ '-v[indicate result of command search]:*:command:_path_commands' \
'-V[show result of command search in verbose form]:*:command:_path_commands' \ '-V[show result of command search in verbose form]:*:command:_path_commands' \
'(-)-p[use default PATH to find command]' \ '(-)-p[use default PATH to find command]' \
':command:_path_commands' \ ':command:_path_commands' \
'*::arguments: _normal' '*:: : _normal -p $service'

View file

@ -1,9 +1,7 @@
#compdef exec #compdef exec
[[ $service == exec ]] && precommands+=( exec )
_arguments -s -S -A '-*' : \ _arguments -s -S -A '-*' : \
'-a+[set argv\[0\] to specified string]:argv[0] string' \ '-a+[set argv\[0\] to specified string]:argv[0] string' \
'-c[clear environment]' \ '-c[clear environment]' \
'-l[simulate login shell (prepend - to argv\[0\])]' \ '-l[simulate login shell (prepend - to argv\[0\])]' \
'*:: : _normal' '*:: : _normal -p $service'

View file

@ -1,9 +1,6 @@
#compdef - nohup eval time rusage noglob nocorrect catchsegv aoss hilite eatmydata #compdef - nohup eval time rusage noglob nocorrect catchsegv aoss hilite eatmydata
# precommands is made local in _main_complete
precommands+=($words[1])
shift words shift words
(( CURRENT-- )) (( CURRENT-- ))
_normal _normal -p $service

View file

@ -4658,7 +4658,7 @@ fi
return ret) return ret)
) )
findex(_normal) findex(_normal)
item(tt(_normal))( item(tt(_normal) [ tt(-p) var(precommand) ])(
This is the standard function called to handle completion outside This is the standard function called to handle completion outside
any special tt(-)var(context)tt(-). It is called both to complete the command any special tt(-)var(context)tt(-). It is called both to complete the command
word and also the arguments for a command. In the second case, word and also the arguments for a command. In the second case,
@ -4668,10 +4668,17 @@ there is none it uses the completion for the tt(-default-) context.
A second use is to reexamine the command line specified by the tt($words) A second use is to reexamine the command line specified by the tt($words)
array and the tt($CURRENT) parameter after those have been modified. array and the tt($CURRENT) parameter after those have been modified.
For example, the function tt(_precommand), which For example, the function tt(_precommand), which
completes after pre-command specifiers such as tt(nohup), removes the completes after precommand specifiers such as tt(nohup), removes the
first word from the tt(words) array, decrements the tt(CURRENT) parameter, first word from the tt(words) array, decrements the tt(CURRENT) parameter,
then calls tt(_normal) again. The effect is that `tt(nohup) var(cmd ...)' then calls `tt(_normal -p $service)'. The effect is that
is treated in the same way as `var(cmd ...)'. `tt(nohup) var(cmd ...)' is treated in the same way as `var(cmd ...)'.
startitem()
item(tt(-p) var(precommand))(
Append var(precommand) to the list of precommands. This option should be
used in nearly all cases.
)
enditem()
If the command name matches one of the patterns given by one of the If the command name matches one of the patterns given by one of the
options tt(-p) or tt(-P) to tt(compdef), the corresponding completion options tt(-p) or tt(-P) to tt(compdef), the corresponding completion