Record mailbox size changes of selected IMAP4 mailbox.  Required to
comply with RFC 3501, section 7.3 and 7.4.1.

Note: EXPUNGE response is recognized to decrement number of
messages in mailbox only.
* elmo-imap4.el (elmo-imap4-mailbox-size-update-maybe): Build list of
  expunged messages only when response contains expunge.
Remove usage of kill file to adjust message counter.

The kill file contains cons' with ranges of UIDs that are considered
'killed', i.e. hidden from user's view.  But these ranges cannot be
used to adjust counter of total messages in a IMAP4 mailbox: A range
of (1 . 100) does not necessarily refer to 100 messages.  E.g. if
there are 100 messages in the mailbox with UID ranging from 1 to 100
and you delete the first message, the range (1 . 100) refers to 99
messages.
* 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-imap4.el (elmo-imap4-mailbox-selected-p): New macro.
Return non-nil if mailbox is selected in session.
(elmo-imap4-session-select-mailbox): Use macro
`elmo-imap4-mailbox-selected-p'.
(elmo-folder-exists-p-plugged): Dto.
(elmo-folder-check-plugged): Dto.
(elmo-imap4-folder-diff-plugged): Dto.
* elmo-imap4.el (elmo-imap4-mailbox-selected-p): Fix typo.
2010-07-02  David Maus  <dmaus@ictsoc.de>

	* elmo-imap4.el (elmo-server-diff-async): Remove.  Unused luna
	method.
	(elmo-imap4-folder-status-plugged): Close mailbox before calling
	STATUS if it is selected.  If
	`elmo-imap4-use-select-to-update-status' is non-nil, do the
	opposite.
2010-07-02  David Maus  <dmaus@ictsoc.de>

	* elmo-imap4.el (elmo-imap4-folder-status-plugged): Remove usage of kill file to
	adjust message counter.
2010-07-02  David Maus  <dmaus@ictsoc.de>

    * elmo-imap4.el (elmo-folder-next-message-number-plugged): Close
    mailbox before calling STATUS if selected.  If
    `elmo-imap4-use-select-to-update-status' is non-nil, do the opposite.
* elmo-imap4.el (elmo-imap4-mailbox-size-update-maybe): Ignore
EXPUNGE responses.
(elmo-imap4-mailbox-size-update-maybe): Use latest EXIST or RECENT
response value.

If the mailbox size changes due to EXPUNGE by another client the
server will inform us with a EXISTS or RECENT response.  If the
expunging didn't change the mailbox size the server might not do so.

If there are more than one EXISTS or RECENT response, use the latest.
elmo-imap4.el (elmo-imap4-session-deselect-mailbox): New function.
Leave selected state without causing silent EXPUNGE.
(elmo-imap4-folder-status-plugged, elmo-folder-rename-internal): Use
function.
* 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.
Merged trunk to elmo-imap4-compliance
Add optional fourth argument, return number of appended message if possible

* elmo.el (elmo-folder-append-buffer): Add optional fourth
  argument, return number of appended message if possible.
* elmo-pipe.el (elmo-folder-append-buffer): Dto.
* elmo-maildir.el (elmo-folder-append-buffer): Dto.
* elmo-flag.el (elmo-folder-append-buffer): Dto.
* elmo-localdir.el (elmo-folder-append-buffer): Dto.
* elmo-filter.el (elmo-folder-append-buffer): Dto.
* elmo-cache.el (elmo-folder-append-buffer): Dto.
* elmo-archive.el (elmo-folder-append-buffer)
(elmo-archive-folder-append-buffer): Dto.
Return number of appended message, implemented all except IMAP

* elmo-maildir.el (elmo-folder-append-buffer): Return number of
appended message.
* elmo-localdir.el (elmo-folder-append-buffer): Dto.
* elmo-archive.el (elmo-archive-folder-append-buffer): Dto.
Return uid of append message if requested

* elmo-date.el (elmo-time-make-imap-date-string): New
function. Return IMAP4 compliant date string.

* elmo-imap4.el (elmo-folder-append-buffer): Return uid of append
message if requested.
Obtain number of appended draft message by `elmo-folder-append-buffer'

* wl-draft.el (wl-draft-save): Obtain number of appended draft message
by `elmo-folder-append-buffer', handle case UID of appended message
could not be found.
Merged trunk to branch elmo-imap4-compliance
Implement new IMAP search feature, proposed by egh@e6h.org

2011-07-17  David Maus  <dmaus@ictsoc.de>

	* elmo-util.el (elmo-list-difference): New function. Return
	difference of two lists.
	* elmo-imap4.el (elmo-imap4-search-generate-vector): Use function.

2011-07-03  Erik Hetzner  <egh@e6h.org>

	* elmo-imap4.el (elmo-imap4-search-internal-primitive): Removed.
	(elmo-imap4-search-build-full-command): New function. Build full
	IMAP search command.
	(elmo-imap4-search-perform): New function. Perform IMAP search.
	(elmo-imap4-search-generate-vector): New function. Generate search
	vector.
	(elmo-imap4-search-mergeable-p): New function. Return non-nil if
	two search conditions are mergeable.
	(elmo-imap4-search-mergeable-charset): New function. Return
	charset of two searches for merging.
	(elmo-imap4-search-generate-uid): New function. Return search for
	a set of messages.
	(elmo-imap4-search-generate-and): New function. Return search that
	returns intersection of two search commands.
	(elmo-imap4-search-generate-or): New function. Return search that
	returns union of two search commands.
	(elmo-imap4-search-generate): New function. Return search in
	folder.
	(elmo-imap4-search-internal): Use new search functions.
Correctly get the number of the appended message

* elmo-maildir.el (elmo-folder-append-buffer): Correctly get the
number of the appended message.