From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: oxiedi@yandex.ru
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH] Merge ignore and deduplication patterns in _sequence
Date: Thu, 21 May 2020 14:43:45 +0200 [thread overview]
Message-ID: <57004-1590065025.229907@6d4A.1jvX.h7ap> (raw)
In-Reply-To: <3932941583753550@myt2-a7d7570d35ff.qloud-c.yandex.net>
On 9 Mar, oxiedi@yandex.ru 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
next prev parent reply other threads:[~2020-05-21 12:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-09 11:32 oxiedi
2020-05-21 12:43 ` Oliver Kiddle [this message]
2020-05-22 19:02 ` oxiedi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57004-1590065025.229907@6d4A.1jvX.h7ap \
--to=okiddle@yahoo.co.uk \
--cc=oxiedi@yandex.ru \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).