+ (setq file-flag 'important
+ mark elmo-msgdb-important-mark))
+ ((member location answered-list)
+ (setq file-flag 'answered
+ mark (elmo-msgdb-mark 'answered cache-status)))
+ ((member location unread-list)
+ (setq file-flag 'unread
+ mark (elmo-msgdb-mark 'unread cache-status)))
+ (t (setq file-flag 'read)))
+
+ ;; Set mark according to flag-table if file status is unread or read.
+ (when (or (eq file-flag 'read)
+ (eq file-flag 'unread))
+ ;;
+ (unless (eq 'read flag)
+ (setq mark (elmo-msgdb-mark flag cache-status 'new)))
+ ;; Update filename's info portion according to the flag-table.
+ (cond
+ ((and (or (eq flag 'important)
+ (setq mark (elmo-msgdb-global-mark-get
+ (elmo-message-entity-field
+ entity 'message-id))))
+ (not (eq file-flag 'important)))
+ (elmo-maildir-set-mark file ?F)
+ ;; Delete from unread location list.
+ (elmo-maildir-folder-set-unread-locations-internal
+ folder
+ (delete location
+ (elmo-maildir-folder-unread-locations-internal
+ folder)))
+ ;; Append to flagged location list.
+ (elmo-maildir-folder-set-flagged-locations-internal
+ folder
+ (cons location
+ (elmo-maildir-folder-flagged-locations-internal
+ folder))))
+ ((and (eq flag 'answered)
+ (not (eq file-flag 'answered)))
+ (elmo-maildir-set-mark file ?R)
+ ;; Delete from unread locations.
+ (elmo-maildir-folder-set-unread-locations-internal
+ folder
+ (delete location
+ (elmo-maildir-folder-unread-locations-internal folder)))
+ ;; Append to answered location list.
+ (elmo-maildir-folder-set-answered-locations-internal
+ folder
+ (cons location
+ (elmo-maildir-folder-answered-locations-internal folder))))
+ ((and (eq flag 'read)
+ (not (eq file-flag 'read)))
+ (elmo-maildir-set-mark file ?S)
+ ;; Delete from unread locations.
+ (elmo-maildir-folder-set-unread-locations-internal
+ folder
+ (delete location
+ (elmo-maildir-folder-unread-locations-internal
+ folder))))))
+ (if mark