2003-09-07 Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
+ * elmo-pop3.el (elmo-pop3-sort-overview-by-original-number): Abolish.
+ (elmo-pop3-sort-msgdb-by-original-number): Use
+ `elmo-msgdb-sort-entities'.
+
+ * elmo-msgdb.el (elmo-msgdb-sort-entities): New function.
+ (elmo-msgdb-sort-by-date): Use it.
+ (elmo-msgdb-overview-sort-by-date): Abolish.
+
* elmo-dop.el (elmo-folder-status-dop): Fixed.
* elmo-msgdb.el (elmo-msgdb-list-messages): Undo last change.
;; elmo-msgdb-create-overview-from-buffer NUMBER SIZE TIME
;; elmo-msgdb-copy-overview-entity ENTITY
;; elmo-msgdb-create-overview-entity-from-file NUMBER FILE
-;; elmo-msgdb-overview-sort-by-date OVERVIEW
;; elmo-msgdb-clear-index
;; elmo-folder-get-info
(elmo-msgdb-set-index msgdb index)
t)) ;return value
-(defun elmo-msgdb-sort-by-date (msgdb)
+(defun elmo-msgdb-sort-entities (msgdb predicate &optional app-data)
(message "Sorting...")
(let ((overview (elmo-msgdb-get-overview msgdb)))
(elmo-msgdb-set-overview
msgdb
- (elmo-msgdb-overview-sort-by-date overview))
+ (sort overview (lambda (a b) (funcall predicate a b app-data))))
(message "Sorting...done")
msgdb))
+(defun elmo-msgdb-sort-by-date (msgdb)
+ (elmo-msgdb-sort-entities
+ msgdb
+ (lambda (x y app-data)
+ (condition-case nil
+ (string<
+ (timezone-make-date-sortable
+ (elmo-msgdb-overview-entity-get-date x))
+ (timezone-make-date-sortable
+ (elmo-msgdb-overview-entity-get-date y)))
+ (error)))))
+
;;;
(defsubst elmo-msgdb-append-element (list element)
(if list
(narrow-to-region (point-min) header-end)
(elmo-msgdb-create-overview-from-buffer number size mtime))))))
-(defun elmo-msgdb-overview-sort-by-date (overview)
- (sort overview
- (function
- (lambda (x y)
- (condition-case nil
- (string<
- (timezone-make-date-sortable
- (elmo-msgdb-overview-entity-get-date x))
- (timezone-make-date-sortable
- (elmo-msgdb-overview-entity-get-date y)))
- (error))))))
-
(defun elmo-msgdb-clear-index (msgdb entity)
(let ((ehash (elmo-msgdb-get-entity-hashtb msgdb))
(mhash (elmo-msgdb-get-mark-hashtb msgdb))
(if (elmo-pop3-folder-use-uidl-internal folder)
(elmo-pop3-folder-location-alist-internal folder)))))))
-(defun elmo-pop3-sort-overview-by-original-number (overview loc-alist)
- (if loc-alist
- (sort overview
- (lambda (ent1 ent2)
- (< (elmo-pop3-uidl-to-number
- (cdr (assq (elmo-msgdb-overview-entity-get-number ent1)
- loc-alist)))
- (elmo-pop3-uidl-to-number
- (cdr (assq (elmo-msgdb-overview-entity-get-number ent2)
- loc-alist))))))
- overview))
-
(defun elmo-pop3-sort-msgdb-by-original-number (folder msgdb)
- (message "Sorting...")
- (let ((overview (elmo-msgdb-get-overview msgdb)))
- (elmo-msgdb-set-overview
- msgdb
- (elmo-pop3-sort-overview-by-original-number
- overview
- (elmo-pop3-folder-location-alist-internal folder)))
- (message "Sorting...done")
+ (let ((location-alist (elmo-pop3-folder-location-alist-internal folder)))
+ (when location-alist
+ (elmo-msgdb-sort-entities
+ msgdb
+ (lambda (ent1 ent2 loc-alist)
+ (< (elmo-pop3-uidl-to-number
+ (cdr (assq (elmo-msgdb-overview-entity-get-number ent1)
+ loc-alist)))
+ (elmo-pop3-uidl-to-number
+ (cdr (assq (elmo-msgdb-overview-entity-get-number ent2)
+ loc-alist)))))
+ location-alist))
msgdb))
(defun elmo-pop3-uidl-to-number (uidl)