Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Completion: Add _log_priorities, _logger
- X-seq: zsh-workers 44885
- From: dana <dana@xxxxxxx>
- To: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- Subject: Re: [PATCH] Completion: Add _log_priorities, _logger
- Date: Sat, 2 Nov 2019 01:45:03 -0500
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=1fsVuOtP1ToiTQiWrV7acj5lNCtOJ6dmu4UCA0GeoIE=; b=WndfQBu6O8vLo+1fwuZadaXq+xI1WQQc5KzOHrSpwgunM0S8hsc6v86HMTLgEZPfWW gWpqz9ufqeZ5unQs9I9KOnssD5B0l+UaG4MhJ/zuPqZEYwy60R+fr5fH0O+ZYtpqcmA4 Az7jsZTtEu09qc8bdcHsMdn9fr39lvTNW+G9garOt897uiuWXPcA6xMdrOAWyG+dawOJ CjDZt0KPzu3xBZ+hriEBxr51ERkX5I6Sx3UlAZnbF50ZoLIB6pKYP/WVj8mRQZzO7VHk CRLd9+/ShxgR5gsRQIUYqPN5Y+ZcvnHxtBt9bmsaSXJdIqnyVtiau+eYKwBB9bTi8G7u MIDQ==
- In-reply-to: <20191102055423.5gzbipni3vnjo4k3@tarpaulin.shahaf.local2>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <E00A62F9-627E-4C0C-A3FD-3A0C1F00D666@dana.is> <20191102055423.5gzbipni3vnjo4k3@tarpaulin.shahaf.local2>
On 2 Nov 2019, at 00:54, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> That is: use up _one_ top-level option letter and stuff all the not-compadd
> --options and their arguments into the argument(s) of that top-level option
> letter.
That would definitely work, and be easy to parse, though it is a bit
unattractive, especially given how these functions are often called. e.g.,
you could end up with _arguments specs like:
'--foo=[specify foo]: :_my_type -Y "-a \"my optarg\" -bcd"'
Granted, very few type functions have options that take arguments, so it
probably wouldn't come up that often, but...
On 2 Nov 2019, at 00:54, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> We can also do:
> .
> _log_priorities "${compadd_options[@]}" -- "${compadd_positional_arguments[@]}" -- "${log_priorities_argv[@]}"
> .
> which is similar to what zargs does. Normally there would be a question here
> of how to escape a literal "--" in $compadd_positional_arguments, but for
> compadd specifically, I think the following is a satisfactory workaround:
Aside from the literal -- operand thing, there are a few complicating factors
i can think of with that:
1. Lower-level functions like _arguments want to automatically stick compadd
options at the beginning of those functions' argument lists, so either they
would have to be changed to pass the two --s (potentially causing issues
for existing type functions that don't expect them) or you would have to
include the --s in every argument spec you wrote.
2. Related to what you mentioned: Because compadd options go at the beginning,
whatever is parsing the function's arguments needs to know all about what
options compadd takes; otherwise it could get confused by an optarg of --.
3. Your type function has to figure out how to parse all of this, which could
lead to a lot of noisy and possibly error-prone boiler-plate.
I think #2 and #3 could be solved by a helper function that does like a
two-pass zparseopts, but i'm not sure about #1, or about the path forward for
existing functions in general. (Though, one benefit of your first suggestion,
if we made sure to pick a letter that no type functions currently want for
themselves, is that it would be pretty straight-forward to just update them as
we go, and then maybe some years in the future we could deprecate/remove the
old way of doing it...?)
On 2 Nov 2019, at 00:54, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> I'll leave it to you to decide whether it's worthwhile to change
> _log_priorities from the version you posted.
I'm definitely open to it, just want to make sure it's something everybody
agrees with that'll work going forward.
On 2 Nov 2019, at 00:54, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> Which reminds me: Shouldn't we mention _log_priorities in the manual, it
> being a new Type/ function?
I'm not actually sure. zshcompsys mentions a few type functions, but they're
only the really general ones like _files. Aside from some passing mentions,
there's nothing in the manual for stuff like _hosts and _pids and _signals. I
always assumed that was a deliberate omission, so i've never bothered with any
of the new type functions i've added.
dana
Messages sorted by:
Reverse Date,
Date,
Thread,
Author