zsh-users
 help / color / mirror / code / Atom feed
From: Dominik Vogt <dominik.vogt@gmx.de>
To: zsh-users@zsh.org
Subject: Re: Completions from file with zcompsys
Date: Tue, 20 Jun 2017 22:42:49 +0100	[thread overview]
Message-ID: <20170620214249.GA15063@gmx.de> (raw)
In-Reply-To: <170620123215.ZM6430@torch.brasslantern.com>

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

Oops.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt


  reply	other threads:[~2017-06-20 21:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-20  7:46 Dominik Vogt
2017-06-20 17:27 ` Bart Schaefer
2017-06-20 18:02   ` Dominik Vogt
2017-06-20 19:32     ` Bart Schaefer
2017-06-20 21:42       ` Dominik Vogt [this message]
2017-06-20 23:31         ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170620214249.GA15063@gmx.de \
    --to=dominik.vogt@gmx.de \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).