;;; -*-Scheme-*-
;;;
-;;; $Id: imail-core.scm,v 1.42 2000/05/08 14:59:06 cph Exp $
+;;; $Id: imail-core.scm,v 1.43 2000/05/08 15:30:45 cph Exp $
;;;
;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
;;;
\f
;;;; Message Navigation
-(define-generic first-unseen-message (folder))
-(define-method first-unseen-message ((folder <folder>))
- (let ((message (first-message folder)))
- (and message
- (let loop ((message message))
- (let ((next (next-message message)))
- (cond ((not next) message)
- ((message-seen? next) (loop next))
- (else next)))))))
+(define (first-unseen-message folder)
+ (let ((end (folder-length folder)))
+ (and (> end 0)
+ (let loop ((start (first-unseen-message-index folder)))
+ (let ((message (get-message folder start)))
+ (if (and (message-seen? message) (< (+ start 1) end))
+ (loop (+ start 1))
+ message))))))
+
+(define-generic first-unseen-message-index (folder))
+(define-method first-unseen-message-index ((folder <folder>))
+ folder
+ 0)
(define (first-message folder)
(and (> (folder-length folder) 0)
;;; -*-Scheme-*-
;;;
-;;; $Id: imail-imap.scm,v 1.20 2000/05/08 15:04:01 cph Exp $
+;;; $Id: imail-imap.scm,v 1.21 2000/05/08 15:30:49 cph Exp $
;;;
;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
;;;
(guarantee-imap-folder-open folder)
(vector-ref (imap-folder-messages folder) index))
-(define-method unseen-message ((folder <imap-folder>))
+#|
+;; There's no guarantee that UNSEEN is kept up to date by the server.
+;; So unless we want to manually update it, it's useless.
+(define-method first-unseen-message-index ((folder <imap-folder>))
(guarantee-imap-folder-open folder)
- (let ((unseen (imap-folder-unseen folder)))
- (and unseen
- (get-message folder unseen))))
+ (or (imap-folder-unseen folder) 0))
+|#
(define-method append-message ((folder <imap-folder>) (message <message>))
(guarantee-imap-folder-open folder)
connection 'FETCH (+ index 1) items))
(define (imap:command:fetch-range connection start end items)
- (if (fix:< start end)
+ (if (< start end)
(imap:command:multiple-response imap:response:fetch?
connection 'FETCH
(cons 'ATOM
((imap:response:fetch? response)
(process-fetch-attributes
(get-message (selected-imap-folder connection)
- (fix:- (imap:response:fetch-index response) 1))
+ (- (imap:response:fetch-index response) 1))
response)
(eq? command 'FETCH))
(else