+2002-10-27 Yuuichi Teranishi <teranisi@gohome.org>
+
+ * elmo.el (elmo-folder-list-flagged): New generic function.
+ (elmo-folder-list-importants): New implementation.
+ (elmo-folder-list-answereds): Ditto.
+ (elmo-folder-search-fast): Use 'flag' instead of 'mark';
+ Added 'digest'.
+ (elmo-message-cached-p): New function.
+ (elmo-message-set-flag): Ditto (no content).
+ (elmo-message-unset-flag): Ditto.
+ (elmo-folder-list-messages-mark-match): Abolish.
+
+ * elmo-util.el (elmo-regexp-opt): New function.
+
+ * elmo-msgdb.el (elmo-msgdb-get-cached): New function.
+ (elmo-msgdb-match-condition-primitive): Use 'flag' instead of 'mark';
+ Added 'digest'.
+ (elmo-msgdb-list-flagged): New function.
+
+ * elmo-imap4.el (elmo-imap4-folder-list-digest-plugged): New function.
+ (elmo-imap4-search-internal-primitive): Use 'flag' instead of 'mark';
+ Added 'digest'.
+
+ * elmo-filter.el (elmo-folder-diff): Use 'flag' instead of 'mark'.
+
2002-10-26 Yuuichi Teranishi <teranisi@gohome.org>
* elmo-version.el (elmo-version): Up to 2.11.0.
(defun elmo-imap4-folder-list-any-plugged (folder)
(elmo-imap4-list folder "or answered or unseen flagged"))
+(defun elmo-imap4-folder-list-digest-plugged (folder)
+ (elmo-imap4-list folder "or unseen flagged"))
+
(luna-define-method elmo-folder-use-flag-p ((folder elmo-imap4-folder))
(not (string-match elmo-imap4-disuse-server-flag-mailbox-regexp
(elmo-imap4-folder-mailbox-internal folder))))
numbers)))
(mapcar '(lambda (x) (delete x numbers)) rest)
numbers))
- ((string= "mark" search-key)
+ ((string= "flag" search-key)
(cond
((string= "unread" (elmo-filter-value filter))
(elmo-folder-list-unreads folder))
(elmo-folder-list-importants folder))
((string= "answered" (elmo-filter-value filter))
(elmo-folder-list-answereds folder))
+ ((string= "digest" (elmo-filter-value filter))
+ (elmo-imap4-folder-list-digest-plugged folder))
((string= "any" (elmo-filter-value filter))
(elmo-imap4-folder-list-any-plugged folder))))
((or (string= "since" search-key)
;; return value.
t))
+(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."
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))))
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))
;;;###autoload
(defun elmo-make-folder (name &optional non-persistent)
"Make an ELMO folder structure specified by NAME.
-If optional argument NON-PERSISTENT is non-nil, folder is treated as
- non-persistent."
+If optional argument NON-PERSISTENT is non-nil, the folder msgdb is not saved."
(let ((type (elmo-folder-type name))
prefix split class folder original)
(setq original (elmo-string name))
(luna-define-generic elmo-folder-list-answereds (folder)
"Return a list of answered message numbers contained in FOLDER.")
-(luna-define-method elmo-folder-list-unreads ((folder elmo-folder))
- (delq nil
- (mapcar
- (lambda (x)
- (if (member (cadr x) (elmo-msgdb-unread-marks))
- (car x)))
- (elmo-msgdb-get-mark-alist (elmo-folder-msgdb folder)))))
-
;; TODO: Should reconsider the structure of global mark.
(defun elmo-folder-list-messages-with-global-mark (folder mark)
(let (entity msgs)
msgs))))
msgs))
+(luna-define-generic elmo-folder-list-flagged (folder flag &optional in-msgdb)
+ "List messages in the FOLDER with FLAG.
+FLAG is a symbol which is one of the following:
+ `new' (new messages)
+ `unread' (unread messages (new messages are included))
+ `answered' (answered or forwarded)
+ `important' (marked as important)
+'sugar' flags:
+ `read' (not unread)
+ `digest' (unread + important)
+ `any' (digest + answered)
+
+If optional IN-MSGDB is non-nil, retrieve flag information from msgdb.")
+
+(luna-define-method elmo-folder-list-flagged ((folder elmo-folder) flag
+ &optional in-msgdb)
+ ;; Currently, only in-msgdb is implemented.
+ (elmo-msgdb-list-flagged (elmo-folder-msgdb folder) flag))
+
+(luna-define-method elmo-folder-list-unreads ((folder elmo-folder))
+ (elmo-msgdb-list-flagged (elmo-folder-msgdb folder) 'unread))
+
(luna-define-method elmo-folder-list-importants ((folder elmo-folder))
- (elmo-folder-list-messages-mark-match folder
- (regexp-quote
- elmo-msgdb-important-mark)))
+ (elmo-msgdb-list-flagged (elmo-folder-msgdb folder) 'important))
(luna-define-method elmo-folder-list-answereds ((folder elmo-folder))
- (delq nil
- (mapcar
- (function
- (lambda (x)
- (if (member (cadr x) (elmo-msgdb-answered-marks))
- (car x))))
- (elmo-msgdb-get-mark-alist (elmo-folder-msgdb folder)))))
+ (elmo-msgdb-list-flagged (elmo-folder-msgdb folder) 'answered))
(luna-define-generic elmo-folder-list-messages-internal (folder &optional
visible-only)
(when (and numbers
(vectorp condition)
(member (elmo-filter-key condition) '("first" "last" "mark")))
- (if (string= (elmo-filter-key condition) "mark")
+ (if (string= (elmo-filter-key condition) "flag")
(let ((msgdb (elmo-folder-msgdb folder)))
;; msgdb should be synchronized at this point.
(cond
(elmo-folder-list-importants folder))
((string= (elmo-filter-value condition) "answered")
(elmo-folder-list-answereds folder))
+ ((string= (elmo-filter-value condition) "digest")
+ (nconc (elmo-folder-list-unreads folder)
+ (elmo-folder-list-importants folder)))
((string= (elmo-filter-value condition) "any")
(nconc (elmo-folder-list-unreads folder)
(elmo-folder-list-importants folder)
folder
(elmo-folder-expand-msgdb-path folder))))
+(defun elmo-message-cached-p (folder number)
+ "Get cache status of the message in the msgdb."
+ (elmo-msgdb-get-cached (elmo-folder-msgdb folder) number))
+
(defun elmo-message-set-cached (folder number cached)
- "Set cache status of the message mark.
+ "Set cache status of the message in the msgdb.
FOLDER is the ELMO folder structure.
NUMBER is a number of the message.
-If CACHED is t, message mark is set as cached."
+If CACHED is t, message is set as cached."
(when (elmo-msgdb-set-cached (elmo-folder-msgdb folder)
number
cached
(elmo-message-use-cache-p folder number))
(elmo-folder-set-mark-modified-internal folder t)))
+(defun elmo-message-set-flag (folder number flag)
+ "Set message flag.
+FOLDER is a ELMO folder structure.
+NUMBER is a message number to set flag.
+
+FLAG is a symbol which is one of the following:
+ `unread' (set the message as unread)
+ `answered' (set the message as answered)
+ `important' (set the message as important)
+'sugar' flag:
+ `read' (remove new and unread flags)")
+
+(defun elmo-message-unset-flag (folder number flag)
+ "Unset message flag.
+FOLDER is a ELMO folder structure.
+NUMBER is a message number to set flag.
+
+FLAG is a symbol which is one of the following:
+ `unread' (remove unread and new flag)
+ `answered' (remove answered flag)
+ `important' (remove important flag)
+'sugar' flag:
+ `read' (set unread flag)")
(defun elmo-message-mark (folder number)
"Get mark of the message.
NUMBER is a number of the message."
(elmo-msgdb-get-mark (elmo-folder-msgdb folder) number))
-(defun elmo-folder-list-messages-mark-match (folder mark-regexp)
- "List messages in the FOLDER which have a mark that matches MARK-REGEXP"
- (let ((case-fold-search nil)
- matched)
- (if mark-regexp
- (dolist (elem (elmo-msgdb-get-mark-alist (elmo-folder-msgdb folder)))
- (if (string-match mark-regexp (cadr elem))
- (setq matched (cons (car elem) matched)))))
- matched))
-
(defun elmo-message-field (folder number field)
"Get message field value in the msgdb.
FOLDER is the ELMO folder structure.