From a0fbfb80fbe4ccac4196b85ebc79015eb2a38d08 Mon Sep 17 00:00:00 2001 From: dmaus Date: Tue, 31 Aug 2010 18:34:21 +0000 Subject: [PATCH] * elmo-imap4.el (elmo-folder-delete-messages-plugged): Use smarter mechanism to expunge messages. If there are already messages in the mailbox with the \Deleted flag set, use following algorithm to delete only our messages: If `elmo-imap4-use-uid' is non-nil, and the server supports the UIDPLUS extension, use the UID EXPUNGE command. Otherwise temporarily remove \Deleted flag, call EXPUNGE, and restore the flag. If `elmo-imap4-use-uid' is nil, use old mechanism and prompt the user. --- elmo/ChangeLog | 5 +++++ elmo/elmo-imap4.el | 23 +++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/elmo/ChangeLog b/elmo/ChangeLog index d73c05b..c27a057 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,8 @@ +2010-08-31 David Maus + + * elmo-imap4.el (elmo-folder-delete-messages-plugged): Use smarter + mechanism to expunge messages. + 2010-08-04 David Maus * elmo-imap4.el (elmo-imap4-session-deselect-mailbox): New diff --git a/elmo/elmo-imap4.el b/elmo/elmo-imap4.el index a8a97d4..134223e 100644 --- a/elmo/elmo-imap4.el +++ b/elmo/elmo-imap4.el @@ -2286,17 +2286,28 @@ If optional argument REMOVE is non-nil, remove FLAG." (luna-define-method elmo-folder-delete-messages-plugged ((folder elmo-imap4-folder) numbers) (let ((session (elmo-imap4-get-session folder)) - (expunge - (or (null (elmo-imap4-list folder "deleted")) - (y-or-n-p - "There's hidden deleted messages, expunge anyway?")))) + (deleted (elmo-imap4-list folder "deleted"))) (elmo-imap4-session-select-mailbox session (elmo-imap4-folder-mailbox-internal folder)) (unless (elmo-imap4-set-flag folder numbers "\\Deleted") (error "Failed to set deleted flag")) - (when expunge - (elmo-imap4-send-command-wait session "expunge")) + (cond + ((and deleted elmo-imap4-use-uid + (elmo-imap4-session-capable-p session 'uidplus)) + (elmo-imap4-send-command-wait + session (list + "uid expunge " + (mapconcat 'number-to-string numbers ",")))) + ((and deleted elmo-imap4-use-uid) + (unless (elmo-imap4-set-flag folder deleted "\\Deleted" 'remove) + (error "Failed to temporarily remove deleted flag")) + (elmo-imap4-send-command-wait session "expunge") + (unless (elmo-imap4-set-flag folder deleted "\\Deleted") + (error "Failed to restore deleted flags"))) + ((or (null deleted) + (y-or-n-p "There are hidden deleted messages. Expunge anyway?")) + (elmo-imap4-send-command-wait session "expunge"))) t)) (defun elmo-imap4-detect-search-charset (string) -- 1.7.10.4