zsh-users
 help / color / mirror / code / Atom feed
From: Phil Pennock <zsh-workers+phil.pennock@spodhuis.org>
To: zsh-users@zsh.org
Subject: More-verbose tab-completion idiom?
Date: Wed, 16 Mar 2022 20:26:52 -0400	[thread overview]
Message-ID: <YjKATMd5ifSGX7eD@fullerene.field.pennock-tech.net> (raw)

Folks,

I have a command (`nats`) which takes a "context", and where that can be
set as an environment variable.  I have tab-completion of these working,
based upon knowing where the contexts are stored.  Each context is a
JSON file in a specific directory, but I mostly only need the name.

But, I could provide a more detailed description, by parsing the
.description field from the JSON file.  AFAIK this is going to be
external shell-outs to jq right now (unless anyone has a solid reliable
pattern for JSON extraction from a simple KV object in zsh?).

This is relatively expensive and I don't want to do it by default.  I
mean, if most people have at most 3 contexts then it might be sane for
them, but I have 35 and while I might be an outlier, I can believe there
would be people with more.

Is there a standard idiom and keybinding for "go ahead and get the
expensive data, to provide me with more details to choose between the
options", or would I be creating this from scratch?

My completion for this command also gets pointed at by the installer,
so I really want to make sure that what I end up with is not a baroque
Phil Special but instead something which fits better with whatever the
plugin ecosystems are doing, etc.

I know about use-cache etc and have that in other completions of mine,
so if there's no existing idiom for "trigger expensive completion" then
I will use a zstyle to let people request "descriptions" for this
completion, and use-cache if that's set.  I'm asking in case there's a
better way I'm not familiar with.

Thanks,
-Phil


             reply	other threads:[~2022-03-17  0:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-17  0:26 Phil Pennock [this message]
2022-03-17  0:50 ` Daniel Shahaf
2022-03-17  1:26   ` Phil Pennock
2022-03-17  1:20 ` Bart Schaefer
2022-03-17  1:24   ` Bart Schaefer
2022-03-17  2:21   ` Phil Pennock
2022-03-17 16:30     ` Daniel Shahaf
2022-03-17 20:44     ` Bart Schaefer
2022-03-17 21:38       ` Phil Pennock
2022-03-18  0:28         ` Daniel Shahaf
2022-03-18  1:16           ` Phil Pennock

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=YjKATMd5ifSGX7eD@fullerene.field.pennock-tech.net \
    --to=zsh-workers+phil.pennock@spodhuis.org \
    --cc=zsh-users@zsh.org \
    --subject='Re: More-verbose tab-completion idiom?' \
    /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

Code repositories for project(s) associated with this 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).