From b78f40cb0aa53db929d95ec5575fb68b66dae9da Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Mon, 8 May 2000 15:30:49 +0000 Subject: [PATCH] Change handling of FIRST-UNSEEN-MESSAGE; ignore IMAP's UNSEEN response as it is insufficiently constrained to be useful. --- v7/src/imail/imail-core.scm | 24 ++++++++++++++---------- v7/src/imail/imail-imap.scm | 16 +++++++++------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/v7/src/imail/imail-core.scm b/v7/src/imail/imail-core.scm index a9aac0c9e..080a0dece 100644 --- a/v7/src/imail/imail-core.scm +++ b/v7/src/imail/imail-core.scm @@ -1,6 +1,6 @@ ;;; -*-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 ;;; @@ -405,15 +405,19 @@ ;;;; Message Navigation -(define-generic first-unseen-message (folder)) -(define-method first-unseen-message ((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 + 0) (define (first-message folder) (and (> (folder-length folder) 0) diff --git a/v7/src/imail/imail-imap.scm b/v7/src/imail/imail-imap.scm index 29d6f04fe..b95cc48b2 100644 --- a/v7/src/imail/imail-imap.scm +++ b/v7/src/imail/imail-imap.scm @@ -1,6 +1,6 @@ ;;; -*-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 ;;; @@ -395,11 +395,13 @@ (guarantee-imap-folder-open folder) (vector-ref (imap-folder-messages folder) index)) -(define-method unseen-message ((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 )) (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 ) (message )) (guarantee-imap-folder-open folder) @@ -450,7 +452,7 @@ 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 @@ -645,7 +647,7 @@ ((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 -- 2.25.1