[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/async a2196f7 03/60: Add `async-let' macro
From: |
Stefan Monnier |
Subject: |
[elpa] externals/async a2196f7 03/60: Add `async-let' macro |
Date: |
Tue, 8 Oct 2019 10:11:27 -0400 (EDT) |
branch: externals/async
commit a2196f7d8d579d41f856b3d66f320158f641898c
Author: John Wiegley <address@hidden>
Commit: John Wiegley <address@hidden>
Add `async-let' macro
---
async.el | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/async.el b/async.el
index 3798c95..a280d3d 100644
--- a/async.el
+++ b/async.el
@@ -298,6 +298,34 @@ returns nil. It can still be useful, however, as an
argument to
"Evaluate FUNC in a separate Emacs process, synchronously."
`(async-get (async-start ,func)))
+(defun async--fold-left (f z xs)
+ (let ((res z))
+ (dolist (x xs)
+ (setq res (funcall f res x)))
+ res))
+
+(defmacro async-let (bindings forms)
+ "Implements `let', but each binding is established asynchronously.
+For example:
+
+ (async-let ((x (foo))
+ (y (bar)))
+ (message "%s %s" x y))
+
+ expands to ==>
+
+ (async-start (foo)
+ (lambda (x)
+ (async-start (bar)
+ (lambda (y)
+ (message "%s %s" x y)))))"
+ (async--fold-left
+ (lambda (acc binding)
+ `(async-start ,(cadr binding)
+ (lambda (,(car binding))
+ ,acc)))
+ forms (reverse bindings)))
+
(provide 'async)
;;; async.el ends here
- [elpa] externals/async updated (1794ea4 -> f61f1db), Stefan Monnier, 2019/10/08
- [elpa] externals/async 5813c24 04/60: Add some string escapes, Stefan Monnier, 2019/10/08
- [elpa] externals/async 0190fb8 05/60: Allow passing any value to async-let bindings., Stefan Monnier, 2019/10/08
- [elpa] externals/async 9ff4d18 12/60: Revert renaming of async-wait to async--wait (#71)., Stefan Monnier, 2019/10/08
- [elpa] externals/async d1273c8 13/60: Using sleep-for instead of sit-for in async-wait prevent infloop (#71)., Stefan Monnier, 2019/10/08
- [elpa] externals/async 8bc0678 01/60: Fix home url in *pkg.el., Stefan Monnier, 2019/10/08
- [elpa] externals/async a2196f7 03/60: Add `async-let' macro,
Stefan Monnier <=
- [elpa] externals/async 1dd865c 09/60: Add some documentation in README for async-let., Stefan Monnier, 2019/10/08
- [elpa] externals/async 57f5d81 06/60: Allow passing multiple forms to async-let, Stefan Monnier, 2019/10/08
- [elpa] externals/async 31b1691 02/60: Don't query in set-visited-file-name., Stefan Monnier, 2019/10/08
- [elpa] externals/async 8242878 08/60: Merge pull request #69 from jwiegley/async_let, Stefan Monnier, 2019/10/08
- [elpa] externals/async 2018523 15/60: Inject nsm-* vars in smtp-mail for emacs-25+ (#75)., Stefan Monnier, 2019/10/08
- [elpa] externals/async 666066d 14/60: Merge pull request #72 from jwiegley/Fix_async_ready, Stefan Monnier, 2019/10/08
- [elpa] externals/async 54977d6 10/60: Improve formatting in README., Stefan Monnier, 2019/10/08
- [elpa] externals/async e1a3735 20/60: Merge branch 'master' of github.com:jwiegley/emacs-async, Stefan Monnier, 2019/10/08
- [elpa] externals/async d6222c2 22/60: Ensure wdired-use-interactive-rename is disabled., Stefan Monnier, 2019/10/08
- [elpa] externals/async d422df5 24/60: Add new var to allow calling emacs with -Q or -q (#80)., Stefan Monnier, 2019/10/08