shell-completion: zsh: Don't use multiple option sets for one command

The options were divided to multiple sets to prevent (or at least try
to prevent) completing e.g. --server after -s was already given. This,
however, caused problems, because after the user had written
"pactl --server foo", further completions stopped to work. The
"server" option set didn't contain any other options, so once Zsh
detected that the "server" option set was in use, it thought that no
other options were valid.

The special casing for "-s", "-n", "--server" and "--client-*" at the
end of _pactl_completion() was probably an attempt to deal with this
problem. Those special cases are unnecessary now that the option
specification given to _arguments is more correct.
This commit is contained in:
Tanu Kaskinen 2014-08-16 14:48:17 +03:00
parent 74c724db05
commit cd3cae9285

View file

@ -276,14 +276,11 @@ _pactl_completion() {
)
_arguments -C \
- '(help)' \
{-h,--help}'[display help and exit]' \
{-h,--help}'[display help and exit]' \
'--version[show version and exit]' \
- '(server)' \
{-s,--server}'[name of server to connect to]:host:_hosts' \
- '(name)' \
{-n,--client-name}'[client name to use]:name' \
'::pactl commands:_pactl_command' \
{-s,--server}'[name of server to connect to]:host:_hosts' \
{-n,--client-name}'[client name to use]:name' \
'::pactl command:_pactl_command'
case $words[$((CURRENT - 1))] in
list) _describe 'pactl list commands' _pactl_list_commands;;
@ -307,8 +304,6 @@ _pactl_completion() {
suspend-*) compadd true false;;
list) compadd short;;
move-*) _devices;;
'-s' | '-n') _pactl_command;;
--server | --client-*) _pactl_command;;
esac
}
@ -375,8 +370,7 @@ _pacmd_completion() {
}
_arguments -C \
- '(help)' \
{-h,--help}'[display help and exit]' \
{-h,--help}'[display help and exit]' \
'--version[show version and exit]' \
'::pacmd commands:_pacmd_command' \