Bug 98639 - zsh tab completion for pasuspender suggests -C (and other enhancements for pasuspender tab completion)
Summary: zsh tab completion for pasuspender suggests -C (and other enhancements for pa...
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: Other All
: medium enhancement
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
Depends on:
Reported: 2016-11-08 11:37 UTC by pseyfert
Modified: 2016-11-14 14:31 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:

updated tab completion for pasuspender (2.07 KB, patch)
2016-11-08 11:37 UTC, pseyfert
Details | Splinter Review

Description pseyfert 2016-11-08 11:37:44 UTC
Created attachment 127833 [details] [review]
updated tab completion for pasuspender

zsh tabcompletion of pasuspender suggests -C although -C is supposed to be an option for _arguments and not a suggestion for pasuspender.

The fix is trivial by reordering
-    _arguments -S -A "-*" -C \
+    _arguments -C -S -A "-*" \

(the other completions in _pulseaudio already have the option in this order).

Additional suggestions for pasuspender:

The current completion keeps suggesting options, even if they won't do anyhting, e.g.
pasuspender --help --v<tab>
will suggest --version.
This can be removed by adding '(-)' at the beginning of the argument.

As enhancement one can add "--" to the suggestions and afterwards switch to standard tab completion to suggest programs and their completion. Here it gets tricky as "--" should not get suggested after "--help" or "--version" but it should get suggested after "--server=<hostname>".

patch attached.
Comment 1 Tanu Kaskinen 2016-11-10 16:00:49 UTC
Thanks! I applied the patch to the "next" branch.
Comment 2 pseyfert 2016-11-12 22:05:29 UTC
Urgh, I realized the function can be written easier, without the ugly shift counting:

_pasuspender_completion() {
    # parenthesis expressions specify which options should not get suggested afterwards
    # e.g. after -s, help and version will not get suggested, -- remains the only valid argument
    # after "--" external commands get suggested
    _arguments -C \
        '(-)'{-h,--help}'[display help and exit]' \
        '(-)--version[show version and exit]' \
        '(-h --help --version -s --server)'{-s,--server=}'[name of server to connect to]:host:_hosts' \
        '(-)--[program]:program: _command_names -e:*::program arguments: _normal'
Comment 3 Tanu Kaskinen 2016-11-14 14:31:06 UTC
Would you like to send another patch?

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.