From: Chris Nebel <c.nebel@mac.com>
To: zsh-users@zsh.org
Subject: Fake parameter completion?
Date: Fri, 18 Oct 2019 14:08:02 -0700 [thread overview]
Message-ID: <7C2ECA3E-EA6B-4C31-BF3A-1CF791F71785@mac.com> (raw)
zsh-users—
I wanted to use autocompletion to complete various “debugging” environment variables, and I came up with something that works, but I don’t understand why it works and some other attempts don’t. First, the task: sh derivatives let you specify extra environment variables for a command by writing them before the command, something like this:
% UseExtraSpiffyLogging=1 ./mytool
The point is that they are ordinarily undefined, so normal parameter completion won’t match them, but I want them completed anyway. Sounds like a job for the “fake” style, which I’ve successfully used in the past; that plus _complete_help led me to this:
zstyle ':completion:complete:-command-::parameters' fake UseExtraSpiffyLogging
This sort of works, but completes “UseEx<tab>” to “UseExtraSpiffyLogging<space>” when really I want no space, or ideally a magic “=“. Re-reading the documentation, I found the “fake-parameters” style. My first attempt didn’t complete anything at all:
zstyle ':completion:complete:-command-::parameters' fake-parameters UseExtraSpiffyLogging
…so I relaxed the context a bit, and now I get the completion *with* the magic “=“, which is perfect:
zstyle ':completion:complete:-command-::*' fake-parameters UseExtraSpiffyLogging
…except that now I have questions:
1. Why are “fake” and “fake-parameters” distinct styles? Obviously they behave differently in practice, but why couldn’t “fake” take the position into account and add the magic “=“ like “fake-parameters” does? (The answer probably has to do with the *other* additional feature that “fake-parameters” provides, which is type-sensitivity, though it seems like “fake” could still do the magic “=“.)
2. What is the actual value of the “*” in the context? Not “parameters”, apparently. (I should mention that I do not truly understand zshcompsys.)
Thanks,
—Chris N.
next reply other threads:[~2019-10-18 22:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-18 21:08 Chris Nebel [this message]
2019-10-18 23:44 ` 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=7C2ECA3E-EA6B-4C31-BF3A-1CF791F71785@mac.com \
--to=c.nebel@mac.com \
--cc=zsh-users@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).