Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Asynchronous completions?
- X-seq: zsh-workers 44393
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Asynchronous completions?
- Date: Wed, 5 Jun 2019 00:01:59 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=aK47ntPJ5YxGATb15CfIIST3NtiMFm/YUQ7o1E2E7Mg=; b=I+P8V7F7XUHaihz6u+SV7Ij8+UDq8L7WSK3/6TqGoENxf0fKmFrDhIJK2aPowP74Bp k7fnV2mVq8EbjV7/vPoOh6ks5E8ca66FQDesPGmoCG4TKsYcArDKUx7/fTuXrFrveIkq wfgSYg+h06wXOzGPeiDdVpFKOmn28H9xcWt+fs8WzC8z2m+axeTkPKe9mqCIUBBhA6Dh ZWjRNknmhFVhUbP9aLgRPK1Lr1wSHuFJzWbRrWD1Hal3eME9M12Advxts5kVg4jN5X91 V9TROyZtXHZf1SxZtJP8CLIXZXMYCNLuS0C2vt1Fo6H4iAYAgX19ZLd/yfdtf9JKLIWf fF4A==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author