* Fake parameter completion?
@ 2019-10-18 21:08 Chris Nebel
2019-10-18 23:44 ` dana
0 siblings, 1 reply; 2+ messages in thread
From: Chris Nebel @ 2019-10-18 21:08 UTC (permalink / raw)
To: zsh-users
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Fake parameter completion?
2019-10-18 21:08 Fake parameter completion? Chris Nebel
@ 2019-10-18 23:44 ` dana
0 siblings, 0 replies; 2+ messages in thread
From: dana @ 2019-10-18 23:44 UTC (permalink / raw)
To: Chris Nebel; +Cc: zsh-users
On 18 Oct 2019, at 16:08, Chris Nebel <c.nebel@mac.com> wrote:
> 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 immediate reason they work differently is that the styles are applied at
different points during completion. fake and fake-always are handled by the
low-level function _description, whilst fake-files and fake-parameters are
handled by their respective higher-level functions directly.
It probably could have been designed differently, but doing it this way seems
(comparatively) straight-forward, especially since they use incompatible
syntaxes for their values. But this was all long before my time, so i'm just
speculating
On 18 Oct 2019, at 16:08, Chris Nebel <c.nebel@mac.com> wrote:
> 2. What is the actual value of the “*” in the context? Not “parameters”,
> apparently. (I should mention that I do not truly understand zshcompsys.)
The tag used for parameter completion is parameters, but _parameters omits it
when it looks up the style. I confess i'm not sure what the significance of
that is
dana
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-18 23:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-18 21:08 Fake parameter completion? Chris Nebel
2019-10-18 23:44 ` dana
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).