* Tweaking the completion engine to prefer some completions
@ 2021-07-13 10:01 Peter Slížik
2021-07-13 12:00 ` Oliver Kiddle
0 siblings, 1 reply; 3+ messages in thread
From: Peter Slížik @ 2021-07-13 10:01 UTC (permalink / raw)
To: Zsh Users
[-- Attachment #1: Type: text/plain, Size: 875 bytes --]
Hello,
I have a few applications installed on my system, with their names sharing
a common prefix.
Now as the apps are company-specific, let me invent some contrived names:
*messageedit*, *messageview*, *messageformat*, *messagesend*, you've got
the idea.
Now, in may daily work, I'm using only one of them: *messageedit*. The
other are used... well, almost never.
Now, if I type *mess<Tab>*, the name gets completed to *message* and the
completion engine waits for further input.
I would like to tweak the completion in such a way the typing *mess<Tab>*
completes the input to *messageedit* and ignores the other possible apps.
Can this be done in a positive way (by naming the preferred application) or
in a negative fashion (by prohibiting all unwanted completions)?
What are the setting options to do it?
Thank you very much for the answers!
Best regards,
Peter
[-- Attachment #2: Type: text/html, Size: 1222 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Tweaking the completion engine to prefer some completions
2021-07-13 10:01 Tweaking the completion engine to prefer some completions Peter Slížik
@ 2021-07-13 12:00 ` Oliver Kiddle
2021-07-13 16:41 ` Peter Slížik
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2021-07-13 12:00 UTC (permalink / raw)
To: Peter Slížik; +Cc: Zsh Users
Peter Slížik wrote:
>
> I have a few applications installed on my system, with their names sharing a
> common prefix.
> Now as the apps are company-specific, let me invent some contrived names:
>
> messageedit, messageview, messageformat, messagesend, you've got the idea.
>
> Now, in may daily work, I'm using only one of them: messageedit. The other are
> used... well, almost never.
>
> Now, if I type mess<Tab>, the name gets completed to message and the completion
> engine waits for further input.
>
> I would like to tweak the completion in such a way the typing mess<Tab>
> completes the input to messageedit and ignores the other possible apps.
>
> Can this be done in a positive way (by naming the preferred application) or in
> a negative fashion (by prohibiting all unwanted completions)?
You can do this with the ignored-patterns style. On the surface, this
works in the negative sense, e.g.:
zstyle ':completion:*:commands' ignored-patterns messageview messageformat messagesend
But you can use a pattern to turn this around into a positive form, e.g:
zstyle ':completion:*:-command-:*:commands' ignored-patterns 'mess(^ageedit)'
If you still occasionally want to complete the others, you may want to
look into the _ignored completer to complete them as a fallback if you
have entered a longer prefix.
In the second example, I used a more specific context which will only
apply in command position. You can vary that depending on the contexts
in which you want it to apply.
Oliver
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Tweaking the completion engine to prefer some completions
2021-07-13 12:00 ` Oliver Kiddle
@ 2021-07-13 16:41 ` Peter Slížik
0 siblings, 0 replies; 3+ messages in thread
From: Peter Slížik @ 2021-07-13 16:41 UTC (permalink / raw)
To: Oliver Kiddle; +Cc: Zsh Users
[-- Attachment #1: Type: text/plain, Size: 1784 bytes --]
Dear Oliver,
thank you for the answer!
Peter
уто, 13. јул 2021. у 14:00 Oliver Kiddle <opk@zsh.org> је написао/ла:
> Peter Slížik wrote:
> >
> > I have a few applications installed on my system, with their names
> sharing a
> > common prefix.
> > Now as the apps are company-specific, let me invent some contrived names:
> >
> > messageedit, messageview, messageformat, messagesend, you've got the
> idea.
> >
> > Now, in may daily work, I'm using only one of them: messageedit. The
> other are
> > used... well, almost never.
> >
> > Now, if I type mess<Tab>, the name gets completed to message and the
> completion
> > engine waits for further input.
> >
> > I would like to tweak the completion in such a way the typing mess<Tab>
> > completes the input to messageedit and ignores the other possible apps.
> >
> > Can this be done in a positive way (by naming the preferred application)
> or in
> > a negative fashion (by prohibiting all unwanted completions)?
>
> You can do this with the ignored-patterns style. On the surface, this
> works in the negative sense, e.g.:
>
> zstyle ':completion:*:commands' ignored-patterns messageview
> messageformat messagesend
>
> But you can use a pattern to turn this around into a positive form, e.g:
>
> zstyle ':completion:*:-command-:*:commands' ignored-patterns
> 'mess(^ageedit)'
>
> If you still occasionally want to complete the others, you may want to
> look into the _ignored completer to complete them as a fallback if you
> have entered a longer prefix.
>
> In the second example, I used a more specific context which will only
> apply in command position. You can vary that depending on the contexts
> in which you want it to apply.
>
> Oliver
>
[-- Attachment #2: Type: text/html, Size: 2262 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-13 16:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13 10:01 Tweaking the completion engine to prefer some completions Peter Slížik
2021-07-13 12:00 ` Oliver Kiddle
2021-07-13 16:41 ` Peter Slížik
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).