From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Asynchronous completions?
Date: Wed, 5 Jun 2019 00:01:59 +0200 [thread overview]
Message-ID: <CAKc7PVA-342v=iFVk5dR5fOZ+2N3iEQQU9dOzYHycwuUWUi3mA@mail.gmail.com> (raw)
Hello,
I've just waited a bit after: git checkout <TAB>. The delay was caused
by the completion script loading all revisions, while I only wanted
branches.
This gave me an idea – to use exec {FD}< <(...) and zle -F to update
the completion, after first displaying "Loading all revisions". In one
project I'm passing as much as 13000 lines through the {FD} after each
keypress without any problems.
The method is very simple, e.g.:
handler() { (git)-[feature/redrawhook]
local IFS=$'\n'
read -u $FD line
zle -F $FD # Better not forget about this, strange things happen
zle -M "$line"
}
zle -N handler
exec {FD}< <(sleep 2; echo Hello World)
true # workaround pre-5.7.1-dev-0 bug fixed in 44214
zle -F -w $FD handler
I'm not familiar with coding completions. Could someone else start the
async-completions trend?
For more examples on the <(...) / zle -F technique take a look at a
patch that introduced asynchronous man-database query into
fast-syntax-highlighting (to highlight if a man page given is correct
or not): https://github.com/zdharma/fast-syntax-highlighting/commit/3e7d5eb0eb70d5c570a680da3ae49d26e1a77f69
--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org
next reply other threads:[~2019-06-04 22:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-04 22:01 Sebastian Gniazdowski [this message]
2019-06-05 7:57 ` Mikael Magnusson
2019-06-05 9:47 ` Peter Stephenson
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='CAKc7PVA-342v=iFVk5dR5fOZ+2N3iEQQU9dOzYHycwuUWUi3mA@mail.gmail.com' \
--to=sgniazdowski@gmail.com \
--cc=zsh-workers@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).