Factor out with-mbase-progress.
This commit is contained in:
parent
a56605fa3f
commit
350f7eca60
3 changed files with 34 additions and 17 deletions
|
@ -58,6 +58,9 @@
|
|||
mbase-active-emails
|
||||
|
||||
mbase-merge-mailman
|
||||
|
||||
do-with-mbase-progress%
|
||||
with-mbase-progress%
|
||||
)
|
||||
|
||||
(import scheme
|
||||
|
@ -288,4 +291,29 @@
|
|||
mb
|
||||
emails)))
|
||||
|
||||
;; Iteration with progress over all members
|
||||
(define (do-with-mbase-progress% mb name proc)
|
||||
(let* ((members-list (find-members-by-predicate mb brmember-existing?))
|
||||
(mlen0 (length members-list))
|
||||
(mlen (if (> mlen0 0)
|
||||
mlen0
|
||||
1)))
|
||||
(with-progress%
|
||||
#t name
|
||||
(let loop ((mb members-list)
|
||||
(i 0))
|
||||
(if (not (null? mb))
|
||||
(let ()
|
||||
(progress%-advance (/ i mlen))
|
||||
(proc (car mb))
|
||||
(loop (cdr mb)
|
||||
(add1 i))))
|
||||
(progress%-advance 1)))))
|
||||
|
||||
;; Simple syntax wrapper
|
||||
(define-syntax with-mbase-progress%
|
||||
(syntax-rules ()
|
||||
((_ mb name mr body ...)
|
||||
(do-with-mbase-progress% mb name (lambda (mr) body ...)))))
|
||||
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue