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

Re: [PATCH] Re: (Y) modifier: up to N matches?

On 4 June 2014 04:08, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> Bart Schaefer wrote on Mon, Jun 02, 2014 at 20:46:03 -0700:
>> On Jun 2,  6:23pm, Daniel Shahaf wrote:
>> }
>> } Would it make sense to have (Y) take a numeric argument specifying the
>> } maximal number of files to match? e.g., *(NY5) would expand to between
>> } 0 and 5 filenames (but never more than 5).
>> My concern is that people are going to expect the (o)/(O) qualifiers to
>> take effect before (Y) does, and will be confused about the "skipped"
>> files when it takes effect after.  If (Y) can't return more than one
>> result, there's nothing to sort.
> The expectations about sorting are just as much of a problem with (Y) as
> they would be with (Y42): in both cases there might be "skipped" files.
> For example, in the source dir, *(Y/on) [or *(Y1/on)] might result in "Etc"
> even though "Doc" exists.
> Let's clarify that in the documentation of (Y).
>> However, I can't come up with any other objection.
> Two patches attached.  The first patch implements (Y42) and adds completion
> and the above-mentioned docs clarification.  (The two latter parts should be
> useful even if we don't add an argument to (Y).)  The second patch isn't
> strictly required, but it cleans up the return type changes that are no
> longer needed after the first patch.
> FWIW, I'm intentionally making (Y) without argument an error; we can settle
> on its semantics later after (Y42) has seen some "in the field" use.  The
> spelling (Y1) can be used instead.
> Cheers,
> Daniel

We already have [1,42] for the first 42 matches after sorting, just
make a reference to that I guess? And as for taking arguments, all
other glob qualifiers that take variable length arguments do it in the
form of u:args: where the : can be any character, so this should be
consistent with that, I think.

Mikael Magnusson

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