[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/excorporate 12f3501 28/93: packages/excorporate: Extend
From: |
Stefan Monnier |
Subject: |
[elpa] externals/excorporate 12f3501 28/93: packages/excorporate: Extend exco-connection-iterate |
Date: |
Sun, 29 Nov 2020 15:43:02 -0500 (EST) |
branch: externals/excorporate
commit 12f350118af14fab5623c3675205df4e86f81b2b
Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Commit: Thomas Fitzsimmons <fitzsim@fitzsim.org>
packages/excorporate: Extend exco-connection-iterate
* packages/excorporate/excorporate.el (exco-connection-iterate):
Add optional callback-will-call-finalize argument. Allow callback
to call finalize function.
---
excorporate.el | 50 ++++++++++++++++++++++++++++++++++++++------------
1 file changed, 38 insertions(+), 12 deletions(-)
diff --git a/excorporate.el b/excorporate.el
index 314be8b..a767ce2 100644
--- a/excorporate.el
+++ b/excorporate.el
@@ -743,23 +743,49 @@ arguments, IDENTIFIER and the server's response."
(defun exco-connection-iterate (initialize-function
per-connection-function
per-connection-callback
- finalize-function)
+ finalize-function
+ &optional callback-will-call-finalize)
"Iterate Excorporate connections.
-Call INITIALIZE-FUNCTION once before iterating.
-Call PER-CONNECTION-FUNCTION for each connection.
-Pass PER-CONNECTION-CALLBACK to PER-CONNECTION-FUNCTION.
-Call FINALIZE-FUNCTION after all operations have responded."
+Call INITIALIZE-FUNCTION once before iterating. It takes no
+arguments.
+
+Call PER-CONNECTION-FUNCTION once for each server connection. It
+is run synchronously. It accepts two arguments, IDENTIFIER, the
+current server connection, and CALLBACK, which is a wrapped
+version of PER-CONNECTION-CALLBACK.
+
+PER-CONNECTION-CALLBACK takes a variable number of arguments,
+depending on which callback it is. If
+CALLBACK-WILL-CALL-FINALIZE is non-nil, it takes a final
+FINALIZE-FUNCTION argument, which is a countdown-wrapped
+finalizer function that PER-CONNECTION-CALLBACK should call (or
+arrange to be called asynchronously) each time it is invoked.
+
+If CALLBACK-WILL-CALL-FINALIZE is non-nil, this function will not
+call FINALIZE-FUNCTION itself. Instead it will wrap
+FINALIZE-FUNCTION into a function that can be called once per
+connection, then pass the wrapped finalizer to the callback as an
+argument. CALLBACK-WILL-CALL-FINALIZE must be set if the
+callback needs to make a recursive asynchronous call."
(exco--ensure-connection)
(funcall initialize-function)
- (let ((responses 0)
- (connection-count (length exco--connection-identifiers)))
+ (let* ((countdown (length exco--connection-identifiers))
+ (wrapped-finalizer
+ (lambda (&rest arguments)
+ (setq countdown (1- countdown))
+ (when (equal countdown 0)
+ (apply finalize-function arguments))))
+ (wrapped-callback
+ (lambda (&rest arguments)
+ (apply per-connection-callback
+ (append arguments
+ (when callback-will-call-finalize
+ (list wrapped-finalizer))))
+ (unless callback-will-call-finalize
+ (funcall wrapped-finalizer)))))
(dolist (identifier exco--connection-identifiers)
(funcall per-connection-function identifier
- (lambda (&rest arguments)
- (setq responses (1+ responses))
- (apply per-connection-callback arguments)
- (when (equal responses connection-count)
- (funcall finalize-function)))))))
+ wrapped-callback))))
;; User-visible functions and variables.
(defgroup excorporate nil
- [elpa] externals/excorporate 2a55a64 04/93: packages/excorporate: Handle nil list of main invitees, (continued)
- [elpa] externals/excorporate 2a55a64 04/93: packages/excorporate: Handle nil list of main invitees, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate bff9b00 07/93: packages/excorporate: Change server version lookup, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 37b25ff 09/93: packages/excorporate: Acknowledge Erik Hetzner, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate fae1f5e 05/93: packages/excorporate: Update manual, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 9cc18b1 10/93: packages/excorporate: Require soap-client 3.1.1, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 09f998e 11/93: packages/excorporate: Bump version to 0.7.2, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate f35c2f1 13/93: packages/excorporate/excorporate-org.el: Allow quitting window, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate e6cb302 15/93: packages/excorporate: Interoperate with LaTeX preview, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate bdf9d5a 16/93: packages/excorporate: Bump version to 0.7.4, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate fd9a7bb 25/93: excorporate-calfw.el: Enable clean byte-compiling in GNU ELPA, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 12f3501 28/93: packages/excorporate: Extend exco-connection-iterate,
Stefan Monnier <=
- [elpa] externals/excorporate de3ad68 46/93: Excorporate: Document new configuration wizard, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate cd392a1 40/93: excorporate-diary: Escape literal percent signs, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate acbc123 22/93: excorporate.texi: Increase authentication success likelihood, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate a1ec101 26/93: excorporate.el: Require org for org-trim, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 836db8c 35/93: packages/excorporate: Bump version to 0.8.1, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 0d20739 41/93: excorporate-diary: Fix documentation string, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 6d8fa65 19/93: packages/excorporate: Acknowledge Fabio Leimgruber, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 3e13cee 24/93: excorporate-calfw.el: Rename from excorporate-calfw.el.txt, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 33ee501 31/93: packages/excorporate: Update documentation for Diary support, Stefan Monnier, 2020/11/29
- [elpa] externals/excorporate 882f2e0 44/93: excorporate-diary: Suppress compilation warning, Stefan Monnier, 2020/11/29