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

Re: disable substring match on command name



On Mar 3,  6:25pm, Oliver Kiddle wrote:
} Subject: Re: disable substring match on command name
}
} Bart wrote:
} >   zstyle -e ':completion:*' matcher-list \
} >     'zstyle -a "word-${CURRENT}:completion:$curcontext" matcher-list reply'
} 
} My only comment is that I'd be inclined to add the custom context
} component at the end rather than the beginning.

I thought about that, but the tag is already appended with no additional
trailing colon in cases where it is known, and all current zstyle forms
use a leading colon so that seemed the best place to put it.

Also I was a bit worried that :completion:${curcontext}:word-N could
match again the ':completion:*' pattern and put the whole thing into
an loop.  If you stick the word-N on the front, patterns that begin
with ':completion' can't possibly match.
 
} >   zstyle -e ':completion:*' matcher-list \
} >     'zstyle -a "word-${CURRENT}$LOOKUP" "$STYLE" reply'
} > 
} > The example names LOOKUP and STYLE are probably not the best choices.

Thinking about this further, there's no reason for the style to be in
a parameter; it's not a pattern, so by definition it must be the same
as in the previous link in the chain (e.g., must be matcher-list above).
Only the lookup pattern is unknown during the "zstye -e" evaluation.

} How about simply adding an option for chained styles [...]
} Admittedly, it'd be slightly less flexible.

Trouble with this is that the ":"-separated context bits are not a
feature of zstyle, they're a feature of the chosen use of zstyle in
compsys.  To add a chaining option we'd have to standardize on a
syntax for gluing sub-patterns together, which zstyle would know
about internally.  That seems a bad idea.

However, I came up with a solution to the "unknown lookup" problem
as well -- compsys always has extendedglob set, so:

    zstyle -e '(#b)(:completion:*)' matcher-list \
        'zstyle -a "word-$CURRENT$match" matcher-list reply'

A bit of a glitch with this is that zstyle does not save and restore
$match et al. around its pattern lookups, but that's easily fixable
because zregexparse already provides the necessary machinery right
there in zutils.c where zstyle is also defined.



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