zsh-workers
 help / color / mirror / code / Atom feed
From: dana <dana@dana.is>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [PATCH] Completion: Add _log_priorities, _logger
Date: Sat, 2 Nov 2019 01:45:03 -0500	[thread overview]
Message-ID: <4D918504-B8F4-46D5-9F04-8B223A56FDEE@dana.is> (raw)
In-Reply-To: <20191102055423.5gzbipni3vnjo4k3@tarpaulin.shahaf.local2>

On 2 Nov 2019, at 00:54, Daniel Shahaf <d.s@daniel.shahaf.name> 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@daniel.shahaf.name> 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@daniel.shahaf.name> 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@daniel.shahaf.name> 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


  reply	other threads:[~2019-11-02  6:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-02  2:14 dana
2019-11-02  5:54 ` Daniel Shahaf
2019-11-02  6:45   ` dana [this message]
2019-11-02  6:58     ` dana
2019-11-02  7:45       ` Daniel Shahaf
2019-11-02  8:20         ` dana

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=4D918504-B8F4-46D5-9F04-8B223A56FDEE@dana.is \
    --to=dana@dana.is \
    --cc=d.s@daniel.shahaf.name \
    --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).