;; return value.
t))
-(defun elmo-msgdb-set-cached (msgdb number cached)
+(defun elmo-msgdb-get-cached (msgdb number)
+ "Return non-nil if message is cached."
+ (not (member (elmo-msgdb-get-mark msgdb number)
+ (elmo-msgdb-uncached-marks))))
+
+(defun elmo-msgdb-set-cached (msgdb number cached use-cache)
"Set message cache status.
If mark is changed, return non-nil."
(let* ((cur-mark (elmo-msgdb-get-mark msgdb number))
'answered)
((not (member cur-mark (elmo-msgdb-unread-marks)))
'read)))
- (cur-cached (not (member cur-mark (elmo-msgdb-uncached-marks)))))
+ (cur-cached (elmo-file-cache-exists-p
+ (elmo-msgdb-get-field msgdb number 'message-id))))
(unless (eq cached cur-cached)
(case cur-flag
(read
(elmo-msgdb-set-mark msgdb number
- (unless cached
- elmo-msgdb-read-uncached-mark)))
+ (if (and use-cache (not cached))
+ elmo-msgdb-read-uncached-mark)))
(important nil)
(answered
(elmo-msgdb-set-mark msgdb number
'answered)
((not (member cur-mark (elmo-msgdb-unread-marks)))
'read)))
- (cur-cached (not (member cur-mark (elmo-msgdb-uncached-marks))))
+ (cur-cached (elmo-file-cache-exists-p
+ (elmo-msgdb-get-field msgdb number 'message-id)))
mark-modified)
(case flag
(read
(unless (or (eq cur-flag 'answered) (eq cur-flag 'important))
(elmo-msgdb-set-mark msgdb number
(if cur-cached
- (if use-cache
- elmo-msgdb-answered-cached-mark
- elmo-msgdb-answered-uncached-mark)
+ elmo-msgdb-answered-cached-mark
elmo-msgdb-answered-uncached-mark)))
(setq mark-modified t)))
(if mark-modified (elmo-folder-set-mark-modified-internal folder t))))
'answered)
((not (member cur-mark (elmo-msgdb-unread-marks)))
'read)))
- (cur-cached (not (member cur-mark (elmo-msgdb-uncached-marks))))
+ (cur-cached (elmo-file-cache-exists-p
+ (elmo-msgdb-get-field msgdb number 'message-id)))
mark-modified)
(case flag
(read
(when (eq cur-flag 'read)
(elmo-msgdb-set-mark msgdb number
- (if (and cur-cached use-cache)
+ (if cur-cached
elmo-msgdb-unread-cached-mark
elmo-msgdb-unread-uncached-mark))
(setq mark-modified t)))
(answered
(when (eq cur-flag 'answered)
(elmo-msgdb-set-mark msgdb number
- (if (and cur-cached (not use-cache))
+ (if (and use-cache (not cur-cached))
elmo-msgdb-read-uncached-mark))
(setq mark-modified t))))
(if mark-modified (elmo-folder-set-mark-modified-internal folder t))))
entity)
numbers)))
(string-to-int (elmo-filter-value condition)))))
- ((string= key "mark")
+ ((string= key "flag")
(setq result
(cond
((string= (elmo-filter-value condition) "any")
(not (or (null mark)
(string= mark elmo-msgdb-read-uncached-mark))))
+ ((string= (elmo-filter-value condition) "digest")
+ (not (or (null mark)
+ (string= mark elmo-msgdb-read-uncached-mark)
+ (string= mark elmo-msgdb-answered-cached-mark)
+ (string= mark elmo-msgdb-answered-uncached-mark))))
;; (member mark (append (elmo-msgdb-answered-marks)
;; (list elmo-msgdb-important-mark)
;; (elmo-msgdb-unread-marks))))
seen-list))
(defun elmo-msgdb-get-message-id-from-buffer ()
- (or (elmo-field-body "message-id")
+ (let ((msgid (elmo-field-body "message-id")))
+ (if msgid
+ (if (string-match "<\\(.+\\)>$" msgid)
+ msgid
+ (concat "<" msgid ">")) ; Invaild message-id.
;; no message-id, so put dummy msgid.
(concat "<" (timezone-make-date-sortable
(elmo-field-body "date"))
(nth 1 (eword-extract-address-components
- (or (elmo-field-body "from") "nobody"))) ">")))
+ (or (elmo-field-body "from") "nobody"))) ">"))))
(defsubst elmo-msgdb-create-overview-from-buffer (number &optional size time)
"Create overview entity from current buffer.
elmo-msgdb-location-filename
dir) alist))
+(defun elmo-msgdb-list-flagged (msgdb flag)
+ (let ((case-fold-search nil)
+ mark-regexp matched)
+ (case flag
+ (new
+ (setq mark-regexp (regexp-quote elmo-msgdb-new-mark)))
+ (unread
+ (setq mark-regexp (elmo-regexp-opt (elmo-msgdb-unread-marks))))
+ (answered
+ (setq mark-regexp (elmo-regexp-opt (elmo-msgdb-unread-marks))))
+ (important
+ (setq mark-regexp (regexp-quote elmo-msgdb-important-mark)))
+ (read
+ (setq mark-regexp (elmo-regexp-opt (elmo-msgdb-unread-marks))))
+ (digest
+ (setq mark-regexp (elmo-regexp-opt
+ (append (elmo-msgdb-unread-marks)
+ (list elmo-msgdb-important-mark)))))
+ (any
+ (setq mark-regexp (elmo-regexp-opt
+ (append
+ (elmo-msgdb-unread-marks)
+ (elmo-msgdb-answered-marks)
+ (list elmo-msgdb-important-mark))))))
+ (when mark-regexp
+ (if (eq flag 'read)
+ (dolist (number (elmo-msgdb-get-number-alist msgdb))
+ (unless (string-match mark-regexp (elmo-msgdb-get-mark
+ msgdb number))
+ (setq matched (cons number matched))))
+ (dolist (elem (elmo-msgdb-get-mark-alist msgdb))
+ (if (string-match mark-regexp (cadr elem))
+ (setq matched (cons (car elem) matched))))))
+ matched))
+
(put 'elmo-msgdb-do-each-entity 'lisp-indent-function '1)
(def-edebug-spec elmo-msgdb-do-each-entity
((symbolp form &rest form) &rest form))