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

Re: [Bulk] Re: [PATCH] Add xxd completion



Daniel Shahaf wrote:
> Thanks for the review.
[ snip ]
> Done.

As you may have noticed, I've now pushed _xxd.

> > > +# TODO: xxd -<tab> should show '-x' and '-x:' differently - give visual hint that there's a required argument
> > 
> > Unless I'm missing something, there's nothing xxd specific in that
> > desire. Perhaps it should be considered for the general case. In many
> 
> Yes, that's a general issue.  For example, instead of:

>     -u                                         -- user name
> I would prefer:
>     -u +                                       -- user name

If you want to dig into the code, it should be possible to make
_arguments do that: match descriptions can differ from the actual match.
I'm not sure how useful it would really be in practice. It'd also need
to allow for optional arguments, and cases where it is -u=USER or
-uUSER. While I say it would be possible, it wouldn't be easy.

> Incidentally, I ran into another general issue:

> It wasn't immediately obvious to me, but I eventually realized the "-z" in the
> output was caused by a stray file named "-z" (via the _files completion defined
> for positional arguments).  However, since the filename begins with a hyphen,
> specifying it as "-z" won't work as intended.  Perhaps "xxd -<tab>" should
> offer "./-z" or "-- -z" (two words) as possible completions?

The -- and ./ tricks won't work for all commands and aren't always
necessary. We'd need to handle it in lots of functions. Files starting
with a - are rare, and usually a mistake. Perhaps it'd be worth doing in
_rm as much to see what it involves. Maybe _files should be cleverer,
perhaps also putting the (-.) in globs by default too.
 
> Done.  'xxd -grou<tab>' now DTRTs; however, 'xxd -g<tab>' gives me:
> 
>     % xxd -g<tab>
>     -groupsize  -- specify the number of octets per group
> 
> and the display doesn't change even if I press <tab> again.  This seems odd:
> why am I not offered both -g and -groupsize as possible completions?  And if
> "-groupsize" is offered in the message, why does pressing <tab> not complete
> the command-line word to the one possible completion?

It'll perhaps seem clearer if you set the format style with the
descriptions tag, e.g:
  zstyle ':completion:*:descriptions' format '%B%d%b'
You may also need this:
  zstyle ':completion:*' group-name ''

This makes it clearer that you have two groups, one of which has no
associated matches, just a heading.

What subsequent tab presses does, depends a lot on your configuration.

Oliver



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