zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: zsh-workers@zsh.org
Subject: Re: [Bulk] Re: [PATCH] Add xxd completion
Date: Sat, 11 Oct 2014 11:46:21 +0200	[thread overview]
Message-ID: <11354.1413020781@thecus.kiddle.eu> (raw)
In-Reply-To: <20141009082124.GC1737@tarsus.local2>

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


  reply	other threads:[~2014-10-11  9:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-08  8:20 Daniel Shahaf
2014-10-08 14:35 ` Oliver Kiddle
2014-10-09  8:21   ` Daniel Shahaf
2014-10-11  9:46     ` Oliver Kiddle [this message]
2014-10-11 16:19       ` [Bulk] " Bart Schaefer
2014-10-18 14:08         ` Daniel Shahaf
2014-10-11 21:25       ` Daniel Shahaf

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=11354.1413020781@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --cc=d.s@daniel.shahaf.name \
    --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).