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

Re: Completions from file with zcompsys

On Tue, Jun 20, 2017 at 12:32:15PM -0700, Bart Schaefer wrote:
> On Jun 20,  7:02pm, Dominik Vogt wrote:
> } Trying that there is a slight problem.  The file has 9529 lines;
> } now, when you type something like
> } 
> }   Chenopodium x<TAB>
> OK, here you have two words but you haven't quoted them.  So the match
> is going to only be on "x" -- completion is tightly bound to the shell
> parser idea of a "word".  You need to start from
>   $ foo 'Chenopodium x<TAB>
> (in which case completion will supply the closing quote) or 
>   $ foo Chenopodium\ x<TAB>

That was really just a typo in the mail.  On the command line, the
space was quotred.

> Or you need to use a different key binding that will back up and grab
> both words before invoking completion.

That youldn't help because a taxon can be one to four words, at
least, possibly more.

> } (where no such taxon exists in the file), zsh starts gobbling 100%
> } cpu for about half a minute before completing an approximate
> } match.
> Yeah, approximate isn't going to deal well with that much data, it has
> to try multiple different substrings of the input word against every
> word passed to compadd.  Although in the example above the fact that
> it is looking for every word that has something that might be mistaken
> for an "x" may make it worse.

Isn't there a way to switch it off for a specific command?
Reading the examples I'd have guessed that 

  zstyle ':completion:*' completer _complete _match _approximate
  zstyle ':completion:*:*:foo' completer _complete _match

Would turn off the _approximate completer for the foo command, but
it doesn't.

> For this you might want to write a real function and run "agrep" or "fzf"
> or something like those, to pre-filter the file contents before passing
> to compadd.

Well, keeping this in mind; the approximation stuff may not be
that important anyway.

> }   zstyle ':completion:*' completer _complete _match _approximate
> }   zstyle ':completion:*:match:*' original only
> }   zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)'
> There's a typo in that last line, there should be a space before the
> word "numeric".



Dominik ^_^  ^_^


Dominik Vogt

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