Open cireu opened 5 years ago
Nice idea. And the code looks good. Can you post a full ivy-read
demo?
I think it would be nice to:
counsel-async-filter-update-time
if needed,counsel--async-filter
re-use this new function.introduce this function
My idea is to introduce such API.
(defun ivy-build-async-candidates (fetcher &optional awaiting-message)
"Build a asynchronous candidates collection for ivy completing session.
FETCHER should accept `ivy--async-callback' as arguements, and call it
each time new candidates arrives with candidates, candidates should be
a string or a list of strings.
AWAITING-MESSAGE will be shown when there's no candidates have been arrived.
"
(error "Unimplemented!"))
But there are some problems I encountered and some behaviours I can't confirm.
How to do the clean up? If a completing session was aborted manually (like C-g
), callback should stop accepting and inserting candidates. Should we force user to pass :unwind
to ivy-read
to do this (like counsel--async-command
based fucntions) or modified the definition of ivy-read
to do the clean up automatically? Or someone have better idea.
What kind of result should be called with ivy--async-callback
, a list of strings or more?
maybe make it use a logic similar to counsel-async-filter-update-time if needed, have counsel--async-filter re-use this new function.
I think these can be easily done, if we can confirm the choive above.
We have
counsel--async-command
to call shell command for completion candidates, however this command doesn't suitable for generalized async work. E.g.url-retrieve
.I try a beta version of async callback to insert candidate to current ivy completing session