From: teranisi Date: Thu, 7 Aug 2003 14:30:25 +0000 (+0000) Subject: * elmo.el (elmo-folder-append-msgdb): Rewrite and define as an inline X-Git-Tag: wl-2_11_7~1 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=70c18da4df68f4207900e645eebc5a85a27471fd;p=elisp%2Fwanderlust.git * elmo.el (elmo-folder-append-msgdb): Rewrite and define as an inline function. * elmo-msgdb.el (elmo-msgdb-append): Use elmo-msgdb-make-index-return. (elmo-msgdb-merge): New function. (elmo-msgdb-make-index-return): Renamed from elmo-msgdb-make-index. (elmo-msgdb-make-index): Rewrite. --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index ebd47cf..3f4493e 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,5 +1,13 @@ 2003-08-07 Yuuichi Teranishi + * elmo.el (elmo-folder-append-msgdb): Rewrite and define as an inline + function. + + * elmo-msgdb.el (elmo-msgdb-append): Use elmo-msgdb-make-index-return. + (elmo-msgdb-merge): New function. + (elmo-msgdb-make-index-return): Renamed from elmo-msgdb-make-index. + (elmo-msgdb-make-index): Rewrite. + * elmo-version.el (elmo-version): Up to 2.11.6. * elmo-msgdb.el (elmo-msgdb-list-messages): If argument is a string, diff --git a/elmo/elmo-msgdb.el b/elmo/elmo-msgdb.el index 20ed99f..60fce6b 100644 --- a/elmo/elmo-msgdb.el +++ b/elmo/elmo-msgdb.el @@ -399,12 +399,41 @@ FLAG is a symbol which is one of the following: (nconc (car msgdb) (car msgdb-append)) (nconc (cadr msgdb) (cadr msgdb-append)) (nconc (caddr msgdb) (caddr msgdb-append)) - (elmo-msgdb-make-index + (elmo-msgdb-make-index-return msgdb (elmo-msgdb-get-overview msgdb-append) (elmo-msgdb-get-mark-alist msgdb-append)) (nth 4 msgdb))) +(defun elmo-msgdb-merge (folder msgdb-merge) + "Return a list of messages which have duplicated message-id." + (let (msgdb duplicates) + (setq msgdb (or (elmo-folder-msgdb-internal folder) + (elmo-make-msgdb nil nil nil + (elmo-folder-msgdb-path folder)))) + (elmo-msgdb-set-overview + msgdb + (nconc (elmo-msgdb-get-overview msgdb) + (elmo-msgdb-get-overview msgdb-merge))) + (elmo-msgdb-set-number-alist + msgdb + (nconc (elmo-msgdb-get-number-alist msgdb) + (elmo-msgdb-get-number-alist msgdb-merge))) + (elmo-msgdb-set-mark-alist + msgdb + (nconc (elmo-msgdb-get-mark-alist msgdb) + (elmo-msgdb-get-mark-alist msgdb-merge))) + (setq duplicates (elmo-msgdb-make-index + msgdb + (elmo-msgdb-get-overview msgdb-merge) + (elmo-msgdb-get-mark-alist msgdb-merge))) + (elmo-msgdb-set-path + msgdb + (or (elmo-msgdb-get-path msgdb) + (elmo-msgdb-get-path msgdb-merge))) + (elmo-folder-set-msgdb-internal folder msgdb) + duplicates)) + (defsubst elmo-msgdb-clear (&optional msgdb) (if msgdb (list @@ -1236,7 +1265,7 @@ Header region is supposed to be narrowed." (and (setq number (elmo-msgdb-overview-entity-get-number entity)) (elmo-clear-hash-val (format "#%d" number) mhash))))) -(defun elmo-msgdb-make-index (msgdb &optional overview mark-alist) +(defun elmo-msgdb-make-index-return (msgdb &optional overview mark-alist) "Append OVERVIEW and MARK-ALIST to the index of MSGDB. If OVERVIEW and MARK-ALIST are nil, make index for current MSGDB. Return the updated INDEX." @@ -1268,6 +1297,43 @@ Return the updated INDEX." (elmo-msgdb-set-index msgdb index) index))) +(defun elmo-msgdb-make-index (msgdb &optional overview mark-alist) + "Append OVERVIEW and MARK-ALIST to the index of MSGDB. +If OVERVIEW and MARK-ALIST are nil, make index for current MSGDB. +Return a list of message numbers which have duplicated message-ids." + (when msgdb + (let* ((overview (or overview (elmo-msgdb-get-overview msgdb))) + (mark-alist (or mark-alist (elmo-msgdb-get-mark-alist msgdb))) + (index (elmo-msgdb-get-index msgdb)) + (ehash (or (car index) ;; append + (elmo-make-hash (length overview)))) + (mhash (or (cdr index) ;; append + (elmo-make-hash (length overview)))) + duplicates) + (while overview + ;; key is message-id + (if (elmo-get-hash-val (caar overview) ehash) ; duplicated. + (setq duplicates (cons + (elmo-message-entity-number (car overview)) + duplicates))) + (if (caar overview) + (elmo-set-hash-val (caar overview) (car overview) ehash)) + ;; key is number + (elmo-set-hash-val + (format "#%d" + (elmo-message-entity-number (car overview))) + (car overview) ehash) + (setq overview (cdr overview))) + (while mark-alist + ;; key is number + (elmo-set-hash-val + (format "#%d" (car (car mark-alist))) + (car mark-alist) mhash) + (setq mark-alist (cdr mark-alist))) + (setq index (or index (cons ehash mhash))) + (elmo-msgdb-set-index msgdb index) + duplicates))) + (defsubst elmo-folder-get-info (folder &optional hashtb) (elmo-get-hash-val folder (or hashtb elmo-folder-info-hashtb))) diff --git a/elmo/elmo.el b/elmo/elmo.el index 2686788..cb66c79 100644 --- a/elmo/elmo.el +++ b/elmo/elmo.el @@ -627,12 +627,8 @@ FIELD is a symbol of the field name.") (luna-define-generic elmo-folder-process-crosspost (folder) "Process crosspost for FOLDER. -If NUMBER-ALIST is set, it is used as number-alist. Return a cons cell of (NUMBER-CROSSPOSTS . NEW-MARK-ALIST).") -(luna-define-generic elmo-folder-append-msgdb (folder append-msgdb) - "Append APPEND-MSGDB to the current msgdb of the folder.") - (luna-define-generic elmo-folder-newsgroups (folder) "Return list of newsgroup name of FOLDER.") @@ -1339,53 +1335,25 @@ FIELD is a symbol of the field.") ;; flag-table) ;; "Append ENTITY to the folder.") -(defun elmo-generic-folder-append-msgdb (folder append-msgdb) +(defsubst elmo-folder-append-msgdb (folder append-msgdb) (if append-msgdb - (let* ((number-alist (elmo-msgdb-get-number-alist append-msgdb)) - (all-alist (copy-sequence (append - (elmo-msgdb-get-number-alist - (elmo-folder-msgdb folder)) - number-alist))) - (cur number-alist) - pair overview - to-be-deleted - mark-alist) - (elmo-folder-set-msgdb-internal folder - (elmo-msgdb-append - (elmo-folder-msgdb folder) - append-msgdb)) - (while cur - (setq all-alist (delq (car cur) all-alist)) - ;; same message id exists. - (if (setq pair (rassoc (cdr (car cur)) all-alist)) - (setq to-be-deleted (nconc to-be-deleted (list (car pair))))) - (setq cur (cdr cur))) + (let ((duplicates (elmo-msgdb-merge folder append-msgdb))) (cond ((eq (elmo-folder-process-duplicates-internal folder) 'hide) - ;; Hide duplicates. - (setq overview (elmo-delete-if - (lambda (x) - (memq (elmo-msgdb-overview-entity-get-number - x) - to-be-deleted)) - (elmo-msgdb-get-overview append-msgdb))) + ;; Let duplicates be a temporary killed message. + (elmo-folder-kill-messages folder duplicates) ;; Should be mark as read. - (elmo-folder-mark-as-read folder to-be-deleted) - (elmo-msgdb-set-overview append-msgdb overview)) + (elmo-folder-mark-as-read folder duplicates)) ((eq (elmo-folder-process-duplicates-internal folder) 'read) ;; Mark as read duplicates. - (elmo-folder-mark-as-read folder to-be-deleted)) + (elmo-folder-mark-as-read folder duplicates)) (t ;; Do nothing. - (setq to-be-deleted nil))) - (length to-be-deleted)) + (setq duplicates nil))) + (length duplicates)) 0)) -(luna-define-method elmo-folder-append-msgdb ((folder elmo-folder) - append-msgdb) - (elmo-generic-folder-append-msgdb folder append-msgdb)) - (defun elmo-folder-confirm-appends (appends) (let ((len (length appends)) in) @@ -1506,7 +1474,6 @@ If update process is interrupted, return nil.") no-check) (let ((killed-list (elmo-folder-killed-list-internal folder)) (before-append t) - number-alist old-msgdb diff diff-2 delete-list new-list new-msgdb mark flag-table crossed after-append) (setq old-msgdb (elmo-folder-msgdb folder))