From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: Completions from file with zcompsys
Date: Tue, 20 Jun 2017 12:32:15 -0700 [thread overview]
Message-ID: <170620123215.ZM6430@torch.brasslantern.com> (raw)
In-Reply-To: <20170620180214.GA5281@gmx.de>
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".
next prev parent reply other threads:[~2017-06-20 19:31 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 [this message]
2017-06-20 21:42 ` Dominik Vogt
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=170620123215.ZM6430@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--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).