zsh-users
 help / color / mirror / code / Atom feed
* completion configuration
@ 2018-06-18 21:40 Pier Paolo Grassi
  2018-06-18 22:12 ` Arturo Escaip
  0 siblings, 1 reply; 3+ messages in thread
From: Pier Paolo Grassi @ 2018-06-18 21:40 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1220 bytes --]

Hello everybody, I must confess I don't have a clue when it comes to
configure completion styles. I made various attempts but for now, I don't
seem to grasp the syntax of ztyle.
I have in my .zshrc (blindly copied years ago from who knows where):

zstyle -e ':completion:*:approximate:*' max-errors \
'reply=( $(( ($#PREFIX+$#SUFFIX)/3 )) numeric )'

that, as I understand, enables approximate match for all the commands when
trying completion for a number of errors proportional to the number of
characters of the word to be completed etc.

I would like to disable this completion for a command that has a completer
function I wrote that pass to compadd various values, since these are so
many that the completion is very slow to show matches. So I thought that
maybe disabling the approximate match for this command would speed things
up.

My best bet doing this was:
zstyle -e ':completion:*:approximate:my_command' max-errors 0

but this does not work. I tried also various variants to no success.
Can someone shed some light on this please?

-- 
Pier Paolo Grassi
email: pierpaolog@gmail.com
linkedin: https://www.linkedin.com/in/pier-paolo-grassi-19300217
founder: https://www.meetup.com/it-IT/Machine-Learning-TO

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: completion configuration
  2018-06-18 21:40 completion configuration Pier Paolo Grassi
@ 2018-06-18 22:12 ` Arturo Escaip
  2018-06-19  7:32   ` Pier Paolo Grassi
  0 siblings, 1 reply; 3+ messages in thread
From: Arturo Escaip @ 2018-06-18 22:12 UTC (permalink / raw)
  To: pierpaolog; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 2177 bytes --]

Hey Pier,

I’m not very knowledgeable about styles, but I think you may have the
context pattern wrong. You can use C-x h to see the context at any point
when writing a command and you can use that output as a guide when building
a pattern for a style. For example, I have a command that I wrote that is
called pb and this is the output I get when I do C-x h right after typing
pb<space>:

~% pb
tags in context :completion::complete:pb::
    argument-1 options  (_arguments _pb (eval))

The full context is :completion::complete:pb::, I think in your call to
zstyle you are missing the last two colons, so what if you try:

zstyle ':completion:*:approximate:my_command:*' max-errors 0

You don’t need the -e option because you don’t need 0 to be evaluated.
​

On Mon, Jun 18, 2018 at 2:41 PM Pier Paolo Grassi <pierpaolog@gmail.com>
wrote:

> Hello everybody, I must confess I don't have a clue when it comes to
> configure completion styles. I made various attempts but for now, I don't
> seem to grasp the syntax of ztyle.
> I have in my .zshrc (blindly copied years ago from who knows where):
>
> zstyle -e ':completion:*:approximate:*' max-errors \
> 'reply=( $(( ($#PREFIX+$#SUFFIX)/3 )) numeric )'
>
> that, as I understand, enables approximate match for all the commands when
> trying completion for a number of errors proportional to the number of
> characters of the word to be completed etc.
>
> I would like to disable this completion for a command that has a completer
> function I wrote that pass to compadd various values, since these are so
> many that the completion is very slow to show matches. So I thought that
> maybe disabling the approximate match for this command would speed things
> up.
>
> My best bet doing this was:
> zstyle -e ':completion:*:approximate:my_command' max-errors 0
>
> but this does not work. I tried also various variants to no success.
> Can someone shed some light on this please?
>
> --
> Pier Paolo Grassi
> email: pierpaolog@gmail.com
> linkedin: https://www.linkedin.com/in/pier-paolo-grassi-19300217
> founder: https://www.meetup.com/it-IT/Machine-Learning-TO
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: completion configuration
  2018-06-18 22:12 ` Arturo Escaip
@ 2018-06-19  7:32   ` Pier Paolo Grassi
  0 siblings, 0 replies; 3+ messages in thread
From: Pier Paolo Grassi @ 2018-06-19  7:32 UTC (permalink / raw)
  To: arturoescaip; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 2608 bytes --]

hello Arturo, thanks for your suggestions, I will try and let you know
best

Il giorno mar 19 giu 2018 alle ore 00:12 Arturo Escaip <
arturoescaip@gmail.com> ha scritto:

> Hey Pier,
>
> I’m not very knowledgeable about styles, but I think you may have the
> context pattern wrong. You can use C-x h to see the context at any point
> when writing a command and you can use that output as a guide when building
> a pattern for a style. For example, I have a command that I wrote that is
> called pb and this is the output I get when I do C-x h right after typing
> pb<space>:
>
> ~% pb
> tags in context :completion::complete:pb::
>     argument-1 options  (_arguments _pb (eval))
>
> The full context is :completion::complete:pb::, I think in your call to
> zstyle you are missing the last two colons, so what if you try:
>
> zstyle ':completion:*:approximate:my_command:*' max-errors 0
>
> You don’t need the -e option because you don’t need 0 to be evaluated.
> ​
>
> On Mon, Jun 18, 2018 at 2:41 PM Pier Paolo Grassi <pierpaolog@gmail.com>
> wrote:
>
>> Hello everybody, I must confess I don't have a clue when it comes to
>> configure completion styles. I made various attempts but for now, I don't
>> seem to grasp the syntax of ztyle.
>> I have in my .zshrc (blindly copied years ago from who knows where):
>>
>> zstyle -e ':completion:*:approximate:*' max-errors \
>> 'reply=( $(( ($#PREFIX+$#SUFFIX)/3 )) numeric )'
>>
>> that, as I understand, enables approximate match for all the commands when
>> trying completion for a number of errors proportional to the number of
>> characters of the word to be completed etc.
>>
>> I would like to disable this completion for a command that has a completer
>> function I wrote that pass to compadd various values, since these are so
>> many that the completion is very slow to show matches. So I thought that
>> maybe disabling the approximate match for this command would speed things
>> up.
>>
>> My best bet doing this was:
>> zstyle -e ':completion:*:approximate:my_command' max-errors 0
>>
>> but this does not work. I tried also various variants to no success.
>> Can someone shed some light on this please?
>>
>> --
>> Pier Paolo Grassi
>> email: pierpaolog@gmail.com
>> linkedin: https://www.linkedin.com/in/pier-paolo-grassi-19300217
>> founder: https://www.meetup.com/it-IT/Machine-Learning-TO
>>
>

-- 
Pier Paolo Grassi
email: pierpaolog@gmail.com
linkedin: https://www.linkedin.com/in/pier-paolo-grassi-19300217
founder: https://www.meetup.com/it-IT/Machine-Learning-TO

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-19  7:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-18 21:40 completion configuration Pier Paolo Grassi
2018-06-18 22:12 ` Arturo Escaip
2018-06-19  7:32   ` Pier Paolo Grassi

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