debbugs: Express extract-bug-numbers in terms of filter-index.
authorRicardo Wurmus <rekado@elephly.net>
Sun, 10 May 2020 08:25:41 +0000 (10:25 +0200)
committerRicardo Wurmus <rekado@elephly.net>
Sun, 10 May 2020 08:25:41 +0000 (10:25 +0200)
* mumi/debbugs.scm (extract-bug-numbers): Rewrite in terms of
filter-index.

mumi/debbugs.scm

index d50012799739e59f9ab34a20a00b447b9edec5d1..584665dfc4f479d5d7c72450e12d1a8630501f34 100644 (file)
@@ -138,22 +138,13 @@ search the index of archived issues."
   "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
 of archived issues."
-  (define index-file
-    (format #f "~a/spool/index.~a.realtime" (%config 'data-dir)
-            (if archived? "archive" "db")))
-  (define (extract-numbers port)
-    (let loop ((numbers '()))
-      (match (read-line port)
-        ((? eof-object? x) numbers)
-        (line
-         (cond
-          ((any (lambda (package)
-                  (string-prefix? package line))
-                packages)
-           (loop (cons (second (string-split line #\space))
-                       numbers)))
-          (else (loop numbers)))))))
-  (call-with-input-file index-file extract-numbers))
+  (filter-index (lambda (line)
+                  (any (lambda (package)
+                         (string-prefix? package line))
+                       packages))
+                (lambda (line)
+                  (second (string-split line #\space)))
+                #:archived? archived?))
 
 (define* (bug-id->log-file bug-id #:key archived?)
   (format #f "~a/spool/~a/~a/~a.log"