[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master adb29b0 4/4: Merge commit '46bfe80d1d0c0ba6cf1a4593b55af11

From: Thierry Volpiatto
Subject: [elpa] master adb29b0 4/4: Merge commit '46bfe80d1d0c0ba6cf1a4593b55af11cd943c697'
Date: Thu, 3 Nov 2016 18:45:07 +0000 (UTC)

branch: master
commit adb29b0d466293f57334c47aac653a3ed0670dad
Merge: d78b6bf 46bfe80
Author: Thierry Volpiatto <address@hidden>
Commit: Thierry Volpiatto <address@hidden>

    Merge commit '46bfe80d1d0c0ba6cf1a4593b55af11cd943c697'
 packages/async/async.el |   26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/packages/async/async.el b/packages/async/async.el
index 7b875ac..99162cb 100644
--- a/packages/async/async.el
+++ b/packages/async/async.el
@@ -298,13 +298,16 @@ 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)))
+(defun async--fold-left (fn forms bindings)
+  (let ((res forms))
+    (dolist (binding bindings)
+      (setq res (funcall fn res
+                         (if (listp binding)
+                             binding
+                             (list binding)))))
-(defmacro async-let (bindings forms)
+(defmacro async-let (bindings &rest forms)
   "Implements `let', but each binding is established asynchronously.
 For example:
@@ -319,12 +322,17 @@ For example:
      (async-start (bar)
       (lambda (y)
         (message \"%s %s\" x y)))))"
+  (declare (indent 1))
    (lambda (acc binding)
-     `(async-start ,(cadr binding)
-                   (lambda (,(car binding))
-                     ,acc)))
-   forms (reverse bindings)))
+     (let ((fun (pcase (cadr binding)
+                  ((and (pred functionp) f) f)
+                  (f `(lambda () ,f)))))
+       `(async-start ,fun
+                     (lambda (,(car binding))
+                       ,acc))))
+   `(progn ,@forms)
+   (reverse bindings)))
 (provide 'async)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]