summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2020-05-07 14:10:02 +0200
committerRicardo Wurmus <rekado@elephly.net>2020-05-07 14:10:02 +0200
commite0dc3c668ff23c2a5abd580ef9cee5d6414123cc (patch)
tree67416b20a98213e76430930e4fcd44464d34ccff
parent52ef2529c877b2b08ac67ebee8f1842b84720e90 (diff)
debbugs: Simplify mbox processing.
* mumi/debbugs.scm (read-emails-from-bug-log): Use mbox->emails instead of dropping lines haphazardly.
-rw-r--r--mumi/debbugs.scm19
1 files changed, 6 insertions, 13 deletions
diff --git a/mumi/debbugs.scm b/mumi/debbugs.scm
index 7873c86..c08a7bd 100644
--- a/mumi/debbugs.scm
+++ b/mumi/debbugs.scm
@@ -76,23 +76,16 @@ ends with ^C.
(#\etx
(let ((mails*
(if (member type keep)
- ;; TODO: This is very ugly. The first few
- ;; lines of the raw messages stored in Debbugs
- ;; logs seem to confuse the email parser, so we
- ;; try to strip them off.
- (let* ((content (string-join
- (drop-while (lambda (line)
- (or (string-prefix? "From " line)
- (string-prefix? "Received" line)
- (string-prefix? "\t" line)
- (string-prefix? " " line)))
- (reverse lines)) "\n"))
+ (let* ((contents (string-join (drop (reverse lines) 1) "\n"))
(mail (catch #t
(lambda ()
- (parse-email content))
+ (parse-email
+ (and=> (call-with-input-string contents mbox->emails)
+ first)))
(lambda args
(format (current-error-port)
- "failed to process email~%")
+ "failed to process email~% ~a~%"
+ args)
#f))))
(let ((id (and mail (assoc-ref (email-headers mail) 'message-id))))
(if (and id (not (hash-ref msgids id)))