summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2020-05-10 10:25:23 +0200
committerRicardo Wurmus <rekado@elephly.net>2020-05-10 10:25:23 +0200
commit02736dc1ff80db306394edd9fdb3a200fd677f71 (patch)
tree734df2bb1b0b137e0aeaf32c53959290e8ad740c
parent513ff3928725da18f9fa4123be43ef12a63a07c2 (diff)
debbugs: Add filter-index.
* mumi/debbugs.scm (filter-index): New procedure.
-rw-r--r--mumi/debbugs.scm18
1 files changed, 18 insertions, 0 deletions
diff --git a/mumi/debbugs.scm b/mumi/debbugs.scm
index 7873c86..d500127 100644
--- a/mumi/debbugs.scm
+++ b/mumi/debbugs.scm
@@ -116,6 +116,24 @@ ends with ^C.
(loop msgids mails lines type skip?)
(loop msgids mails (cons line lines) type skip?))))))))
+(define* (filter-index pred proc #:key archived?)
+ "Open up a Debbugs index file and collect the result of applying
+PROC to those lines that match the predicate PRED. If ARCHIVED? is #T
+search the index of archived issues."
+ (define index-file
+ (format #f "~a/spool/index.~a.realtime" (%config 'data-dir)
+ (if archived? "archive" "db")))
+ (call-with-input-file index-file
+ (lambda (port)
+ (let loop ((result '()))
+ (match (read-line port)
+ ((? eof-object? x) result)
+ (line
+ (cond
+ ((pred line)
+ (loop (cons (proc line) result)))
+ (else (loop result)))))))))
+
(define* (extract-bug-numbers packages #:key archived?)
"Open up a Debbugs index file and return the bug numbers for those
lines that match one of PACKAGES. If ARCHIVED? is #T search the index