Skip to content
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
Closed

Run prompts asynchronously #482

xiaq opened this issue Sep 17, 2017 · 4 comments
Milestone

Comments

@xiaq
Copy link
Member

@xiaq 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 the enhancement label Sep 17, 2017
@xiaq xiaq added this to the 0.11 milestone Sep 17, 2017
@zzamboni
Copy link
Contributor

@zzamboni 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
Copy link

@therealpxc 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
Copy link
Member Author

@xiaq 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
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
Copy link
Contributor

@zzamboni 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants