Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: completion

On 01/07/2015 12:42 PM, Bart Schaefer wrote:
On Jan 7, 2015 11:51 AM, "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx> wrote:
The hardest part of the zstyle mechanism is grasping the "reverse pattern
match" lookup mechanism.  Your hypothetical assassination example is
inaccurate because you're applying the patterns in the wrong "direction".

Here's possibly a way to think about this.  Let's consider two applications
of patterns, globbing and zstyle.

Globbing starts with a search space full of very specific objects:
Individual file names.  You provide a general description (the pattern) and
globbing looks up all the specific objects.

Zstyle starts with an *empty* search space and a whole lot of very specific
*searches* (at least one for every possible word-on-the-command-line you
might want to complete).  These searches are called style contexts.  You
populate the search space with general descriptions of the style contexts
you care about, and zstyle looks up the single general description that
best fits a specific search.

This is why there are wildcards in the commands that set styles.  There are
no wildcards in the commands that test or look up styles.

"Show me the dogs in this park that are on a leash." You search the park
for dogs, there may be lots but it is an instantaneous finite number.

"All dogs in this park must be on a leash." You check every animal you see
entering the park to see if it is a dog and has a leash.  You have no idea
how many animals or leashes you may eventually find, but if the current
animal is a dog, you know it has to have a leash to be allowed in the park.

I see. One is 'go find' the other is 'test what comes by', so that's a filter really, no? That's very helpful--get the bedrock concepts right-- but how do we make sense of this in practice? How do we parse these completions, with their varying numbers of colons and asterisks? You and Peter have both made comments (which I don't understand) that seem to suggest that these colons are not what I think they are at all. But if they are not field separators then I can't imagine what they might be. (For a while I thought they might be 'emphasizers'). I have maybe a dozen or so of these 'zstyle' lines in my .zshrc, and they are all there on faith (borrowed from here and there) and I have no idea how any of them work. First, let me understand the meta syntax, then I'll worry about what goes on inside each field (if that's what they are).

So should we perhaps say 'zstyle filters' vs. 'zstyle searches'? 'Search' puts me in mind of the globbing thing: go find!

To put it in English, what I'm reaching for (I think), sounds something like this:

If [something-on-command-line] matches [this-pattern] (a filter), then expand that pattern using [this-particular-set-of-rules], and then search (go find) in [this-particular-group-of-objects] for [this-particular-glob-pattern] and put that on my command line. I'm supposing that that's how it hasta work, but I can't 'see' that in the actual syntax.

Messages sorted by: Reverse Date, Date, Thread, Author