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

Re: How about separating "_arguments --" into a new function?

> 2021/10/13 1:04, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> perhaps the tool could be designed with an eye towards updating existing
> completion functions?  For instance, perhaps the tool could inspect the
> existing _cmd file and omit from the output any lines where the
> --foo[lorem ipsum] part already appears in the file?

Such a tool is useful, of cause, but analyzing the existing _cmd is
would be quite complicated, I guess.

> Perhaps make the tool a filter, in order to support, say, «ssh foo
> 'lorem --help' | help2specs»?

Of course it must read the help text from stdin (if cmd is not given
as argument) since in _arguments 'cmd --help' is run by _call_program
and the output is passed to help2specs via pipe.

>> Or just using $_args_cache_cmd is enough?
> If it is enough, then it should be made more discoverable.

I guess it is enough since no one is requesting to separate _arguments.
How about the following?

diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 89b918d60..c00270f3d 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -4237,6 +4237,17 @@ as `tt(-)tt(-enable-foo)', but the script also accepts the negated form
 example(_arguments -- -s "LPAR()(#s)--enable- --disable-RPAR()")
+The list of var(spec)s derived from the help text is saved in an array
+parameter `tt(_arg_cache_)var(cmd)' where `var(cmd)' is the name of the
+command.  If `tt(_arguments -)tt(-)' (or tt(_gnu_generic)) does not work
+satisfactorily for a commnd `tt(foo)', you can save the specs in a file
+`tt(_foo)' by
+example(echo ${(qqq)_arg_chache_foo} > _foo)
+and use it as a draft of your own completion function for the command
 em(Miscellaneous notes)
 Finally, note that tt(_arguments) generally expects to be the primary

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