* question about "-E" option of compadd
@ 2016-04-25 3:07 Han Pingtian
2016-04-25 4:36 ` Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: Han Pingtian @ 2016-04-25 3:07 UTC (permalink / raw)
To: zsh-users
Hi there,
There is one statement about -E option of compadd in the manual:
And because all but one empty string would otherwise be removed,
this option implies the -V and -2 options (even if an
explicit -J option is given).
But isn't the action "all but one empty string be removed" implying a
"-1" option? "-2" option should keep all empty strings I think.
Thanks in advance!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: question about "-E" option of compadd
2016-04-25 3:07 question about "-E" option of compadd Han Pingtian
@ 2016-04-25 4:36 ` Bart Schaefer
2016-04-25 7:48 ` Han Pingtian
0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2016-04-25 4:36 UTC (permalink / raw)
To: Zsh Users
On Sun, Apr 24, 2016 at 8:07 PM, Han Pingtian <hanpt@linux.vnet.ibm.com> wrote:
>
> And because all but one empty string would otherwise be removed,
> this option implies the -V and -2 options (even if an
> explicit -J option is given).
>
> But isn't the action "all but one empty string be removed" implying a
> "-1" option? "-2" option should keep all empty strings I think.
Note the word "otherwise" in the "And because ..." sentence.
"Otherwise" in this context means "if -E were not used".
"And because all but one empty string would be removed if -E were not
used, it is the case that -E implies -V and --2."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: question about "-E" option of compadd
2016-04-25 4:36 ` Bart Schaefer
@ 2016-04-25 7:48 ` Han Pingtian
2016-04-25 19:20 ` Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: Han Pingtian @ 2016-04-25 7:48 UTC (permalink / raw)
To: zsh-users
On Sun, Apr 24, 2016 at 09:36:00PM -0700, Bart Schaefer wrote:
> On Sun, Apr 24, 2016 at 8:07 PM, Han Pingtian <hanpt@linux.vnet.ibm.com> wrote:
> >
> > And because all but one empty string would otherwise be removed,
> > this option implies the -V and -2 options (even if an
> > explicit -J option is given).
> >
> > But isn't the action "all but one empty string be removed" implying a
> > "-1" option? "-2" option should keep all empty strings I think.
>
> Note the word "otherwise" in the "And because ..." sentence.
> "Otherwise" in this context means "if -E were not used".
>
> "And because all but one empty string would be removed if -E were not
> used, it is the case that -E implies -V and --2."
Thanks. But looks like even if -E was used, all but one empty strings
still being removed ? like this:
% _foo()
compadd -E 3 foo1 foo1 foo1 foo2 foo3 '' '' ''
% compdef _foo foo
% foo <tab>
foo1 foo2 foo3
there is only one empty string showed.
Thanks in advance.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: question about "-E" option of compadd
2016-04-25 7:48 ` Han Pingtian
@ 2016-04-25 19:20 ` Bart Schaefer
2016-04-26 0:51 ` Han Pingtian
0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2016-04-25 19:20 UTC (permalink / raw)
To: zsh-users
On Apr 25, 3:48pm, Han Pingtian wrote:
} Subject: Re: question about "-E" option of compadd
}
} But looks like even if -E was used, all but one empty strings
} still being removed ? like this:
}
} % _foo()
} compadd -E 3 foo1 foo1 foo1 foo2 foo3 '' '' ''
} % compdef _foo foo
} % foo <tab>
} foo1 foo2 foo3
There's this other part of the documentation for -E
empty matches [are] only useful to format completion lists and to
make explanatory string be shown in completion lists
Without -V -2, the completion listing is deduplicated on the match
string regardless of the descriptions, so you'll only see one of the
possibly several descriptions. With -V -2, identical matches and
their corresponding descriptions are shown, but if the descriptions
are missing then the deduplication still happens.
In other words -E is only used to "pad" the list of matches to have
the same number of elements as the array of descriptions passed to -d.
It's not an error to pass -E without -d but it's not useful either.
Or at least that's my understanding of how it's expected to work, and
is how it works in e.g. Oliver's new _dates helper function; but it
is quite possible that some other combination of options bends it.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: question about "-E" option of compadd
2016-04-25 19:20 ` Bart Schaefer
@ 2016-04-26 0:51 ` Han Pingtian
0 siblings, 0 replies; 5+ messages in thread
From: Han Pingtian @ 2016-04-26 0:51 UTC (permalink / raw)
To: zsh-users
On Mon, Apr 25, 2016 at 12:20:04PM -0700, Bart Schaefer wrote:
> On Apr 25, 3:48pm, Han Pingtian wrote:
> } Subject: Re: question about "-E" option of compadd
> }
> } But looks like even if -E was used, all but one empty strings
> } still being removed ? like this:
> }
> } % _foo()
> } compadd -E 3 foo1 foo1 foo1 foo2 foo3 '' '' ''
> } % compdef _foo foo
> } % foo <tab>
> } foo1 foo2 foo3
>
> There's this other part of the documentation for -E
>
> empty matches [are] only useful to format completion lists and to
> make explanatory string be shown in completion lists
>
> Without -V -2, the completion listing is deduplicated on the match
> string regardless of the descriptions, so you'll only see one of the
> possibly several descriptions. With -V -2, identical matches and
> their corresponding descriptions are shown, but if the descriptions
> are missing then the deduplication still happens.
>
> In other words -E is only used to "pad" the list of matches to have
> the same number of elements as the array of descriptions passed to -d.
> It's not an error to pass -E without -d but it's not useful either.
>
Thanks so much, now I got it!
> Or at least that's my understanding of how it's expected to work, and
> is how it works in e.g. Oliver's new _dates helper function; but it
> is quite possible that some other combination of options bends it.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-04-26 1:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-25 3:07 question about "-E" option of compadd Han Pingtian
2016-04-25 4:36 ` Bart Schaefer
2016-04-25 7:48 ` Han Pingtian
2016-04-25 19:20 ` Bart Schaefer
2016-04-26 0:51 ` Han Pingtian
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).