zsh-workers
 help / color / mirror / code / Atom feed
* Asynchronous completions?
@ 2019-06-04 22:01 Sebastian Gniazdowski
  2019-06-05  7:57 ` Mikael Magnusson
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Gniazdowski @ 2019-06-04 22:01 UTC (permalink / raw)
  To: Zsh hackers list

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-05  9:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-04 22:01 Asynchronous completions? Sebastian Gniazdowski
2019-06-05  7:57 ` Mikael Magnusson
2019-06-05  9:47   ` Peter Stephenson

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