zsh-workers
 help / color / mirror / code / Atom feed
* Completion for aplay from alsa-utils
@ 2019-11-02 21:13 Sebastian Gniazdowski
  2019-11-03 23:17 ` dana
  0 siblings, 1 reply; 11+ messages in thread
From: Sebastian Gniazdowski @ 2019-11-02 21:13 UTC (permalink / raw)
  To: Zsh hackers list


[-- Attachment #1.1: Type: text/plain, Size: 388 bytes --]

Hello,
the submitted completion is in file _alsa-utils and covers:
- all options of the aplay command, with the =-type options correctly
recognized,
- exclusion lists for the options,
- _file completion for *:… arguments.

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

[-- Attachment #1.2: Type: text/html, Size: 761 bytes --]

[-- Attachment #2: 0001-Completion-for-aplay-from-alsa-utils.patch.txt --]
[-- Type: text/plain, Size: 2986 bytes --]

From 087505538427f58bac1cc8bde90e95614063f206 Mon Sep 17 00:00:00 2001
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Date: Tue, 29 Oct 2019 18:59:46 +0100
Subject: [PATCH] Completion for aplay from alsa-utils

---
 Completion/Linux/Command/_alsa-utils | 54 ++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 Completion/Linux/Command/_alsa-utils

diff --git a/Completion/Linux/Command/_alsa-utils b/Completion/Linux/Command/_alsa-utils
new file mode 100644
index 000000000..e8356b95a
--- /dev/null
+++ b/Completion/Linux/Command/_alsa-utils
@@ -0,0 +1,54 @@
+#compdef aplay
+# Copyright (c) 2019 Sebastian Gniazdowski
+
+setopt localoptions warncreateglobal typesetsilent
+
+local -a opts
+opts=(
+  + '(operation)'
+  {-h,--help}'[print help message]'
+  --version'[print current version]'
+  {-l,--list-devices}'[list all soundcards and digital audio devices]'
+  {-L,--list-pcms}'[list device names]'
+  + option
+  {-D,--device}'[select PCM by name]'
+  {-q,--quiet}'[quiet mode]'
+  {-t,--file-type}'[file type (voc, wav, raw or au)]'
+  {-c,--channels=}'[channels]'
+  {-r,--rate=}'[sample rate]'
+  {-f,--format=}'[sample format (case insensitive)]'
+  {-d,--duration=}'[interrupt after # seconds]'
+  {-s,--samples=}'[interrupt after # samples per channel]'
+  {-M,--mmap}'[mmap stream]'
+  {-N,--nonblock}'[nonblocking mode]'
+  {-F,--period-time=}'[distance between interrupts is # microseconds]'
+  {-B,--buffer-time=}'[buffer duration is # microseconds]'
+  --period-size='[distance between interrupts is # frames]'
+  --buffer-size='[buffer duration is # frames]'
+  {-A,--avail-min=}'[min available space for wakeup is # microseconds]'
+  {-R,--start-delay=}'[delay for automatic PCM start is # microseconds]'
+  {-T,--stop-delay=}'[delay for automatic PCM stop is # microseconds from xrun]'
+  {-v,--verbose}'[show PCM structure and setup (accumulative)]'
+  {-V,--vumeter=}'[enable VU meter (TYPE: mono or stereo)]'
+  {-I,--separate-channels}'[file for each channel]'
+  {-i,--interactive}'[allow interactive operation from stdin]'
+  {-m,--chmap=}'[give the channel map to override or follow]'
+  --disable-resample'[disable automatic rate resample]'
+  --disable-channels'[disable automatic channel conversions]'
+  --disable-format'[disable automatic format conversions]'
+  --disable-softvol'[disable software volume control (softvol)]'
+  --test-position'[test ring buffer position]'
+  --test-coef='[test coefficient for ring buffer position (default 8)]'
+  --test-nowait'[do not wait for ring buffer - eats whole CPU]'
+  --max-file-time='[start another output file when the old file has recorded]'
+  --process-id-file'[write the process ID here]'
+  --use-strftime'[apply the strftime facility to the output file name]'
+  --dump-hw-params'[dump hw_params of the device]'
+  --fatal-errors'[treat all errors as fatal]'
+
+  '*:sound file:_files'
+)
+
+_arguments -s $opts
+
+# The return value passes through
-- 
2.21.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Completion for aplay from alsa-utils
  2019-11-02 21:13 Completion for aplay from alsa-utils Sebastian Gniazdowski
@ 2019-11-03 23:17 ` dana
  2019-11-04 10:38   ` Oliver Kiddle
  2019-11-21 23:10   ` Sebastian Gniazdowski
  0 siblings, 2 replies; 11+ messages in thread
From: dana @ 2019-11-03 23:17 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh hackers list

On 2 Nov 2019, at 16:13, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> the submitted completion is in file _alsa-utils

Feels like maybe it should just be called _aplay, unless you think there would
be so much shared code between future alsa-utils completion functions that
they all need to live together in one (not sure but doesn't seem like it)

And you can add arecord to #compdef, since it's basically the same thing as
aplay

Some functional issues i noticed:

* _arguments should have -S

* There are no exclusions for any of the alias options (e.g., -D and --device
  should be exclusive)

* --device, --file-type, and --process-id-file should take arguments

* All short aliases of long options that take an argument should have + (e.g.,
  -c+ for --channels=)

* -v is cumulative, but there is no * in the spec

Would also be nice to have better optarg completion (there are no argument
descriptions, some of the options take pre-defined arguments that are listed
in the documentation that you could offer, &c.), and taking the option
descriptions from the help output verbatim doesn't look that nice here, but
i'm probably being too pedantic now

dana


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Completion for aplay from alsa-utils
  2019-11-03 23:17 ` dana
@ 2019-11-04 10:38   ` Oliver Kiddle
  2019-11-21 23:10   ` Sebastian Gniazdowski
  1 sibling, 0 replies; 11+ messages in thread
From: Oliver Kiddle @ 2019-11-04 10:38 UTC (permalink / raw)
  To: Sebastian Gniazdowski, Zsh hackers list

dana wrote:
> On 2 Nov 2019, at 16:13, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> > the submitted completion is in file _alsa-utils
>
> Feels like maybe it should just be called _aplay, unless you think there would
> be so much shared code between future alsa-utils completion functions that
> they all need to live together in one (not sure but doesn't seem like it)

I don't agree on this point.
There often is shared code between utilities that come from the same
source. As you even point out, arecord takes essentially the same set of
options. And _alsa-utils makes it clearer where aplay comes from if it
isn't clear. We've also got plenty of existing functions where naming
matches to package or source rather than the command. It can also make
it easier to handle name clashes if a different aplay turns up.

Oliver

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Completion for aplay from alsa-utils
  2019-11-03 23:17 ` dana
  2019-11-04 10:38   ` Oliver Kiddle
@ 2019-11-21 23:10   ` Sebastian Gniazdowski
  2019-11-22  3:05     ` dana
  2019-11-22 15:17     ` Eric Cook
  1 sibling, 2 replies; 11+ messages in thread
From: Sebastian Gniazdowski @ 2019-11-21 23:10 UTC (permalink / raw)
  To: dana; +Cc: Zsh hackers list

On Mon, 4 Nov 2019 at 00:17, dana <dana@dana.is> wrote:
>
> On 2 Nov 2019, at 16:13, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> > the submitted completion is in file _alsa-utils

Thanks for the review.

> And you can add arecord to #compdef, since it's basically the same thing as
> aplay

True, diff on help messages reveals no differences.

> Some functional issues i noticed:
>
> * _arguments should have -S
>
> * There are no exclusions for any of the alias options (e.g., -D and --device
>   should be exclusive)

How to add them?

> * --device, --file-type, and --process-id-file should take arguments

--file-type and --process-id-file take arguments without =. How to add
arguments to their spec, should it be +?

> * All short aliases of long options that take an argument should have + (e.g.,
>   -c+ for --channels=)
>
> * -v is cumulative, but there is no * in the spec

What do you mean?

> Would also be nice to have better optarg completion (there are no argument
> descriptions, some of the options take pre-defined arguments that are listed
> in the documentation that you could offer, &c.), and taking the option
> descriptions from the help output verbatim doesn't look that nice here, but
> i'm probably being too pedantic now

I think that editing of the descriptions provided the number of
options is large would be quite artificial. I mean I could express a
few options by my own words, however on long term I would have to drop
this because it would be an overwhelming task.

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Completion for aplay from alsa-utils
  2019-11-21 23:10   ` Sebastian Gniazdowski
@ 2019-11-22  3:05     ` dana
  2019-11-25 10:16       ` Sebastian Gniazdowski
  2019-11-22 15:17     ` Eric Cook
  1 sibling, 1 reply; 11+ messages in thread
From: dana @ 2019-11-22  3:05 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh hackers list

On 21 Nov 2019, at 17:10, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> > * There are no exclusions for any of the alias options (e.g., -D and --device
> > should be exclusive)
>
> How to add them?

'(-D --device)' (or whatever) at the beginning of the arg spec

On 21 Nov 2019, at 17:10, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> --file-type and --process-id-file take arguments without =. How to add
> arguments to their spec, should it be +?

I don't know why they're formatted differently in the help output, but AFAICT
they're all the same, they all use the normal getopt_long() syntax for options
with arguments

On 21 Nov 2019, at 17:10, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> > * -v is cumulative, but there is no * in the spec
>
> What do you mean?

-v can be supplied multiple times, which your description mentions, but
without a * near the beginning of the arg spec it will only be completed once
at most

The spec syntax is described under the _arguments section in zshcompsys, if
you're unfamiliar

dana


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Completion for aplay from alsa-utils
  2019-11-21 23:10   ` Sebastian Gniazdowski
  2019-11-22  3:05     ` dana
@ 2019-11-22 15:17     ` Eric Cook
  2019-11-25  9:27       ` Sebastian Gniazdowski
  1 sibling, 1 reply; 11+ messages in thread
From: Eric Cook @ 2019-11-22 15:17 UTC (permalink / raw)
  To: zsh-workers

On 11/21/19 6:10 PM, Sebastian Gniazdowski wrote:
> I think that editing of the descriptions provided the number of
> options is large would be quite artificial. I mean I could express a
> few options by my own words, however on long term I would have to drop
> this because it would be an overwhelming task.
>

You have created:
- a plugin manager
- a backdoor for executing commands across separately running zsh processes
- a json parser
- a ncurses interface
- a documentation format

And adding descriptions to a completer is the overwhelming task?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Completion for aplay from alsa-utils
  2019-11-22 15:17     ` Eric Cook
@ 2019-11-25  9:27       ` Sebastian Gniazdowski
  0 siblings, 0 replies; 11+ messages in thread
From: Sebastian Gniazdowski @ 2019-11-25  9:27 UTC (permalink / raw)
  To: Eric Cook; +Cc: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 753 bytes --]

Sun., 24 Nov 2019, 23:51 user Eric Cook <llua@gmx.com> wrote:

> You have created:
> - a plugin manager
> - a backdoor for executing commands across separately running zsh processes
> - a json parser
> - a ncurses interface
> - a documentation format
>
> And adding descriptions to a completer is the overwhelming task?
>

I think that yes, it would be. Think rephrasing one sentence in the name of
"not making the work look like if I've just copy-pasted someone's else
text" (as this is what's the topic is about, I suspect). It's fine to do
so. However, after a few next sentences what's this starts to be is "why I
am doing this? isn't it that the authors of the package knew best what the
options are for?" and this IMO quickly starts to overwhelm.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Completion for aplay from alsa-utils
  2019-11-22  3:05     ` dana
@ 2019-11-25 10:16       ` Sebastian Gniazdowski
  2019-11-25 12:10         ` Sebastian Gniazdowski
  0 siblings, 1 reply; 11+ messages in thread
From: Sebastian Gniazdowski @ 2019-11-25 10:16 UTC (permalink / raw)
  To: dana; +Cc: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 813 bytes --]

On Fri, 22 Nov 2019 at 04:05, dana <dana@dana.is> wrote:
>
> On 21 Nov 2019, at 17:10, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> > > * There are no exclusions for any of the alias options (e.g., -D and --device
> > > should be exclusive)
> >
> > How to add them?
>
> '(-D --device)' (or whatever) at the beginning of the arg spec

Thanks. I attach an updated version of the patch. It has problem with
one thing – the cumulative option spec using *:

'(-v --verbose)*'{-v,--verbose}'[show PCM structure and setup (accumulative)]'

doesn't yield the desired effect – the option still cannot be
repeated. I don't know why?

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

[-- Attachment #2: 0001-Completion-for-aplay-from-alsa-utils.patch.2.txt --]
[-- Type: text/plain, Size: 3437 bytes --]

From e890819a3da80b9061aa694959deb7108b78ba6d Mon Sep 17 00:00:00 2001
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Date: Tue, 29 Oct 2019 18:59:46 +0100
Subject: [PATCH] Completion for aplay from alsa-utils

---
 Completion/Linux/Command/_alsa-utils | 54 ++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 Completion/Linux/Command/_alsa-utils

diff --git a/Completion/Linux/Command/_alsa-utils b/Completion/Linux/Command/_alsa-utils
new file mode 100644
index 000000000..75c3a89dd
--- /dev/null
+++ b/Completion/Linux/Command/_alsa-utils
@@ -0,0 +1,54 @@
+#compdef aplay arecord
+# Copyright (c) 2019 Sebastian Gniazdowski
+
+setopt localoptions warncreateglobal typesetsilent
+
+local -a opts
+opts=(
+  + '(operation)'
+  '(-h --help)'{-h,--help}'[print help message]'
+  --version'[print current version]'
+  '(-l --list-devices)'{-l,--list-devices}'[list all soundcards and digital audio devices]'
+  '(-L --list-pcms)'{-L,--list-pcms}'[list device names]'
+  + option
+  '(-D+ --device=)'{-D+,--device=}'[select PCM by name]'
+  '(-q --quiet)'{-q,--quiet}'[quiet mode]'
+  '(-t+ --file-type=)'{-t+,--file-type+}'[file type (voc, wav, raw or au)]'
+  '(-c+ --channels=)'{-c+,--channels=}'[channels]'
+  '(-r+ --rate=)'{-r+,--rate=}'[sample rate]'
+  '(-f+ --format=)'{-f+,--format=}'[sample format (case insensitive)]'
+  '(-d+ --duration=)'{-d+,--duration=}'[interrupt after # seconds]'
+  '(-s+ --samples=)'{-s+,--samples=}'[interrupt after # samples per channel]'
+  '(-M --mmap)'{-M,--mmap}'[mmap stream]'
+  '(-N --nonblock)'{-N,--nonblock}'[nonblocking mode]'
+  '(-F+ --period-time=)'{-F+,--period-time=}'[distance between interrupts is # microseconds]'
+  '(-B+ --buffer-time=)'{-B+,--buffer-time=}'[buffer duration is # microseconds]'
+  --period-size='[distance between interrupts is # frames]'
+  --buffer-size='[buffer duration is # frames]'
+  '(-A+ --avail-min=)'{-A+,--avail-min=}'[min available space for wakeup is # microseconds]'
+  '(-R+ --start-delay=)'{-R+,--start-delay=}'[delay for automatic PCM start is # microseconds]'
+  '(-T+ --stop-delay=)'{-T+,--stop-delay=}'[delay for automatic PCM stop is # microseconds from xrun]'
+  '(-v --verbose)*'{-v,--verbose}'[show PCM structure and setup (accumulative)]'
+  '(-V+ --vumeter=)'{-V+,--vumeter=}'[enable VU meter (TYPE: mono or stereo)]'
+  '(-I --separate-channels)'{-I,--separate-channels}'[file for each channel]'
+  '(-i --interactive)'{-i,--interactive}'[allow interactive operation from stdin]'
+  '(-m+ --chmap=)'{-m+,--chmap=}'[give the channel map to override or follow]'
+  --disable-resample'[disable automatic rate resample]'
+  --disable-channels'[disable automatic channel conversions]'
+  --disable-format'[disable automatic format conversions]'
+  --disable-softvol'[disable software volume control (softvol)]'
+  --test-position'[test ring buffer position]'
+  --test-coef='[test coefficient for ring buffer position (default 8)]'
+  --test-nowait'[do not wait for ring buffer - eats whole CPU]'
+  --max-file-time='[start another output file when the old file has recorded]'
+  --process-id-file='[write the process ID here]'
+  --use-strftime'[apply the strftime facility to the output file name]'
+  --dump-hw-params'[dump hw_params of the device]'
+  --fatal-errors'[treat all errors as fatal]'
+
+  '*:sound file:_files'
+)
+
+_arguments -sS $opts
+
+# The return value passes through
-- 
2.21.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Completion for aplay from alsa-utils
  2019-11-25 10:16       ` Sebastian Gniazdowski
@ 2019-11-25 12:10         ` Sebastian Gniazdowski
  2019-11-26  2:16           ` dana
  0 siblings, 1 reply; 11+ messages in thread
From: Sebastian Gniazdowski @ 2019-11-25 12:10 UTC (permalink / raw)
  To: dana; +Cc: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 1265 bytes --]

Ok, it has been resolved – the exclusion for -v and --verbose was
causing the repeat-problem. After removing the exclusion, the options
can be repeated.

On Mon, 25 Nov 2019 at 11:16, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> On Fri, 22 Nov 2019 at 04:05, dana <dana@dana.is> wrote:
> >
> > On 21 Nov 2019, at 17:10, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> > > > * There are no exclusions for any of the alias options (e.g., -D and --device
> > > > should be exclusive)
> > >
> > > How to add them?
> >
> > '(-D --device)' (or whatever) at the beginning of the arg spec
>
> Thanks. I attach an updated version of the patch. It has problem with
> one thing – the cumulative option spec using *:
>
> '(-v --verbose)*'{-v,--verbose}'[show PCM structure and setup (accumulative)]'
>
> doesn't yield the desired effect – the option still cannot be
> repeated. I don't know why?
>
> --
> Sebastian Gniazdowski
> News: https://twitter.com/ZdharmaI
> IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
> Blog: http://zdharma.org



-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

[-- Attachment #2: 0001-Completion-for-aplay-from-alsa-utils.patch.3.txt --]
[-- Type: text/plain, Size: 3423 bytes --]

From fb19dbe313d6ef98d546dd972aae9f510c45da10 Mon Sep 17 00:00:00 2001
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Date: Tue, 29 Oct 2019 18:59:46 +0100
Subject: [PATCH] Completion for aplay from alsa-utils

---
 Completion/Linux/Command/_alsa-utils | 54 ++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 Completion/Linux/Command/_alsa-utils

diff --git a/Completion/Linux/Command/_alsa-utils b/Completion/Linux/Command/_alsa-utils
new file mode 100644
index 000000000..a6534592e
--- /dev/null
+++ b/Completion/Linux/Command/_alsa-utils
@@ -0,0 +1,54 @@
+#compdef aplay arecord
+# Copyright (c) 2019 Sebastian Gniazdowski
+
+setopt localoptions warncreateglobal typesetsilent
+
+local -a opts
+opts=(
+  + '(operation)'
+  '(-h --help)'{-h,--help}'[print help message]'
+  --version'[print current version]'
+  '(-l --list-devices)'{-l,--list-devices}'[list all soundcards and digital audio devices]'
+  '(-L --list-pcms)'{-L,--list-pcms}'[list device names]'
+  + option
+  '(-D+ --device=)'{-D+,--device=}'[select PCM by name]'
+  '(-q --quiet)'{-q,--quiet}'[quiet mode]'
+  '(-t+ --file-type=)'{-t+,--file-type+}'[file type (voc, wav, raw or au)]'
+  '(-c+ --channels=)'{-c+,--channels=}'[channels]'
+  '(-r+ --rate=)'{-r+,--rate=}'[sample rate]'
+  '(-f+ --format=)'{-f+,--format=}'[sample format (case insensitive)]'
+  '(-d+ --duration=)'{-d+,--duration=}'[interrupt after # seconds]'
+  '(-s+ --samples=)'{-s+,--samples=}'[interrupt after # samples per channel]'
+  '(-M --mmap)'{-M,--mmap}'[mmap stream]'
+  '(-N --nonblock)'{-N,--nonblock}'[nonblocking mode]'
+  '(-F+ --period-time=)'{-F+,--period-time=}'[distance between interrupts is # microseconds]'
+  '(-B+ --buffer-time=)'{-B+,--buffer-time=}'[buffer duration is # microseconds]'
+  --period-size='[distance between interrupts is # frames]'
+  --buffer-size='[buffer duration is # frames]'
+  '(-A+ --avail-min=)'{-A+,--avail-min=}'[min available space for wakeup is # microseconds]'
+  '(-R+ --start-delay=)'{-R+,--start-delay=}'[delay for automatic PCM start is # microseconds]'
+  '(-T+ --stop-delay=)'{-T+,--stop-delay=}'[delay for automatic PCM stop is # microseconds from xrun]'
+  '*'{-v,--verbose}'[show PCM structure and setup (accumulative)]'
+  '(-V+ --vumeter=)'{-V+,--vumeter=}'[enable VU meter (TYPE: mono or stereo)]'
+  '(-I --separate-channels)'{-I,--separate-channels}'[file for each channel]'
+  '(-i --interactive)'{-i,--interactive}'[allow interactive operation from stdin]'
+  '(-m+ --chmap=)'{-m+,--chmap=}'[give the channel map to override or follow]'
+  --disable-resample'[disable automatic rate resample]'
+  --disable-channels'[disable automatic channel conversions]'
+  --disable-format'[disable automatic format conversions]'
+  --disable-softvol'[disable software volume control (softvol)]'
+  --test-position'[test ring buffer position]'
+  --test-coef='[test coefficient for ring buffer position (default 8)]'
+  --test-nowait'[do not wait for ring buffer - eats whole CPU]'
+  --max-file-time='[start another output file when the old file has recorded]'
+  --process-id-file='[write the process ID here]'
+  --use-strftime'[apply the strftime facility to the output file name]'
+  --dump-hw-params'[dump hw_params of the device]'
+  --fatal-errors'[treat all errors as fatal]'
+
+  '*:sound file:_files'
+)
+
+_arguments -sS $opts
+
+# The return value passes through
-- 
2.21.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Completion for aplay from alsa-utils
  2019-11-25 12:10         ` Sebastian Gniazdowski
@ 2019-11-26  2:16           ` dana
  2019-12-01 21:11             ` Sebastian Gniazdowski
  0 siblings, 1 reply; 11+ messages in thread
From: dana @ 2019-11-26  2:16 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh hackers list

On 25 Nov 2019, at 06:10, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> Ok, it has been resolved – the exclusion for -v and --verbose was
> causing the repeat-problem. After removing the exclusion, the options
> can be repeated.

More things, sry:

> +  '(-h --help)'{-h,--help}'[print help message]'
> +  --version'[print current version]'

Usually options that can't be used together with any other arguments, like
these two, are made fully exclusive via `(: * -)` or similar

> +  '(-D+ --device=)'{-D+,--device=}'[select PCM by name]'

You can't put the +/= syntax in the exclusion thing, it won't match like that.
See my earlier example

> +_arguments -sS $opts

This needs to be `-s -S`, per the documentation i mentioned before:

> Options to _arguments itself must be in separate words, i.e. -s -w, not -sw.

dana


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Completion for aplay from alsa-utils
  2019-11-26  2:16           ` dana
@ 2019-12-01 21:11             ` Sebastian Gniazdowski
  0 siblings, 0 replies; 11+ messages in thread
From: Sebastian Gniazdowski @ 2019-12-01 21:11 UTC (permalink / raw)
  To: dana; +Cc: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 1228 bytes --]

On Tue, 26 Nov 2019 at 03:16, dana <dana@dana.is> wrote:
>
> On 25 Nov 2019, at 06:10, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> > Ok, it has been resolved – the exclusion for -v and --verbose was
> > causing the repeat-problem. After removing the exclusion, the options
> > can be repeated.
>
> More things, sry:
>
> > +  '(-h --help)'{-h,--help}'[print help message]'
> > +  --version'[print current version]'
>
> Usually options that can't be used together with any other arguments, like
> these two, are made fully exclusive via `(: * -)` or similar

Ok

> > +  '(-D+ --device=)'{-D+,--device=}'[select PCM by name]'
>
> You can't put the +/= syntax in the exclusion thing, it won't match like that.
> See my earlier example

Ah yes, this resulted from using a substitution with back-references in vim.

> > +_arguments -sS $opts
>
> This needs to be `-s -S`, per the documentation i mentioned before:
>
> > Options to _arguments itself must be in separate words, i.e. -s -w, not -sw.

All done. Attaching the patch.


-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

[-- Attachment #2: 0001-Completion-for-aplay-from-alsa-utils.patch.4.txt --]
[-- Type: text/plain, Size: 3418 bytes --]

From fdd014c6334d8ad256892372d22b748e4dab806d Mon Sep 17 00:00:00 2001
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Date: Tue, 29 Oct 2019 18:59:46 +0100
Subject: [PATCH] Completion for aplay from alsa-utils

---
 Completion/Linux/Command/_alsa-utils | 54 ++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 Completion/Linux/Command/_alsa-utils

diff --git a/Completion/Linux/Command/_alsa-utils b/Completion/Linux/Command/_alsa-utils
new file mode 100644
index 000000000..15d8fb444
--- /dev/null
+++ b/Completion/Linux/Command/_alsa-utils
@@ -0,0 +1,54 @@
+#compdef aplay arecord
+# Copyright (c) 2019 Sebastian Gniazdowski
+
+setopt localoptions warncreateglobal typesetsilent
+
+local -a opts
+opts=(
+  '(- : *)'{-h,--help}'[print help message]'
+  '(- : *)'--version'[print current version]'
+  # -l/--list-devices doesn't benefit from -v/--verbose
+  '(- : *)'{-l,--list-devices}'[list all soundcards and digital audio devices]'
+
+  '(-L --list-pcms)'{-L,--list-pcms}'[list device names]'
+  '(-D --device)'{-D+,--device=}'[select PCM by name]'
+  '(-q --quiet)'{-q,--quiet}'[quiet mode]'
+  '(-t --file-type)'{-t+,--file-type+}'[file type (voc, wav, raw or au)]'
+  '(-c --channels)'{-c+,--channels=}'[channels]'
+  '(-r --rate)'{-r+,--rate=}'[sample rate]'
+  '(-f --format)'{-f+,--format=}'[sample format (case insensitive)]'
+  '(-d --duration)'{-d+,--duration=}'[interrupt after # seconds]'
+  '(-s --samples)'{-s+,--samples=}'[interrupt after # samples per channel]'
+  '(-M --mmap)'{-M,--mmap}'[mmap stream]'
+  '(-N --nonblock)'{-N,--nonblock}'[nonblocking mode]'
+  '(-F --period-time)'{-F+,--period-time=}'[distance between interrupts is # microseconds]'
+  '(-B --buffer-time)'{-B+,--buffer-time=}'[buffer duration is # microseconds]'
+  --period-size='[distance between interrupts is # frames]'
+  --buffer-size='[buffer duration is # frames]'
+  '(-A --avail-min)'{-A+,--avail-min=}'[min available space for wakeup is # microseconds]'
+  '(-R --start-delay)'{-R+,--start-delay=}'[delay for automatic PCM start is # microseconds]'
+  '(-T --stop-delay)'{-T+,--stop-delay=}'[delay for automatic PCM stop is # microseconds from xrun]'
+  '*'{-v,--verbose}'[show PCM structure and setup (accumulative)]'
+  '(-V --vumeter)'{-V+,--vumeter=}'[enable VU meter (TYPE: mono or stereo)]'
+  '(-I --separate-channels)'{-I,--separate-channels}'[file for each channel]'
+  '(-i --interactive)'{-i,--interactive}'[allow interactive operation from stdin]'
+  '(-m --chmap)'{-m+,--chmap=}'[give the channel map to override or follow]'
+  --disable-resample'[disable automatic rate resample]'
+  --disable-channels'[disable automatic channel conversions]'
+  --disable-format'[disable automatic format conversions]'
+  --disable-softvol'[disable software volume control (softvol)]'
+  --test-position'[test ring buffer position]'
+  --test-coef='[test coefficient for ring buffer position (default 8)]'
+  --test-nowait'[do not wait for ring buffer - eats whole CPU]'
+  --max-file-time='[start another output file when the old file has recorded]'
+  --process-id-file='[write the process ID here]'
+  --use-strftime'[apply the strftime facility to the output file name]'
+  --dump-hw-params'[dump hw_params of the device]'
+  --fatal-errors'[treat all errors as fatal]'
+
+  '*:sound file:_files'
+)
+
+_arguments -s -S $opts
+
+# The return value passes through
-- 
2.21.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-12-01 21:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-02 21:13 Completion for aplay from alsa-utils Sebastian Gniazdowski
2019-11-03 23:17 ` dana
2019-11-04 10:38   ` Oliver Kiddle
2019-11-21 23:10   ` Sebastian Gniazdowski
2019-11-22  3:05     ` dana
2019-11-25 10:16       ` Sebastian Gniazdowski
2019-11-25 12:10         ` Sebastian Gniazdowski
2019-11-26  2:16           ` dana
2019-12-01 21:11             ` Sebastian Gniazdowski
2019-11-22 15:17     ` Eric Cook
2019-11-25  9:27       ` Sebastian Gniazdowski

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).