zsh-users
 help / color / mirror / code / Atom feed
* 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

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).