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

Re: how to use tags in zsh completion system



Hi Peter Stephenson,

This is the first time I am using a mailing list. So, I am not sure whether I am doing it correctly or not.

Do I need to always refer to my previous mail or will you be able to figure out my previous mails?
Do I need to view my email and its correspondence from https://www.zsh.org/mla/ or everything will be in the inbox?

Being said that, I tried:

% scp
tags in context :completion::complete:scp::
    argument-rest options  (_arguments _ssh _ssh)
tags in context :completion::complete:scp:argument-rest:
    files hosts users  (_ssh _ssh)
    globbed-files      (_files _ssh _ssh)
    hosts              (_hosts _combination _ssh_hosts _ssh _ssh)
    users              (_users _combination _ssh_users _ssh _ssh)

% scp hosts
tags in context :completion::complete:scp::
    argument-rest options  (_arguments _ssh)
tags in context :completion::complete:scp:argument-rest:
    files hosts users  (_ssh)
    globbed-files      (_files _ssh)
    hosts              (_hosts _combination _ssh_hosts _ssh)
    users              (_users _combination _ssh_users _ssh)

I am sorry, I can not understand what the output means.

The documentation says:

"typically indicating a class of object that the user may need to distinguish."

"Unlike the contexts (which tell you how completion arrived at the point it did), the tags describe the things it can complete here."

If you will be kind enough to explain with the example you were talking about then it would be very helpful for me.

If you kindly make a completion function with more than one tag (Ex. frooble1, frooble2, frooble3) and description of how they were useful. And how that function can be used with `zstyle ':completion:*:aliens:*'....` then I will be very glad.

Thanks and Best Regards,

Ahmad Ismail


On Wed, Aug 26, 2020 at 4:57 PM Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> On 26 August 2020 at 09:59 Ahmad Ismail <ismail783@xxxxxxxxx> wrote:
> The [documentation][1] says
>
> >     zstyle ':completion:*:aliens:*' tag-order \
> >       'frooble:-funny:funny\ frooble' frooble
> >which is used when you're completing for the command aliens, which
> presumably has completions tagged as `frooble' ...
>
> I understand that both context and tag can be viewed using <kbd>^Xh</kbd>.
> So, I tried the following command but suggestion did not show the tags.
>
>     % zstyle ':completion:*:aliens:*' tag-order 'frooble:-funny:funny\
> frooble' frooble
>     % aliens <kbd>TAB</kbd>
>     Completing file
>     Desktop/       Documents/     dotfiles/      Downloads/
>     % aliens <kbd>^Xh</kbd>
>     tags in context :completion::complete:aliens::
>         globbed-files  (_files _default)
>     % aliens frooble <kbd>^Xh</kbd>
>     tags in context :completion::complete:aliens::
>         globbed-files  (_files _default)
>
> I think I am doing something wrong with
>
> > completions tagged as `frooble'
>
> Please help me understand how to use tags in zsh completion system.

Hi Ahmad,

That section in the guide is actually just an example of how things work
using an invented command --- your understanding is basically correct but
actually there is no "aliens" command.

Just off the top of my head (other people may have their own favourite
examples), one interesting command with a number of different tags
that apply at the start of completion is scp: ^xh for that gives me

tags in context :completion::complete:scp::
    argument-rest options  (_arguments _ssh _ssh)
tags in context :completion::complete:scp:argument-rest:
    files hosts users  (_ssh _ssh)
    globbed-files      (_files _ssh _ssh)
    hosts              (_hosts _combination _ssh_hosts _ssh _ssh)
    users              (_users _combination _ssh_users _ssh _ssh)

so that might be something to play with.

(Alternatively, if I got my act together I could probably write
a fake completion for "aliens" that actually did what the guide
says...)

Cheers
pws


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