From 1e26074a0b25a621d51dec1edb659d6d7c8d6337 Mon Sep 17 00:00:00 2001 From: dmaus Date: Wed, 5 May 2010 17:00:44 +0000 Subject: [PATCH] * elmo-imap4.el (elmo-imap4-mailbox-size-update-maybe): Use simpler method to count expunged messages. (elmo-imap4-folder-diff-plugged): Use NOOP and SEARCH when called for selected mailbox. --- elmo/ChangeLog | 10 ++++++++++ elmo/elmo-imap4.el | 52 +++++++++++++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/elmo/ChangeLog b/elmo/ChangeLog index bf7c08c..6b2f155 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,9 +1,19 @@ +2010-05-05 David Maus + + * elmo-imap4.el (elmo-imap4-mailbox-size-update-maybe): Use + simpler method to count expunged messages. + (elmo-imap4-folder-diff-plugged): Use NOOP and SEARCH when called + for selected mailbox. + 2010-04-17 David Maus * elmo-imap4.el (elmo-imap4-mailbox-size-update-maybe): Build list of expunged messages only when response contains expunge. (elmo-imap4-folder-diff-plugged): Removed usage of kill file to adjust message counter. + (elmo-imap4-folder-diff-plugged): When mailbox is selected, search + for unread messages, call noop to maybe update mailbox size and + return recorded size of mailbox. 2010-04-16 David Maus diff --git a/elmo/elmo-imap4.el b/elmo/elmo-imap4.el index 3ad7574..f304809 100644 --- a/elmo/elmo-imap4.el +++ b/elmo/elmo-imap4.el @@ -285,20 +285,20 @@ Debug information is inserted in the buffer \"*IMAP4 DEBUG*\"") "Update size of selected mailbox in SESSION according to RESPONSE." (let ((exists (elmo-imap4-response-value response 'exists)) (recent (elmo-imap4-response-value response 'recent)) - (expunge (if (assq 'expunge response) - (delq nil (mapcar '(lambda (r) - (if (eq (car r) 'expunge) - (cadr r))) - response)))) (current-size (or (elmo-imap4-session-current-mailbox-size-internal - session) (cons nil nil)))) - (when (or expunge exists recent) - (when expunge + session) (cons nil nil))) + (expunge 0)) + (when (assq 'expunge response) + (mapc '(lambda (r) + (if (eq (car r) 'expunge) + (setq expunge (1+ expunge)))) response)) + (when (or (> expunge 0) exists recent) + (when (> expunge 0) (if (null (car current-size)) (elmo-imap4-debug "[%s] -> (bug) cannot reduce mailbox size" (format-time-string "%T")) (setcar current-size (- (car current-size) - (length expunge))))) + expunge)))) (if exists (setcar current-size exists)) (if recent (setcdr current-size recent)) (elmo-imap4-session-set-current-mailbox-size-internal @@ -2551,18 +2551,28 @@ If optional argument REMOVE is non-nil, remove FLAG." (elmo-imap4-session-select-mailbox session (elmo-imap4-folder-mailbox-internal folder))) - (setq response - (elmo-imap4-send-command-wait session - (list - "status " - (elmo-imap4-mailbox - (elmo-imap4-folder-mailbox-internal - folder)) - " (recent unseen messages)"))) - (setq response (elmo-imap4-response-value response 'status)) - (setq messages (elmo-imap4-response-value response 'messages)) - (setq new (elmo-imap4-response-value response 'recent) - unread (elmo-imap4-response-value response 'unseen)) + (if (string= (elmo-imap4-session-current-mailbox-internal session) + (elmo-imap4-folder-mailbox-internal folder)) + (progn + (elmo-imap4-send-command-wait session "noop") + (setq unread (length (elmo-imap4-folder-list-flagged folder 'unread))) + (setq messages + (car (elmo-imap4-session-current-mailbox-size-internal + session)) + new (cdr (elmo-imap4-session-current-mailbox-size-internal + session)))) + (setq response + (elmo-imap4-send-command-wait session + (list + "status " + (elmo-imap4-mailbox + (elmo-imap4-folder-mailbox-internal + folder)) + " (recent unseen messages)"))) + (setq response (elmo-imap4-response-value response 'status)) + (setq messages (elmo-imap4-response-value response 'messages)) + (setq new (elmo-imap4-response-value response 'recent) + unread (elmo-imap4-response-value response 'unseen))) (if (< unread new) (setq new unread)) (list new unread messages))) -- 1.7.10.4