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

Re: Completions from file with zcompsys

On Jun 20,  7:02pm, Dominik Vogt wrote:
} If a different "globbing" character would be easier to implement

No, that would not be easier.

} or a completely different way to allow partial searches in both
} words of the plant name at the same time

I can't think of anything that wouldn't require you to restructure the
file e.g. with colons instead of spaces.

} 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>

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

} (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.

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.

}   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".

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