* elmo-pop3.el (elmo-pop3-sort-overview-by-original-number): Abolish.
authorhmurata <hmurata>
Sun, 7 Sep 2003 06:01:31 +0000 (06:01 +0000)
committerhmurata <hmurata>
Sun, 7 Sep 2003 06:01:31 +0000 (06:01 +0000)
(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/ChangeLog
elmo/elmo-msgdb.el
elmo/elmo-pop3.el

index 5ca311e..dd4a679 100644 (file)
@@ -1,5 +1,13 @@
 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.
index 8f91dc1..3422a01 100644 (file)
 ;; 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
@@ -517,15 +516,27 @@ content of MSGDB is changed."
     (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
@@ -1287,18 +1298,6 @@ Header region is supposed to be narrowed."
          (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))
index 9523450..dad3830 100644 (file)
@@ -702,27 +702,19 @@ If IF-EXISTS is `any-exists', get BIFF session or normal session if exists."
        (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)