New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run prompts asynchronously #482

Closed
xiaq opened this Issue Sep 17, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@xiaq
Member

xiaq commented Sep 17, 2017

Sometimes prompts can take a long time and will block the UI. In that case, Elvish can render the prompt as a placeholder (say "?") and update it when the function completes.

@xiaq xiaq added this to the 0.11 milestone Sep 17, 2017

@zzamboni

This comment has been minimized.

Contributor

zzamboni commented Sep 18, 2017

This would be very nice, with a couple of considerations:

  • Don't use "?" - better cache the previous value and use that
  • Run asynchronously but not overlapping - otherwise we have a potential explosion of simultaneous number of prompt commands running at the same time.
@therealpxc

This comment has been minimized.

therealpxc commented Sep 18, 2017

Are there any shells that currently do this right? This would be a pretty nice feature and hugely increase the perceived 'performance' of Elvish for people who use VCS prompts.

@xiaq xiaq closed this in dd2d36a Nov 12, 2017

@xiaq

This comment has been minimized.

Member

xiaq commented Nov 12, 2017

Good news, this has landed in master. To see it in action, try this:

edit:prompt = { echo 'slow prompt'; sleep 1 }
edit:-prompts-max-wait = 0.05

Read dd2d36a for a detailed explanation and caveat.

zzamboni added a commit to zzamboni/dot-elvish that referenced this issue Nov 14, 2017

Removed caching and documented using org-mode
With Elvish now supporting prompt caching
(elves/elvish#482), I have removed the whole
caching implementation from the prompt, which was messy and unreliable.

I have also used the opportunity to write the code in literate
programming style, using org-mode. See chain.org for the fully
documented source code, from which chain.elv is generated.

For an excellent introduction to literate programming using org-mode, see
http://www.howardism.org/Technical/Emacs/literate-programming-tutorial.html.
@zzamboni

This comment has been minimized.

Contributor

zzamboni commented Nov 14, 2017

@xiaq this is great! I have vastly simplified my chain theme implementation thanks to this new feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment