From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW,T_KAM_HTML_FONT_INVALID,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 23625 invoked from network); 5 Sep 2020 11:30:15 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 5 Sep 2020 11:30:15 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1599305415; b=aGw/EJGZnAWPdB1FGIC1+TemU7S25fTVwOp7XTbr/z5tJXdAy8lYKxyWNTx/yp2TbfLhh/8WDN 9VK6u4+S6P2RH1eO26/SCjPz3BjIT6PVY1oRIjzo5n68fBQcIaNlH8I/fZRIJjK6cwuO9LqHKU M0PoYl9IlYu8dJ14ujHDviRzoEaxLSAvfdznJMzRD3G2a2DEGm3zCXSJ1Y0eHSmLj9yv9P4H6/ rY/ZFybqIA/nO0oZ/oMHmTKNErUhPlkrDSs2osEq7DzDxB4EXbC9+BIuvYxhJpzTYHae+cjZ5y gjcduLLGsgbqriuazgzC3Nx2Uw6iKiuZ+Vr5vtjKM6rRmA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ot1-f48.google.com) smtp.remote-ip=209.85.210.48; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1599305415; bh=79iYPdQ/omyK/p5PBhDl4bEO/1BCdLrJdtk0AkI6OzM=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=QbcRQTJ1vVU7O0GQbeUIMHXUpe2PyWjwyHGlXUYouSt+bco8Z9/hxQxON8ky0zaH7IguBBiJFl GW+jqP8SgblWDG/KE3vqd50QWOGIc96Pkya9RFuhIlncfSrhQu5JmE2CDcaJ4k3nv9HrzPJjHC shcz/JH0y3zoiS4Z/8NwKkQ9JEvNEKt2TnrAThZkg2Pxaq3QjxbWQ3uw3Rmul1bkpeKKQOcOSF jWILQFSJxPh/wtYt1SVHsJpvwJC6q85KHWp/v+6SL74zsCX+f6GF5bJhjkcCBgErxBRGoSkp0I FWQlBA0mQXLMfVI1CXcpqDYI1B3tg+kHYtM4XAhmu6ckVw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=rPf39CplopNMH7C+VsuPJjm7ZZ4AqziGJDjamtEUaXo=; b=ccwz42ohcbwf7BjvUQqndCLUDU N+gaIUT8wUEendTHbkDwnEcuX8MN+1eHNqKcB5CWwE33AtE01igmJ9gBO1veeVJYXAjhNK75tbC+s 8Qx+n8V/V4vJzyPgyv5l38Dp6o2V82op6NMvQazrV+mHnUzmpanrhb88wQuc03vG/lxH+NxXbGKX2 mBhfSwH6llvxtCnsYyh015kBEsrpILJabS6cUpwqtIoUq32UYcqitO3V5V5c/g99hf0H4IP6GgyBW XMhi9Nu0D41fBOv6bEVSFuQ+lrTRQTgku3s6z9/0F4BgH44Mn89P4THzz+lN4QyPTGL/go3J5moMM Ue5z8Swg==; Received: from authenticated user by zero.zsh.org with local id 1kEWOa-000ACD-0K; Sat, 05 Sep 2020 11:30:12 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ot1-f48.google.com) smtp.remote-ip=209.85.210.48; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ot1-f48.google.com ([209.85.210.48]:33404) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kEWO2-0009ov-EY; Sat, 05 Sep 2020 11:29:39 +0000 Received: by mail-ot1-f48.google.com with SMTP id m12so5293320otr.0 for ; Sat, 05 Sep 2020 04:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rPf39CplopNMH7C+VsuPJjm7ZZ4AqziGJDjamtEUaXo=; b=e7fLy9H/lP75nfKJQ+oleARrD1wCu6zGdRjBJVRGaRtN+oQbWgfukabq5xaIMOZGqQ 4EwS3fvaCGtY58sMWj59HjAJCmzOavAn5NXTCnxAMpYY6mumMRFS0qm0Jm5l4Ns8+9Re rM2u4HP+4N2w6nlJki+xYlqYRC4MvhI6h8EdmtjRBgnw59fF8ofaSDWD/QjoZSW95g0f JhYwiC0NtBbIGfAf0xpTK43HqgeNcwrY/x6Ca2X9kil7d9CVyjjp7Fxsl7f81VKJ/x9b bsNDKEIyPPnX+1pL7PziMzDfJ3+YDpdNgAF/ZR+u6ak70H6ahPE8t7kuEGAkjBZyVC57 qnKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rPf39CplopNMH7C+VsuPJjm7ZZ4AqziGJDjamtEUaXo=; b=CZC9N5i3jiacWBECXXCB/5F6x5szPoK2QfWaK7k3ngS0bBSTu9TvyuXXjbpM9NuwwT 6Dx8r0CBNr5M88mnTzo2/O/P159VDjXNMJArMRvRjVq/dcLqFS5gzZTc/Zk+WE8Ldbcf ZdvL8PJALXMz0Hb2qxWHo+IedxxEHCvCIcCCuy3qFImf9Z+HG3R6jkqD4fudaTtz1Tsj 3s5jv2rHguWzzMefybfhnu53FNsvcsMUS697nCetm0QukEiRPvxZ3+8kvBbWQy3nGLlU YlaPaN8Ylio9Kdhwc4TXwvxRV5vgsCcyzskNlKe3/pemC8oxnr7f50NbsljWz1WL7Xy5 oHow== X-Gm-Message-State: AOAM530NwXQo42oxLhfVE6u9ouelYNYgkrkyjYNWoX1ChfpE97Tfno6D e61kH5tjeimQNH5KGD4Mt5Z8+cfceau0/N9cOqM= X-Google-Smtp-Source: ABdhPJxspCwkt1WoEmHWeJPZyp0Y+a/e9fuOjHk7K7iJNKeIUSd3odVQyC+rDY2mb04qf6Yfv5b1TpxNgFzKeOdzZuI= X-Received: by 2002:a05:6830:1e30:: with SMTP id t16mr8795647otr.18.1599305376572; Sat, 05 Sep 2020 04:29:36 -0700 (PDT) MIME-Version: 1.0 References: <441849700.1433895.1598439442873@mail2.virginmedia.com> <20200904192329.08f436ea@tarpaulin.shahaf.local2> In-Reply-To: <20200904192329.08f436ea@tarpaulin.shahaf.local2> From: Ahmad Ismail Date: Sat, 5 Sep 2020 17:29:25 +0600 Message-ID: Subject: Re: how to use tags in zsh completion system To: Daniel Shahaf Cc: Peter Stephenson , Zsh Users Content-Type: multipart/alternative; boundary="000000000000dbaa8405ae8f4c68" X-Seq: 26055 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: --000000000000dbaa8405ae8f4c68 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Daniel Shahaf, Thank you very much for explaining tags. I am grateful to you. *Thanks and Best Regards,Ahmad Ismail* On Sat, Sep 5, 2020 at 1:23 AM Daniel Shahaf wrote= : > Elaborating per the request in users/26049. > > Peter Stephenson wrote on Wed, 26 Aug 2020 11:57 +0100: > > > Please help me understand how to use tags in zsh completion system. > > > > 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. > > The scp(1) command can be invoked in several different ways: > . > scp $localfile ${remotehost}: > scp $remoteuser@$remotehost: $localfile > scp ${remotehost}: $localfile > . > Thus, =C2=ABscp =C2=BB completes three kinds of things: local files, > usernames for remote login, and hostnames for remote login. > > The completion system knows what type of thing each possible > completion is. Each tag =E2=80=94 in this example, "files", "hosts", > "users", and "globbed-files" =E2=80=94 corresponds to a single "type of t= hing" > that can be completed at that point. (I'm not sure how "globbed-files" > gets there, but you needn't worry about that right now.) > > You can see completions grouped by tag by setting the group-name style: > > $ zsh -f > % autoload compinit > % compinit > % zstyle :completion:\* group-name '' > % zstyle :completion:\*:descriptions format '=E2=86=92 %d' > % scp > =E2=86=92 file > bar.txt foo.txt > =E2=86=92 remote host name > hermes.example.org localhost > =E2=86=92 user > danielsh root > > You can reorder the three groups of candidate completions by setting the > tag-order style appropriately. For example, =C2=ABzstyle \* tag-order us= ers > hosts files=C2=BB will show the groups in a different order than above. > > Tag names are also part of the zstyle context string (the thing context > patterns are matched against), so styles can be set for some tags but > not others. For example, =C2=ABzstyle ':completion:*:options' prefix-hid= den > true=C2=BB > will set the prefix-hidden style whilst listing candidate completions > that are options, but not whilst listing other candidate completions. > > As Peter said elsethread, you can generally forget about tags unless > you're either configuring completion system or writing your own > completion function (which you wouldn't generally need to do, unless > you wrote a custom command as well). > > Cheers, > > Daniel > --000000000000dbaa8405ae8f4c68 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi=C2=A0Daniel Shahaf,

Thank you very m= uch for explaining tags. I am grateful=C2=A0to you.

Thanks and Best Regar= ds,

Ahmad Ismail



On Sat, Sep 5, 2= 020 at 1:23 AM Daniel Shahaf <= d.s@daniel.shahaf.name> wrote:
Elaborating per the request in users/26049.

Peter Stephenson wrote on Wed, 26 Aug 2020 11:57 +0100:
> > Please help me understand how to use tags in zsh completion syste= m.=C2=A0
>
> 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::
>=C2=A0 =C2=A0 =C2=A0argument-rest options=C2=A0 (_arguments _ssh _ssh)<= br> > tags in context :completion::complete:scp:argument-rest:
>=C2=A0 =C2=A0 =C2=A0files hosts users=C2=A0 (_ssh _ssh)
>=C2=A0 =C2=A0 =C2=A0globbed-files=C2=A0 =C2=A0 =C2=A0 (_files _ssh _ssh= )
>=C2=A0 =C2=A0 =C2=A0hosts=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (_hosts _combination _ssh_hosts _ssh _ssh)
>=C2=A0 =C2=A0 =C2=A0users=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (_users _combination _ssh_users _ssh _ssh)
>
> so that might be something to play with.

The scp(1) command can be invoked in several different ways:
.
=C2=A0 =C2=A0 scp $localfile ${remotehost}:
=C2=A0 =C2=A0 scp $remoteuser@$remotehost: $localfile
=C2=A0 =C2=A0 scp ${remotehost}: $localfile
.
Thus, =C2=ABscp <TAB>=C2=BB completes three kinds of things: local fi= les,
usernames for remote login, and hostnames for remote login.=C2=A0

The completion system knows what type of thing each possible
completion is.=C2=A0 Each tag=C2=A0=E2=80=94 in this example, "files&q= uot;, "hosts",
"users", and "globbed-files"=C2=A0=E2=80=94 corresponds= to a single "type of thing"
that can be completed at that point.=C2=A0 (I'm not sure how "glob= bed-files"
gets there, but you needn't worry about that right now.)

You can see completions grouped by tag by setting the group-name style:

=C2=A0 =C2=A0 $ zsh -f
=C2=A0 =C2=A0 % autoload compinit
=C2=A0 =C2=A0 % compinit
=C2=A0 =C2=A0 % zstyle :completion:\* group-name ''
=C2=A0 =C2=A0 % zstyle :completion:\*:descriptions format '=E2=86=92 %d= '
=C2=A0 =C2=A0 % scp <TAB>
=C2=A0 =C2=A0 =E2=86=92 file
=C2=A0 =C2=A0 bar.txt foo.txt
=C2=A0 =C2=A0 =E2=86=92 remote host name
=C2=A0 =C2=A0 hermes.example.org localhost
=C2=A0 =C2=A0 =E2=86=92 user
=C2=A0 =C2=A0 danielsh root

You can reorder the three groups of candidate completions by setting the tag-order style appropriately.=C2=A0 For example, =C2=ABzstyle \* tag-order= users
hosts files=C2=BB will show the groups in a different order than above.

Tag names are also part of the zstyle context string (the thing context
patterns are matched against), so styles can be set for some tags but
not others.=C2=A0 For example, =C2=ABzstyle ':completion:*:options'= prefix-hidden true=C2=BB
will set the prefix-hidden style whilst listing candidate completions
that are options, but not whilst listing other candidate completions.

As Peter said elsethread, you can generally forget about tags unless
you're either configuring completion system or writing your own
completion function (which you wouldn't generally need to do, unless you wrote a custom command as well).

Cheers,

Daniel
--000000000000dbaa8405ae8f4c68--