Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

_arguments optspecs (was Re: Editing the history in the shell)

On Sat, May 23, 2020 at 2:30 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> I'm not entirely sure about some
> of the _zed optspecs, but all the desired combinations seem to work
> and all the undesired ones seem not to.

My uncertainty is around these three lines:

>      '(- 2):file:_files' \
> +    '(-f -x 1)-h[edit history]:history file:_files' \
> +    '2:history size: ';;

The first spec causes "file" to be offered (as the first non-option
argument)  if there is no option yet, and will not offer a second

The second spec offers -h followed by "history file" as the argument
to -h, and won't offer -f or -x or a first non-option argument.

The third spec expects "history size" as the second non-option
argument, but does not provide any completions.

What's strange is why "history size" is the second non-option
argument.  If I leave (1) out of the exclusion list on the second
spec, I get offered "file", so in that case the argument to -h is
being taken as an option argument; but after filling in that position
I next get "no more arguments" instead of "history files".  So it
appears that sometimes the argument of -h is not counted as a
non-option argument, and other times it is so counted, which is why
it's "2:" in the third optspec and the (1) is required in the second

Does anybody actually understand this?  Is it explainable (or already
explained, where?) in the doc for _arguments?

Messages sorted by: Reverse Date, Date, Thread, Author