From: teranisi Date: Mon, 24 Mar 2003 04:23:38 +0000 (+0000) Subject: * wl-summary.el (wl-summary-mark-as-read-internal): New inline X-Git-Tag: elmo-mark-restart~71 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=0bb82a75cb6ddb520256d4b210d1201b291e8708;p=elisp%2Fwanderlust.git * wl-summary.el (wl-summary-mark-as-read-internal): New inline function. (wl-summary-mark-as-read, wl-summary-mark-as-unread): Use it. (wl-summary-update-mark): Enclose with save-excursion. (wl-summary-mark-as-read-internal): Fixed last change. (wl-summary-mark-as-important): Use 3rd argument of elmo-folder-unmark-important, elmo-folder-mark-as-important; Don't use elmo-msgdb-set-mark. (wl-summary-redisplay-internal): If msgdb flag is already read, just update the mark on buffer. * elmo.el (elmo-message-set-mark): Abolish. * elmo-msgdb.el (toplevel): Added comment. (elmo-msgdb-set-mark): Abolish. (elmo-load-msgdb): Added 4th element `path'. (elmo-msgdb-append): Follow the change above. (elmo-msgdb-clear): Ditto. (elmo-msgdb-delete-msgs): Ditto. (elmo-msgdb-get-path): New inline function. (elmo-msgdb-set-path): Ditto. (elmo-flag-table-filename): New variable. (elmo-flag-table-load): New function. (elmo-flag-table-set): Ditto. (elmo-flag-table-save): Ditto. (elmo-msgdb-get-field-value): Abolish. (elmo-msgdb-overview-get-entity-by-number): Ditto. --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 45eceb6..1d88d97 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,10 +1,21 @@ -2003-01-30 Yuuichi Teranishi - - * pldap.el (ldap-search-basic): Don't treat exit status 32 as an - error [wl:11327]. - - * elmo-imap4.el (elmo-folder-msgdb-create-plugged): Bind print-level, - print-depth. +2003-03-24 Yuuichi Teranishi + + * elmo.el (elmo-message-set-mark): Abolish. + + * elmo-msgdb.el (toplevel): Added comment. + (elmo-msgdb-set-mark): Abolish. + (elmo-load-msgdb): Added 4th element `path'. + (elmo-msgdb-append): Follow the change above. + (elmo-msgdb-clear): Ditto. + (elmo-msgdb-delete-msgs): Ditto. + (elmo-msgdb-get-path): New inline function. + (elmo-msgdb-set-path): Ditto. + (elmo-flag-table-filename): New variable. + (elmo-flag-table-load): New function. + (elmo-flag-table-set): Ditto. + (elmo-flag-table-save): Ditto. + (elmo-msgdb-get-field-value): Abolish. + (elmo-msgdb-overview-get-entity-by-number): Ditto. 2003-02-16 Yoichi NAKAYAMA @@ -52,6 +63,14 @@ * elmo-localdir.el (elmo-folder-rename-internal): Referctoring; Replace nested conditional with guard clauses. +2003-01-30 Yuuichi Teranishi + + * pldap.el (ldap-search-basic): Don't treat exit status 32 as an + error [wl:11327]. + + * elmo-imap4.el (elmo-folder-msgdb-create-plugged): Bind print-level, + print-depth. + 2003-01-30 TAKAHASHI Kaoru * elmo-archive.el (elmo-folder-rename-internal): Referctoring; diff --git a/elmo/elmo-msgdb.el b/elmo/elmo-msgdb.el index 4cd49d7..b686df8 100644 --- a/elmo/elmo-msgdb.el +++ b/elmo/elmo-msgdb.el @@ -75,16 +75,104 @@ :group 'elmo) ;;; MSGDB interface. +;; +;; MSGDB elmo-load-msgdb PATH +;; MARK elmo-msgdb-get-mark MSGDB NUMBER + +;; CACHED elmo-msgdb-get-cached MSGDB NUMBER +;; VOID elmo-msgdb-set-cached MSGDB NUMBER CACHED USE-CACHE +;; VOID elmo-msgdb-set-flag MSGDB FOLDER NUMBER FLAG +;; VOID elmo-msgdb-unset-flag MSGDB FOLDER NUMBER FLAG + +;; LIST-OF-NUMBERS elmo-msgdb-count-marks MSGDB +;; NUMBER elmo-msgdb-get-number MSGDB MESSAGE-ID +;; FIELD-VALUE elmo-msgdb-get-field MSGDB NUMBER FIELD +;; MSGDB elmo-msgdb-append MSGDB MSGDB-APPEND +;; MSGDB elmo-msgdb-clear MSGDB +;; elmo-msgdb-delete-msgs MSGDB NUMBERS +;; elmo-msgdb-sort-by-date MSGDB + +;; elmo-msgdb-id-mark-table-load +;; elmo-msgdb-id-mark-table-save + +;; elmo-msgdb-append-entity-from-buffer +;; msgdb number flag id-mark-table &optional buffer + +;; ENTITY elmo-msgdb-make-entity ARGS +;; VALUE elmo-msgdb-entity-field ENTITY +;; + +;; OVERVIEW elmo-msgdb-get-overview MSGDB +;; NUMBER-ALIST elmo-msgdb-get-number-alist MSGDB +;; MARK-ALIST elmo-msgdb-get-mark-alist MSGDB +;; elmo-msgdb-change-mark MSGDB BEFORE AFTER + +;; (for internal use?) +;; LIST-OF-MARKS elmo-msgdb-unread-marks +;; LIST-OF-MARKS elmo-msgdb-answered-marks +;; LIST-OF-MARKS elmo-msgdb-uncached-marks +;; elmo-msgdb-seen-save DIR OBJ +;; elmo-msgdb-overview-save DIR OBJ + +;; elmo-msgdb-overview-entity-get-references ENTITY +;; elmo-msgdb-overview-entity-set-references ENTITY +;; elmo-msgdb-get-parent-entity ENTITY MSGDB +;; elmo-msgdb-overview-enitty-get-number ENTITY +;; elmo-msgdb-overview-enitty-get-from-no-decode ENTITY +;; elmo-msgdb-overview-enitty-get-from ENTITY +;; elmo-msgdb-overview-enitty-get-subject-no-decode ENTITY +;; elmo-msgdb-overview-enitty-get-subject ENTITY +;; elmo-msgdb-overview-enitty-get-date ENTITY +;; elmo-msgdb-overview-enitty-get-to ENTITY +;; elmo-msgdb-overview-enitty-get-cc ENTITY +;; elmo-msgdb-overview-enitty-get-size ENTITY +;; elmo-msgdb-overview-enitty-get-id ENTITY +;; elmo-msgdb-overview-enitty-get-extra-field ENTITY +;; elmo-msgdb-overview-enitty-get-extra ENTITY +;; elmo-msgdb-overview-get-entity ID MSGDB + +;; elmo-msgdb-killed-list-load DIR +;; elmo-msgdb-killed-list-save DIR +;; elmo-msgdb-append-to-killed-list FOLDER MSG +;; elmo-msgdb-killed-list-length KILLED-LIST +;; elmo-msgdb-max-of-killed KILLED-LIST +;; elmo-msgdb-killed-message-p KILLED-LIST MSG +;; elmo-living-messages MESSAGES KILLED-LIST +;; elmo-msgdb-finfo-load +;; elmo-msgdb-finfo-save +;; elmo-msgdb-flist-load +;; elmo-msgdb-flist-save + +;; elmo-crosspost-alist-load +;; elmo-crosspost-alist-save + +;; elmo-msgdb-add-msgs-to-seen-list MSGS MSGDB SEEN-LIST + +;; 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-folder-get-info-max +;; elmo-folder-get-info-length +;; elmo-folder-get-info-unread + +;; elmo-msgdb-list-flagged MSGDB FLAG +;; (MACRO) elmo-msgdb-do-each-entity + (defun elmo-load-msgdb (path) "Load the MSGDB from PATH." (let ((inhibit-quit t)) (elmo-make-msgdb (elmo-msgdb-overview-load path) (elmo-msgdb-number-load path) - (elmo-msgdb-mark-load path)))) + (elmo-msgdb-mark-load path) + path))) -(defun elmo-make-msgdb (&optional overview number-alist mark-alist) +(defun elmo-make-msgdb (&optional overview number-alist mark-alist path) "Make a MSGDB." - (let ((msgdb (list overview number-alist mark-alist nil))) + (let ((msgdb (list overview number-alist mark-alist nil path))) (elmo-msgdb-make-index msgdb) msgdb)) @@ -93,33 +181,6 @@ (cadr (elmo-get-hash-val (format "#%d" number) (elmo-msgdb-get-mark-hashtb msgdb)))) -(defsubst elmo-msgdb-set-mark (msgdb number mark) - "Set MARK of the message with NUMBER in the MSGDB. -if MARK is nil, mark is removed." - (let ((elem (elmo-get-hash-val (format "#%d" number) - (elmo-msgdb-get-mark-hashtb msgdb)))) - (if elem - (if mark - ;; Set mark of the elem - (setcar (cdr elem) mark) - ;; Delete elem from mark-alist - (elmo-msgdb-set-mark-alist - msgdb - (delq elem (elmo-msgdb-get-mark-alist msgdb))) - (elmo-clear-hash-val (format "#%d" number) - (elmo-msgdb-get-mark-hashtb msgdb))) - (when mark - ;; Append new element. - (elmo-msgdb-set-mark-alist - msgdb - (nconc - (elmo-msgdb-get-mark-alist msgdb) - (list (setq elem (list number mark))))) - (elmo-set-hash-val (format "#%d" number) elem - (elmo-msgdb-get-mark-hashtb msgdb)))) - ;; 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) @@ -314,7 +375,8 @@ FLAG is a symbol which is one of the following: (elmo-msgdb-make-index msgdb (elmo-msgdb-get-overview msgdb-append) - (elmo-msgdb-get-mark-alist msgdb-append)))) + (elmo-msgdb-get-mark-alist msgdb-append)) + (nth 4 msgdb))) (defsubst elmo-msgdb-clear (&optional msgdb) (if msgdb @@ -322,8 +384,9 @@ FLAG is a symbol which is one of the following: (setcar msgdb nil) (setcar (cdr msgdb) nil) (setcar (cddr msgdb) nil) - (setcar (nthcdr 3 msgdb) nil)) - (list nil nil nil nil))) + (setcar (nthcdr 3 msgdb) nil) + (setcar (nthcdr 4 msgdb) nil)) + (list nil nil nil nil nil))) (defun elmo-msgdb-delete-msgs (msgdb msgs) "Delete MSGS from MSGDB @@ -332,7 +395,8 @@ content of MSGDB is changed." (number-alist (cadr msgdb)) (mark-alist (caddr msgdb)) (index (elmo-msgdb-get-index msgdb)) - (newmsgdb (list overview number-alist mark-alist index)) + (newmsgdb (list overview number-alist mark-alist index + (nth 4 msgdb))) ov-entity) ;; remove from current database. (while msgs @@ -398,6 +462,9 @@ content of MSGDB is changed." (defsubst elmo-msgdb-get-mark-hashtb (msgdb) (cdr (nth 3 msgdb))) +(defsubst elmo-msgdb-get-path (msgdb) + (nth 4 msgdb)) + ;; ;; number <-> Message-ID handling ;; @@ -407,6 +474,34 @@ content of MSGDB is changed." (elmo-msgdb-append-element ret-val (cons number id))) ret-val)) +;;; flag table +;; +(defvar elmo-flag-table-filename "flag-table") +(defun elmo-flag-table-load (dir) + "Load flag hashtable for MSGDB." + (let ((table (elmo-make-hash)) + ;; For backward compatibility + (seen-file (expand-file-name elmo-msgdb-seen-filename dir)) + seen-list) + (when (file-exists-p seen-file) + (setq seen-list (elmo-object-load seen-file)) + (delete-file seen-file)) + (dolist (msgid seen-list) + (elmo-set-hash-val msgid 'read table)) + (dolist (pair (elmo-object-load + (expand-file-name elmo-flag-table-filename dir))) + (elmo-set-hash-val (car pair) (cdr pair) table)) + table)) + +(defun elmo-flag-table-set (flag-table msg-id flag) + (elmo-set-hash-val msg-id flag flag-table)) + +(defun elmo-flag-table-save (dir flag-table) + (elmo-object-save + (expand-file-name (expand-file-name elmo-flag-table-filename dir) + (mapatoms (lambda (atom) + (cons (symbol-name atom) (symbol-value atom))) + flag-table)))) ;;; ;; persistent mark handling ;; (for each folder) @@ -460,14 +555,6 @@ content of MSGDB is changed." ;; ;; overview handling ;; - -(defsubst elmo-msgdb-get-field-value (field-name beg end buffer) - (save-excursion - (save-restriction - (set-buffer buffer) - (narrow-to-region beg end) - (elmo-field-body field-name)))) - (defun elmo-multiple-field-body (name &optional boundary) (save-excursion (save-restriction @@ -725,6 +812,9 @@ Return CONDITION itself if no entity exists in msgdb." (defsubst elmo-msgdb-set-index (msgdb index) (setcar (cdddr msgdb) index)) +(defsubst elmo-msgdb-set-path (msgdb path) + (setcar (cddddr msgdb) index)) + (defsubst elmo-msgdb-overview-entity-get-references (entity) (and entity (aref (cdr entity) 1))) @@ -819,17 +909,6 @@ Return CONDITION itself if no entity exists in msgdb." (and entity (aset (cdr entity) 8 extra)) entity) -(defun elmo-msgdb-overview-get-entity-by-number (database number) - (when number - (let ((db database) - entity) - (while db - (if (eq (elmo-msgdb-overview-entity-get-number (car db)) number) - (setq entity (car db) - db nil) ; exit loop - (setq db (cdr db)))) - entity))) - (defun elmo-msgdb-overview-get-entity (id msgdb) (when id (let ((ht (elmo-msgdb-get-entity-hashtb msgdb))) diff --git a/elmo/elmo.el b/elmo/elmo.el index 2dac126..048b677 100644 --- a/elmo/elmo.el +++ b/elmo/elmo.el @@ -1177,12 +1177,6 @@ NUMBER is a number of the message. FIELD is a symbol of the field." (elmo-msgdb-get-field (elmo-folder-msgdb folder) number field)) -(defun elmo-message-set-mark (folder number mark) - ;; Set mark for the message in the FOLDER with NUMBER as MARK. - (elmo-msgdb-set-mark - (elmo-folder-msgdb folder) - number mark)) - (luna-define-method elmo-message-use-cache-p ((folder elmo-folder) number) nil) ; default is not use cache. diff --git a/wl/ChangeLog b/wl/ChangeLog index a15e852..86f912d 100644 --- a/wl/ChangeLog +++ b/wl/ChangeLog @@ -3,6 +3,13 @@ * wl-summary.el (wl-summary-mark-as-read-internal): New inline function. (wl-summary-mark-as-read, wl-summary-mark-as-unread): Use it. + (wl-summary-update-mark): Enclose with save-excursion. + (wl-summary-mark-as-read-internal): Fixed last change. + (wl-summary-mark-as-important): Use 3rd argument of + elmo-folder-unmark-important, elmo-folder-mark-as-important; + Don't use elmo-msgdb-set-mark. + (wl-summary-redisplay-internal): If msgdb flag is already read, + just update the mark on buffer. 2003-03-19 Yoichi NAKAYAMA diff --git a/wl/wl-summary.el b/wl/wl-summary.el index 8780341..6559bd0 100644 --- a/wl/wl-summary.el +++ b/wl/wl-summary.el @@ -3878,13 +3878,14 @@ If ARG, exit virtual folder." (let ((number (or number (wl-summary-message-number))) buffer-read-only cur-mark) (setq cur-mark (elmo-message-mark wl-summary-buffer-elmo-folder number)) - ;; set mark on buffer - (unless (string= (wl-summary-persistent-mark) cur-mark) - (delete-backward-char 1) - (insert (or cur-mark " "))) - (when wl-summary-highlight - (wl-highlight-summary-current-line nil nil t)) - (set-buffer-modified-p nil))) + (save-excursion + ;; set mark on buffer + (unless (string= (wl-summary-persistent-mark) cur-mark) + (delete-backward-char 1) + (insert (or cur-mark " "))) + (when wl-summary-highlight + (wl-highlight-summary-current-line nil nil t)) + (set-buffer-modified-p nil)))) (defsubst wl-summary-mark-as-read-internal (inverse number-or-numbers @@ -3909,18 +3910,18 @@ If ARG, exit virtual folder." (elmo-folder-mark-as-read folder number-list no-folder-mark)) (dolist (number number-list) (setq visible (wl-summary-jump-to-msg number) - mark (elmo-message-mark folder number)) - (setq new-mark (elmo-message-mark folder number)) + new-mark (elmo-message-mark folder number)) ;; set mark on buffer (when visible - (unless (string= (wl-summary-persistent-mark) new-mark) + (unless (string= (wl-summary-persistent-mark) (or new-mark " ")) (delete-backward-char 1) (insert (or new-mark " "))) (if (and visible wl-summary-highlight) (wl-highlight-summary-current-line nil nil t)) (set-buffer-modified-p nil)) (unless inverse - (if (member mark (elmo-msgdb-unread-marks)) + (if (member (elmo-message-mark folder number) + (elmo-msgdb-unread-marks)) (run-hooks 'wl-summary-unread-message-hook)))) (unless no-modeline-update ;; Update unread numbers. @@ -3993,8 +3994,9 @@ If ARG, exit virtual folder." (progn ;; server side mark (save-match-data + (elmo-folder-unmark-important folder (list number) + no-server-update) (unless no-server-update - (elmo-folder-unmark-important folder (list number)) (elmo-msgdb-global-mark-delete message-id)) ;; Remove cache if local folder. (if (and (elmo-folder-local-p folder) @@ -4004,17 +4006,13 @@ If ARG, exit virtual folder." (elmo-file-cache-get-path message-id)))) (when visible (delete-backward-char 1) - (insert " ")) - (elmo-msgdb-set-mark msgdb number nil)) + (elmo-message-mark folder number))) ;; server side mark - (save-match-data - (unless no-server-update - (elmo-folder-mark-as-important folder (list number)))) + (elmo-folder-mark-as-important folder (list number) + no-server-update) (when visible (delete-backward-char 1) (insert elmo-msgdb-important-mark)) - (elmo-msgdb-set-mark msgdb number - elmo-msgdb-important-mark) (if (eq (elmo-file-cache-exists-p message-id) 'entire) (elmo-folder-mark-as-read folder (list number)) ;; Force cache message. @@ -5113,9 +5111,13 @@ Use function list is `wl-summary-write-current-folder-functions'." (elmo-folder-plugged-p wl-summary-buffer-elmo-folder)) 'leave))) - (if (elmo-message-use-cache-p folder num) - (elmo-message-set-cached folder num t)) - (wl-summary-mark-as-read num no-folder-mark) + (when (elmo-message-use-cache-p folder num) + (elmo-message-set-cached folder num t)) + (if (member (elmo-message-mark wl-summary-buffer-elmo-folder + num) + (elmo-msgdb-unread-marks)) + (wl-summary-mark-as-read num no-folder-mark) + (wl-summary-update-mark)) (setq wl-summary-buffer-current-msg num) (when wl-summary-recenter (recenter (/ (- (window-height) 2) 2))