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=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 10948 invoked from network); 24 Oct 2021 09:54:19 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 24 Oct 2021 09:54:19 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1635069259; b=oKEJx3atjmc1QcmG/H3FXOz5gDHidcqmVQbcn5urlvt6AW2vbEqFqYWL6acOwgZbac0xgwpCC3 y9JrZK+K7bUhdb4+ZNUeGrjRe9ap3gQ22U1LIYtR4WBelUU88rEBsfsZzOzi40jMO1inQ5621q F6zTcUKAbILiJrNyb+mpgaiIYUBhgDqzvqsb8sYcRIfwIibnZS/I4JWN6rTG0Uej/y3yKZq9C8 dfm+BMS8vhTHeyPhaCIw1BsOGXoBZ7/uCBUBRq/68lLEoGYj1MsQPmPnwIIj4EhQxjlMFaQtAG wPZ2zk4MivtcacP7mZbhtWh7kH0Ih+n6fyBwAIoMVbErHA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (snd00009-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.9; dmarc=none header.from=kba.biglobe.ne.jp; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1635069259; bh=UmayESQRnO01NvSpH//Z9jJzFznPijgxMavChOTZJaM=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Message-ID:In-Reply-To:To:References:Date:Subject: MIME-Version:Content-Transfer-Encoding:Content-Type:From:DKIM-Signature; b=Fo56PGazDjsWYhPVbKyiG0pomP/j1xoSy+inqYcDFsUm0gJrzMAAbtIk1IkAY44KZb9PjhpRpg BeDjLaJlOow0fO2aqehE61GQ4nyy3L8t8CGKDFie+BcJo3YnPJqFr1HgFwxw9efy4rURLiX2Bo pq7ySR3mWpkl2o5APRcyq58DhUKR7/EJnltGoxOZcHN50jhmwlpj1e4Bu3PVKkH44dg2xfuPHx 3uLpLHKoDh2vuHbhS3hATUZOShV8pFDewLxALV6P6fU46HK5BFwgXWAP8923ygHIGgjFr5LkRL R97kU1ntz2i0RA+3fYiq4yRotuexl5WnnObwjttYKzkiyA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-Id:In-Reply-To:To:References: Date:Subject:Mime-Version:Content-Transfer-Encoding:Content-Type:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=ChCl8QDYLN1JjXvIm0l1OvCuwBw8Pd9zJPzb9jDjrdE=; b=ie7mIl+QeH6gu9tXCmXmvU8Y9T oK2U9UcoxA4ClZ2H/zSNcHMry4jswGqpmSROJIGHCrKMtbA4W1BYGOFrKRfiPw/+KQAaEms0Ng10Z muKFzeYQbmJ1BA1YoIunhZSKahfbXyOyVML5GxhEqvJU7PLXollldtr5bfwBeur01GJP/3yrHrKjW 3TZNufGkWtVPepeWfphLJXlQUoYkCfvKv/ewEll3c6Mvf20DblBCLOmqT412VjMjyaa93U2Ay9oUK lvgFQcqJZp/sbwdOp47lXN2tBAbpUJC8YCXZ7AP8HP5KLLNq1GGa7B3sHqkqJMGSW/aoFFadW9y8V M8/NYHRQ==; Received: from authenticated user by zero.zsh.org with local id 1meaCp-0007T7-Cw; Sun, 24 Oct 2021 09:54:19 +0000 Authentication-Results: zsh.org; iprev=pass (snd00009-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.9; dmarc=none header.from=kba.biglobe.ne.jp; arc=none Received: from snd00009-bg.im.kddi.ne.jp ([27.86.113.9]:51105 helo=dfmta0012.biglobe.ne.jp) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1meaCX-0007AS-0U; Sun, 24 Oct 2021 09:54:03 +0000 Received: from mail.biglobe.ne.jp by omta0012.biglobe.ne.jp with ESMTP id <20211024095354344.JTTT.59926.mail.biglobe.ne.jp@biglobe.ne.jp> for ; Sun, 24 Oct 2021 18:53:54 +0900 From: "Jun. T" Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: Re: How about separating "_arguments --" into a new function? Date: Sun, 24 Oct 2021 18:53:52 +0900 References: <4B74EF96-AE73-4D40-ACDD-9999DFFDA1A8@kba.biglobe.ne.jp> <20211012160428.GD17948@tarpaulin.shahaf.local2> <20211017164917.GA30795@tarpaulin.shahaf.local2> <20211021141557.GA16034@tarpaulin.shahaf.local2> To: zsh-workers@zsh.org In-Reply-To: <20211021141557.GA16034@tarpaulin.shahaf.local2> Message-Id: <19B5D2FE-1409-4B6C-A89A-F8DCEE9DF69A@kba.biglobe.ne.jp> X-Mailer: Apple Mail (2.3445.104.21) X-Biglobe-Sender: takimoto-j@kba.biglobe.ne.jp X-Seq: 49520 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: > 2021/10/21 23:15, Daniel Shahaf wrote: > The content > of ${_args_cache_foo} need to be escaped once for their transit = through > lex.c when _foo will be read by compinit, and once against =C2=ABecho=C2= =BB's > treatment of backslashes. I know. But if the output of 'cmd --help' already has '\', for example --escape replace $ by \$ then 'print -r' does not work either (if the output of 'print -r' is = used as a spec for _arguments as is). Using (qq) (instead of (qqq)) may or may not help, but then users must unset RC_QUOTE (before calling print/echo). But anyway $_args_cache_cmd is just a 'draft' of _cmd, and users must edit it manually (usually lots of editing are required). I'll push the following soon, so feel free to modify/improve it. diff --git a/Etc/completion-style-guide b/Etc/completion-style-guide index 62e6a2787..4fa0040a5 100644 --- a/Etc/completion-style-guide +++ b/Etc/completion-style-guide @@ -570,3 +570,13 @@ Misc. remarks data derived from another command's output to the helper. = Consider using some variation of the `q` expansion flag to deal with this: `_call_program vals $words[1] ${(q-)myfile}' +10) If you are going to create a new completion function '_cmd' for a + command 'cmd', and if the 'cmd' supports the --help option, then = you + may try + compdef _gnu_generic cmd + cmd - + _gnu_generic may not work sufficiently well for 'cmd', but the = specs + for _arguments generated from the help text are cached in a = variable + '_args_cache_cmd', and you can save them in a file '_cmd' by + print -r -- ${(F)${(@qqq)_args_cache_cmd}} > _cmd + and use the file as a draft of the new completion function.