Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Merge ignore and deduplication patterns in _sequence
On 9 Mar, oxiedi@xxxxxxxxx wrote:
> First, it fixes the following bug:
>
> % zsh -f
> % autoload -Uz compinit
> % compinit -D
> % compdef '_arguments ": :_sequence compadd - 1 2 3"' seq
> % zstyle ':completion:*:*:seq:*:*' ignored-patterns 2
> % seq <Tab>
> _sequence:40: command not found: -F
>
> Second, it allows a user to ignore matches using the ignored-patterns style.
Sorry for taking so long to review this patch. Currently, _sequence
ignores a -F that is passed to it and in general it is good for helper
functions to accept as many of them as possible. As I'll explain, I think
the omission was intentional in this case. I'd be interested in what
other people think because the change is perhaps more useful in actual
practice.
A compadd option passed to _sequence would normally apply to the whole
list rather than individual elements. Using -S as an example:
_foo() {
_sequence -S/ -s, -n2 compadd - 1 2 3
}
foo 1,2<tab> - completes the / suffix, we have a complete list (-n2)
So / is a suffix of the whole list rather than of individual elements.
So if _sequence is passed a -F option then arguably the pattern should
apply to the whole list: -F '(1,2)' would exclude the list 1,2. However,
there's no simple way to implement that and it doesn't seem especially
useful. And in practical terms, while we normally have _sequence wrap
_wanted rather than the other way around, sometimes it is the
inverse as in the _arguments example.
I'm inclined to apply the change. Anyone else have a view?
There is one caveat which is that for the array passed to -F, we rely on
the dynamic scoping of local variables in zsh so if _sequence calls a
function with a local variable name clash then things break. ign is very
commonly used in completion functions. dedup was rather less common.
Perhaps we should call it _sequence_ign or something. I'm not worried
about nested use of _sequence because ignored patterns from an outer
_sequence are unlikely to be especially helpful.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author