From: "Jun. T" <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: How about separating "_arguments --" into a new function?
Date: Sun, 24 Oct 2021 18:53:52 +0900 [thread overview]
Message-ID: <19B5D2FE-1409-4B6C-A89A-F8DCEE9DF69A@kba.biglobe.ne.jp> (raw)
In-Reply-To: <20211021141557.GA16034@tarpaulin.shahaf.local2>
> 2021/10/21 23:15, Daniel Shahaf <d.s@daniel.shahaf.name> 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 «echo»'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 -<TAB>
+ _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.
next prev parent reply other threads:[~2021-10-24 9:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-08 16:12 Jun. T
2021-10-12 16:04 ` Daniel Shahaf
2021-10-14 10:58 ` Jun T
2021-10-17 16:49 ` Daniel Shahaf
2021-10-18 4:40 ` Jun T
2021-10-21 14:15 ` Daniel Shahaf
2021-10-24 9:53 ` Jun. T [this message]
2021-10-25 19:46 ` 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=19B5D2FE-1409-4B6C-A89A-F8DCEE9DF69A@kba.biglobe.ne.jp \
--to=takimoto-j@kba.biglobe.ne.jp \
--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).