X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=wl%2Fwl-summary.el;h=ae7a442b8db7f69a59b6095d4701a128c1c062dd;hb=709366cf00291239e4287abb0b2105ad47fdbf59;hp=c3ff1dd39042193a4ebe2cd17043f66f1fa557b0;hpb=a4c8f641fd63d2de34c774409ca9183785b80186;p=elisp%2Fwanderlust.git diff --git a/wl/wl-summary.el b/wl/wl-summary.el index c3ff1dd..ae7a442 100644 --- a/wl/wl-summary.el +++ b/wl/wl-summary.el @@ -83,12 +83,12 @@ (defvar wl-summary-buffer-current-msg nil) (defvar wl-summary-buffer-unread-count 0) (defvar wl-summary-buffer-new-count 0) +(defvar wl-summary-buffer-answered-count 0) (defvar wl-summary-buffer-mime-charset nil) (defvar wl-summary-buffer-weekday-name-lang nil) (defvar wl-summary-buffer-thread-indent-set-alist nil) -(defvar wl-summary-buffer-view 'thread) +(defvar wl-summary-buffer-view nil) (defvar wl-summary-buffer-message-modified nil) -(defvar wl-summary-buffer-mark-modified nil) (defvar wl-summary-buffer-thread-modified nil) (defvar wl-summary-buffer-number-column nil) @@ -110,6 +110,7 @@ (defvar wl-summary-buffer-msgdb nil) (defvar wl-summary-buffer-folder-name nil) (defvar wl-summary-buffer-line-formatter nil) +(defvar wl-summary-buffer-line-format nil) (defvar wl-summary-buffer-mode-line-formatter nil) (defvar wl-summary-buffer-mode-line nil) @@ -146,12 +147,12 @@ (make-variable-buffer-local 'wl-summary-buffer-last-displayed-msg) (make-variable-buffer-local 'wl-summary-buffer-unread-count) (make-variable-buffer-local 'wl-summary-buffer-new-count) +(make-variable-buffer-local 'wl-summary-buffer-answered-count) (make-variable-buffer-local 'wl-summary-buffer-mime-charset) (make-variable-buffer-local 'wl-summary-buffer-weekday-name-lang) (make-variable-buffer-local 'wl-summary-buffer-thread-indent-set) (make-variable-buffer-local 'wl-summary-buffer-view) (make-variable-buffer-local 'wl-summary-buffer-message-modified) -(make-variable-buffer-local 'wl-summary-buffer-mark-modified) (make-variable-buffer-local 'wl-summary-buffer-thread-modified) (make-variable-buffer-local 'wl-summary-buffer-number-column) (make-variable-buffer-local 'wl-summary-buffer-temp-mark-column) @@ -181,6 +182,7 @@ (make-variable-buffer-local 'wl-summary-buffer-msgdb) (make-variable-buffer-local 'wl-summary-buffer-folder-name) (make-variable-buffer-local 'wl-summary-buffer-line-formatter) +(make-variable-buffer-local 'wl-summary-buffer-line-format) (make-variable-buffer-local 'wl-summary-buffer-mode-line-formatter) (make-variable-buffer-local 'wl-summary-buffer-mode-line) @@ -193,11 +195,6 @@ (defvar wl-temp-mark) (defvar wl-persistent-mark) -;; internal functions (dummy) -(unless (fboundp 'wl-summary-append-message-func-internal) - (defun wl-summary-append-message-func-internal (entity msgdb update - &optional force-insert))) - (defmacro wl-summary-sticky-buffer-name (name) (` (concat wl-summary-buffer-name ":" (, name)))) @@ -207,6 +204,12 @@ subject-string)) (defun wl-summary-default-from (from) + "Instance of `wl-summary-from-function'. +Ordinarily returns the sender name. Returns recipient names if (1) +summary's folder name matches with `wl-summary-showto-folder-regexp' +and (2) sender address is yours. + +See also variable `wl-use-petname'." (let (retval tos ng) (unless (and (eq major-mode 'wl-summary-mode) @@ -226,7 +229,8 @@ (eword-decode-string (if wl-use-petname (or - (funcall wl-summary-get-petname-function to) + (funcall + wl-summary-get-petname-function to) (car (std11-extract-address-components to)) to) @@ -250,6 +254,9 @@ string) string)) +(defvar wl-summary-sort-specs '(number date subject from list-info)) +(defvar wl-summary-default-sort-spec 'date) + (defvar wl-summary-mode-menu-spec '("Summary" ["Read" wl-summary-read t] @@ -277,7 +284,8 @@ ["By Number" wl-summary-sort-by-number t] ["By Date" wl-summary-sort-by-date t] ["By From" wl-summary-sort-by-from t] - ["By Subject" wl-summary-sort-by-subject t]) + ["By Subject" wl-summary-sort-by-subject t] + ["By List Info" wl-summary-sort-by-list-info t]) "----" ("Message Operation" ["Mark as read" wl-summary-mark-as-read t] @@ -409,10 +417,8 @@ (define-key wl-summary-mode-map "p" 'wl-summary-prev) (define-key wl-summary-mode-map "N" 'wl-summary-down) (define-key wl-summary-mode-map "P" 'wl-summary-up) -;;;(define-key wl-summary-mode-map "w" 'wl-draft) (define-key wl-summary-mode-map "w" 'wl-summary-write) (define-key wl-summary-mode-map "W" 'wl-summary-write-current-folder) -;;;(define-key wl-summary-mode-map "e" 'wl-draft-open-file) (define-key wl-summary-mode-map "e" 'wl-summary-save) (define-key wl-summary-mode-map "\C-c\C-o" 'wl-jump-to-draft-buffer) (define-key wl-summary-mode-map "\C-c\C-a" 'wl-addrmgr) @@ -546,6 +552,8 @@ (defun wl-summary-display-top () (interactive) (goto-char (point-min)) + (when wl-summary-lazy-highlight + (wl-highlight-summary-window)) (if wl-summary-buffer-disp-msg (wl-summary-redisplay))) @@ -553,19 +561,18 @@ (interactive) (goto-char (point-max)) (forward-line -1) + (when wl-summary-lazy-highlight + (wl-highlight-summary-window)) (if wl-summary-buffer-disp-msg (wl-summary-redisplay))) (defun wl-summary-count-unread () - (let ((pair - (elmo-msgdb-count-marks (wl-summary-buffer-msgdb) - wl-summary-new-mark - (list wl-summary-unread-uncached-mark - wl-summary-unread-cached-mark)))) + (let ((lst (elmo-msgdb-count-marks (wl-summary-buffer-msgdb)))) (if (eq major-mode 'wl-summary-mode) - (setq wl-summary-buffer-new-count (car pair) - wl-summary-buffer-unread-count (cdr pair))) - pair)) + (setq wl-summary-buffer-new-count (car lst) + wl-summary-buffer-unread-count (nth 1 lst) + wl-summary-buffer-answered-count (nth 2 lst))) + lst)) (defun wl-summary-message-string (&optional use-cache) "Return full body string of current message. @@ -630,7 +637,7 @@ you." (concat "^--" boundary "\n" "\\([Cc]ontent-[Dd]escription:.*\n\\)?" "[Cc]ontent-[Tt]ype:[ \t]+" - "\\(message/rfc822\\|text/rfc822-headers\\)\n" + "\\(message/rfc822\\|text/rfc822-headers\\).*\n" "\\(.+\n\\)*\n") nil t)) (re-search-forward (concat "\n\\(--" boundary "\\)--\n") nil t)) @@ -721,7 +728,7 @@ you." (current-column)))) (setq wl-summary-buffer-temp-mark-column temp wl-summary-buffer-persistent-mark-column persistent))) - + (defun wl-summary-buffer-set-folder (folder) (if (stringp folder) (setq folder (wl-folder-get-elmo-folder folder))) @@ -746,10 +753,11 @@ you." wl-summary-default-number-column)) (wl-line-formatter-setup wl-summary-buffer-line-formatter - (or (wl-get-assoc-list-value - wl-folder-summary-line-format-alist - (elmo-folder-name-internal folder)) - wl-summary-line-format) + (setq wl-summary-buffer-line-format + (or (wl-get-assoc-list-value + wl-folder-summary-line-format-alist + (elmo-folder-name-internal folder)) + wl-summary-line-format)) wl-summary-line-format-spec-alist) (wl-line-formatter-setup wl-summary-buffer-mode-line-formatter @@ -783,13 +791,6 @@ you." wl-thread-space-str-internal (or (nth 5 wl-summary-buffer-thread-indent-set) wl-thread-space-str)) - (setq wl-thread-indent-regexp - (concat - (regexp-quote wl-thread-have-younger-brother-str-internal) "\\|" - (regexp-quote wl-thread-youngest-child-str-internal) "\\|" - (regexp-quote wl-thread-vertical-str-internal) "\\|" - (regexp-quote wl-thread-horizontal-str-internal) "\\|" - (regexp-quote wl-thread-space-str-internal))) (run-hooks 'wl-summary-buffer-set-folder-hook)) (defun wl-summary-mode () @@ -816,7 +817,7 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'." (wl-mode-line-buffer-identification '(wl-summary-buffer-mode-line)) (easy-menu-add wl-summary-mode-menu) (when wl-summary-lazy-highlight - (if wl-on-xemacs + (if wl-on-xemacs (progn (make-local-variable 'pre-idle-hook) (add-hook 'pre-idle-hook 'wl-highlight-summary-window)) @@ -857,6 +858,60 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'." (string< (elmo-msgdb-overview-entity-get-subject-no-decode x) (elmo-msgdb-overview-entity-get-subject-no-decode y))) +(defun wl-summary-get-list-info (entity) + "Returns (\"ML-name\" . ML-count) of ENTITY." + (let (sequence ml-name ml-count subject return-path delivered-to mailing-list) + (setq sequence (elmo-msgdb-overview-entity-get-extra-field + entity "x-sequence") + ml-name (or (elmo-msgdb-overview-entity-get-extra-field + entity "x-ml-name") + (and sequence + (car (split-string sequence " ")))) + ml-count (or (elmo-msgdb-overview-entity-get-extra-field + entity "x-mail-count") + (elmo-msgdb-overview-entity-get-extra-field + entity "x-ml-count") + (and sequence + (cadr (split-string sequence " "))))) + (and (setq subject (elmo-msgdb-overview-entity-get-subject + entity)) + (setq subject (elmo-delete-char ?\n subject)) + (string-match "^\\s(\\(\\S)+\\)[ :]\\([0-9]+\\)\\s)[ \t]*" subject) + (progn + (or ml-name (setq ml-name (match-string 1 subject))) + (or ml-count (setq ml-count (match-string 2 subject))))) + (and (setq return-path + (elmo-msgdb-overview-entity-get-extra-field + entity "return-path")) + (string-match "^<\\([^@>]+\\)-return-\\([0-9]+\\)-" return-path) + (progn + (or ml-name (setq ml-name (match-string 1 return-path))) + (or ml-count (setq ml-count (match-string 2 return-path))))) + (and (setq delivered-to + (elmo-msgdb-overview-entity-get-extra-field + entity "delivered-to")) + (string-match "^mailing list \\([^@]+\\)@" delivered-to) + (or ml-name (setq ml-name (match-string 1 delivered-to)))) + (and (setq mailing-list + (elmo-msgdb-overview-entity-get-extra-field + entity "mailing-list")) + (string-match "\\(^\\|; \\)contact \\([^@]+\\)-[^-@]+@" mailing-list) ; *-help@, *-owner@, etc. + (or ml-name (setq ml-name (match-string 2 mailing-list)))) + (cons (and ml-name (car (split-string ml-name " "))) + (and ml-count (string-to-int ml-count))))) + +(defun wl-summary-overview-entity-compare-by-list-info (x y) + "Compare entity X and Y by mailing-list info." + (let* ((list-info-x (wl-summary-get-list-info x)) + (list-info-y (wl-summary-get-list-info y))) + (if (equal (car list-info-x) (car list-info-y)) + (if (equal (cdr list-info-x) (cdr list-info-y)) + (wl-summary-overview-entity-compare-by-date x y) + (< (or (cdr list-info-x) 0) + (or (cdr list-info-y) 0))) + (string< (or (car list-info-x) "") + (or (car list-info-y) ""))))) + (defun wl-summary-sort-by-date () (interactive) (wl-summary-rescan "date")) @@ -869,6 +924,9 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'." (defun wl-summary-sort-by-from () (interactive) (wl-summary-rescan "from")) +(defun wl-summary-sort-by-list-info () + (interactive) + (wl-summary-rescan "list-info")) (defun wl-summary-rescan (&optional sort-by) "Rescan current folder without updating." @@ -884,8 +942,6 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'." (inhibit-read-only t) (buffer-read-only nil) expunged) - (fset 'wl-summary-append-message-func-internal - (wl-summary-get-append-message-func)) (erase-buffer) (message "Re-scanning...") (setq i 0) @@ -910,10 +966,9 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'." (setq wl-summary-buffer-delete-list nil) (setq wl-summary-delayed-update nil) (elmo-kill-buffer wl-summary-search-buf-name) - (message "Constructing summary structure...") (while curp (setq entity (car curp)) - (wl-summary-append-message-func-internal entity msgdb nil) + (wl-summary-insert-message entity msgdb nil) (setq curp (cdr curp)) (when (> num elmo-display-progress-threshold) (setq i (+ i 1)) @@ -927,7 +982,7 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'." (caar wl-summary-delayed-update) (elmo-msgdb-overview-entity-get-number (cdar wl-summary-delayed-update))) - (wl-summary-append-message-func-internal + (wl-summary-insert-message (cdar wl-summary-delayed-update) msgdb nil t) (setq wl-summary-delayed-update (cdr wl-summary-delayed-update)))) (message "Constructing summary structure...done") @@ -936,8 +991,7 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'." (progn (message "Inserting thread...") (wl-thread-insert-top) - (message "Inserting thread...done")) - (wl-summary-make-number-list)) + (message "Inserting thread...done"))) (when wl-use-scoring (setq wl-summary-scored nil) (wl-summary-score-headers nil msgdb @@ -1004,10 +1058,10 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'." wl-summary-buffer-message-modified) (defun wl-summary-set-mark-modified () (elmo-folder-set-mark-modified-internal - wl-summary-buffer-elmo-folder t) - (setq wl-summary-buffer-mark-modified t)) + wl-summary-buffer-elmo-folder t)) (defun wl-summary-mark-modified-p () - wl-summary-buffer-mark-modified) + (elmo-folder-mark-modified-internal + wl-summary-buffer-elmo-folder)) (defun wl-summary-set-thread-modified () (setq wl-summary-buffer-thread-modified t)) (defun wl-summary-thread-modified-p () @@ -1017,7 +1071,8 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'." (if (or wl-summary-buffer-refile-list wl-summary-buffer-copy-list wl-summary-buffer-delete-list) - (if (y-or-n-p "Marks remain to be executed. Execute them? ") + (if (y-or-n-p (format "Execute remaining marks in %s? " + (wl-summary-buffer-folder-name))) (progn (wl-summary-exec) (if (or wl-summary-buffer-refile-list @@ -1144,7 +1199,6 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'." (wl-summary-cleanup-temp-marks) (erase-buffer) (wl-summary-set-message-modified) - (wl-summary-set-mark-modified) (setq wl-thread-entity-hashtb (elmo-make-hash (* (length (elmo-msgdb-get-number-alist (wl-summary-buffer-msgdb))) 2))) @@ -1323,13 +1377,15 @@ If ARG is non-nil, checking is omitted." (number-alist (elmo-msgdb-get-number-alist msgdb)) (message-id (cdr (assq number number-alist))) (ov (elmo-msgdb-overview-get-entity message-id msgdb)) - (entity ov) + (wl-message-entity ov) + (entity ov) ; backward compatibility. (size (elmo-msgdb-overview-entity-get-size ov)) (inhibit-read-only t) (buffer-read-only nil) (file-cached (elmo-file-cache-exists-p message-id)) (force-read (and size - (or (null wl-prefetch-threshold) + (or (and (null wl-prefetch-confirm) arg) + (null wl-prefetch-threshold) (< size wl-prefetch-threshold)))) mark new-mark) (unwind-protect @@ -1365,23 +1421,12 @@ If ARG is non-nil, checking is omitted." (elmo-message-encache wl-summary-buffer-elmo-folder number)) + (elmo-message-set-cached wl-summary-buffer-elmo-folder + number t) (setq new-mark - (cond - ((string= mark - wl-summary-unread-uncached-mark) - wl-summary-unread-cached-mark) - ((string= mark wl-summary-new-mark) - (setq wl-summary-buffer-new-count - (- wl-summary-buffer-new-count 1)) - (setq wl-summary-buffer-unread-count - (+ wl-summary-buffer-unread-count 1)) - wl-summary-unread-cached-mark) - ((string= mark wl-summary-read-uncached-mark) - nil) - (t mark))) - (elmo-msgdb-set-mark msgdb number new-mark) - (or new-mark (setq new-mark " ")) - (wl-summary-set-mark-modified) + (or (elmo-message-mark wl-summary-buffer-elmo-folder + number) + " ")) (wl-summary-update-modeline) (wl-folder-update-unread (wl-summary-buffer-folder-name) @@ -1389,11 +1434,6 @@ If ARG is non-nil, checking is omitted." wl-summary-buffer-new-count))) new-mark))))))) -;;(defvar wl-summary-message-uncached-marks -;; (list wl-summary-new-mark -;; wl-summary-unread-uncached-mark -;; wl-summary-read-uncached-mark)) - (defun wl-summary-prefetch-region (beg end &optional prefetch-marks) (interactive "r") (let ((count 0) @@ -1439,8 +1479,8 @@ If ARG is non-nil, checking is omitted." (wl-summary-prefetch)) (wl-summary-prefetch-msg (car targets)))) (if (if prefetch-marks - (string= mark wl-summary-unread-cached-mark) - (or (string= mark wl-summary-unread-cached-mark) + (string= mark elmo-msgdb-unread-cached-mark) + (or (string= mark elmo-msgdb-unread-cached-mark) (string= mark " "))) (message "Prefetching... %d/%d message(s)" (setq count (+ 1 count)) length)) @@ -1507,15 +1547,11 @@ If ARG is non-nil, checking is omitted." (insert " ")) (forward-line 1))))) -;; Does not work correctly... (defun wl-summary-mark-as-read-region (beg end) (interactive "r") (save-excursion (save-restriction (narrow-to-region beg end) -;;; use narrowing. -;;; (save-excursion (goto-char end) -;;; (end-of-line) (point))) (goto-char (point-min)) (if (eq wl-summary-buffer-view 'thread) (progn @@ -1525,17 +1561,16 @@ If ARG is non-nil, checking is omitted." children) (if (wl-thread-entity-get-opened entity) ;; opened...mark line. - ;; Crossposts are not processed - (wl-summary-mark-as-read t) + (wl-summary-mark-as-read number) ;; closed - (wl-summary-mark-as-read t) ; mark itself. + (wl-summary-mark-as-read number) ; mark itself. (setq children (wl-thread-get-children-msgs number)) (while children - (wl-summary-mark-as-read t nil nil (car children)) + (wl-summary-mark-as-read (car children)) (setq children (cdr children)))) (forward-line 1)))) (while (not (eobp)) - (wl-summary-mark-as-read t) + (wl-summary-mark-as-read (wl-summary-message-number)) (forward-line 1))))) (wl-summary-count-unread) (wl-summary-update-modeline)) @@ -1614,44 +1649,24 @@ If ARG is non-nil, checking is omitted." (inhibit-read-only t) (buffer-read-only nil) (case-fold-search nil) - msg mark) + msg mark new-mark) (message "Setting all msgs as read...") (elmo-folder-mark-as-read folder (elmo-folder-list-unreads - folder - (list wl-summary-unread-cached-mark - wl-summary-unread-uncached-mark - wl-summary-new-mark))) + folder)) (save-excursion (goto-char (point-min)) (while (not (eobp)) - (setq msg (wl-summary-message-number)) - (setq mark (wl-summary-persistent-mark)) - (when (and (not (string= mark " ")) - (not (string= mark wl-summary-important-mark)) - (not (string= mark wl-summary-read-uncached-mark))) + (setq msg (wl-summary-message-number) + mark (wl-summary-persistent-mark) + new-mark (or (elmo-message-mark folder msg) " ")) + (unless (string= mark new-mark) (delete-backward-char 1) - (if (or (not (elmo-message-use-cache-p folder msg)) - (string= mark wl-summary-unread-cached-mark)) - (progn - (insert " ") - (elmo-msgdb-set-mark msgdb msg nil)) - ;; New mark and unread-uncached mark - (insert wl-summary-read-uncached-mark) - (elmo-msgdb-set-mark - msgdb msg wl-summary-read-uncached-mark)) + ;; New mark and unread-uncached mark + (insert new-mark) (if wl-summary-highlight (wl-highlight-summary-current-line nil nil t))) (forward-line 1))) - (elmo-folder-replace-marks - folder - (list (cons wl-summary-unread-cached-mark - nil) - (cons wl-summary-unread-uncached-mark - wl-summary-read-uncached-mark) - (cons wl-summary-new-mark - wl-summary-read-uncached-mark))) - (wl-summary-set-mark-modified) (wl-folder-update-unread (wl-summary-buffer-folder-name) 0) (setq wl-summary-buffer-unread-count 0) (setq wl-summary-buffer-new-count 0) @@ -1669,20 +1684,12 @@ If ARG is non-nil, checking is omitted." (msgdb (wl-summary-buffer-msgdb)) (number-alist (elmo-msgdb-get-number-alist msgdb)) (case-fold-search nil) - mark number unread new-mark) - (setq mark (wl-summary-persistent-mark)) - (cond - ((or (string= mark wl-summary-new-mark) - (string= mark wl-summary-unread-uncached-mark) - (string= mark wl-summary-important-mark)) - ;; noop - ) - ((string= mark wl-summary-unread-cached-mark) - (setq new-mark wl-summary-unread-uncached-mark)) - (t - (setq new-mark wl-summary-read-uncached-mark))) - (when new-mark - (setq number (wl-summary-message-number)) + new-mark mark number unread) + (setq number (wl-summary-message-number)) + (elmo-message-set-cached folder number nil) + (setq new-mark (elmo-message-mark folder number) + mark (wl-summary-persistent-mark)) + (unless (string= new-mark mark) (delete-backward-char 1) (insert new-mark) (elmo-file-cache-delete @@ -1690,8 +1697,6 @@ If ARG is non-nil, checking is omitted." (elmo-message-field wl-summary-buffer-elmo-folder number 'message-id))) - (elmo-msgdb-set-mark msgdb number new-mark) - (wl-summary-set-mark-modified) (if wl-summary-highlight (wl-highlight-summary-current-line nil nil t)) (set-buffer-modified-p nil))))) @@ -1699,44 +1704,31 @@ If ARG is non-nil, checking is omitted." (defun wl-summary-resume-cache-status () "Resume the cache status of all messages in the current folder." (interactive) - (let* ((folder wl-summary-buffer-elmo-folder) - (cur-buf (current-buffer)) - (msgdb (wl-summary-buffer-msgdb)) - (number-alist (elmo-msgdb-get-number-alist msgdb)) - (inhibit-read-only t) - (buffer-read-only nil) - (case-fold-search nil) - msg mark msgid set-mark) + (let ((folder wl-summary-buffer-elmo-folder) + (buffer-read-only nil) + (case-fold-search nil) + number msgid set-mark mark) (message "Resuming cache status...") (save-excursion (goto-char (point-min)) (while (not (eobp)) - (setq msg (wl-summary-message-number)) + (setq number (wl-summary-message-number)) (setq mark (wl-summary-persistent-mark)) - (setq msgid (elmo-msgdb-get-field msgdb msg 'message-id)) + (setq msgid (elmo-message-field folder number 'message-id)) (setq set-mark nil) (if (elmo-file-cache-exists-p msgid) - (if (or - (string= mark wl-summary-unread-uncached-mark) ; U -> ! - (string= mark wl-summary-new-mark) ; N -> ! - ) - (setq set-mark wl-summary-unread-cached-mark) - (if (string= mark wl-summary-read-uncached-mark) ; u -> ' ' - (setq set-mark " "))) - (if (string= mark " ") - (setq set-mark wl-summary-read-uncached-mark) ;' ' -> u - (if (string= mark wl-summary-unread-cached-mark) - (setq set-mark wl-summary-unread-uncached-mark) ; ! -> U - ))) + (when (member mark (elmo-msgdb-uncached-marks)) + (elmo-message-set-cached folder number t) + (setq set-mark (elmo-message-mark folder number))) + (unless (member mark (elmo-msgdb-uncached-marks)) + (elmo-message-set-cached folder number nil) + (setq set-mark (or (elmo-message-mark folder number) " ")))) (when set-mark (delete-backward-char 1) (insert set-mark) - (elmo-msgdb-set-mark msgdb msg - (if (string= set-mark " ") nil set-mark)) (if wl-summary-highlight (wl-highlight-summary-current-line))) (forward-line 1)) - (wl-summary-set-mark-modified) (wl-summary-count-unread) (wl-summary-update-modeline) (message "Resuming cache status...done") @@ -1800,6 +1792,25 @@ If ARG is non-nil, checking is omitted." (wl-highlight-summary-current-line))) (forward-line 1))))) +(defun wl-summary-update-status-marks () + "Synchronize status marks on current buffer to the msgdb." + (interactive) + (save-excursion + (goto-char (point-min)) + (let ((inhibit-read-only t) + (buffer-read-only nil) + mark) + (while (not (eobp)) + (unless (string= (wl-summary-persistent-mark) + (setq mark (or (elmo-message-mark + wl-summary-buffer-elmo-folder + (wl-summary-message-number)) + " "))) + (delete-backward-char 1) + (insert mark) + (if wl-summary-highlight (wl-highlight-summary-current-line))) + (forward-line 1))))) + (defun wl-summary-get-delete-folder (folder) (if (string= folder wl-trash-folder) 'null @@ -1819,35 +1830,28 @@ If ARG is non-nil, checking is omitted." (error "Trash Folder is not created")))) wl-trash-folder))))) -(defun wl-summary-get-append-message-func () +(defun wl-summary-insert-message (&rest args) (if (eq wl-summary-buffer-view 'thread) - 'wl-summary-insert-thread-entity - 'wl-summary-insert-sequential)) + (apply 'wl-summary-insert-thread-entity args) + (apply 'wl-summary-insert-sequential args))) (defun wl-summary-sort () (interactive) - (let ((sort-by (let ((input-range-list '("number" "date" "subject" "from")) - (default "date") - in) - (setq in - (completing-read - (format "Sort by (%s): " default) - (mapcar - (function (lambda (x) (cons x x))) - input-range-list))) - (if (string= in "") - default - in)))) - (if (not (member sort-by '("number" "date" "subject" "from"))) - (error "Sort by %s is not implemented" sort-by)) - (wl-summary-rescan sort-by))) + (wl-summary-rescan + (completing-read + (format "Sort by (%s): " (symbol-name wl-summary-default-sort-spec)) + (mapcar (lambda (spec) + (list (symbol-name spec))) + wl-summary-sort-specs) + nil t nil nil (symbol-name wl-summary-default-sort-spec)))) (defun wl-summary-sync-marks () "Update marks in summary." (interactive) (let ((last-progress 0) + (folder wl-summary-buffer-elmo-folder) (i 0) - unread-marks importants unreads + importants unreads importants-in-db unreads-in-db diff diffs mes progress) ;; synchronize marks. @@ -1855,27 +1859,27 @@ If ARG is non-nil, checking is omitted." wl-summary-buffer-elmo-folder) 'internal)) (message "Updating marks...") - (setq unread-marks (list wl-summary-unread-cached-mark - wl-summary-unread-uncached-mark - wl-summary-new-mark) - importants-in-db (elmo-folder-list-messages-mark-match + (setq importants-in-db (elmo-folder-list-messages-mark-match wl-summary-buffer-elmo-folder - (regexp-quote wl-summary-important-mark)) + (regexp-quote elmo-msgdb-important-mark)) unreads-in-db (elmo-folder-list-messages-mark-match wl-summary-buffer-elmo-folder - (wl-regexp-opt unread-marks)) - importants (elmo-folder-list-importants - wl-summary-buffer-elmo-folder - wl-summary-important-mark) + (wl-regexp-opt (elmo-msgdb-unread-marks))) + importants (elmo-uniq-list + (nconc + (elmo-folder-list-importants + wl-summary-buffer-elmo-folder) + (elmo-folder-list-messages-with-global-mark + wl-summary-buffer-elmo-folder + elmo-msgdb-important-mark))) unreads (elmo-folder-list-unreads - wl-summary-buffer-elmo-folder - unread-marks)) + wl-summary-buffer-elmo-folder)) (setq diff (elmo-list-diff importants importants-in-db)) (setq diffs (cadr diff)) ; important-deletes (setq mes (format "Updated (-%d" (length diffs))) (while diffs (wl-summary-mark-as-important (car diffs) - wl-summary-important-mark + elmo-msgdb-important-mark 'no-server) (setq diffs (cdr diffs))) (setq diffs (car diff)) ; important-appends @@ -1887,12 +1891,12 @@ If ARG is non-nil, checking is omitted." (setq diffs (cadr diff)) (setq mes (concat mes (format "(-%d" (length diffs)))) (while diffs - (wl-summary-mark-as-read t 'no-server nil (car diffs)) + (wl-summary-mark-as-read (car diffs) 'no-folder 'no-modeline) (setq diffs (cdr diffs))) (setq diffs (car diff)) ; unread-appends (setq mes (concat mes (format "/+%d) unread mark(s)." (length diffs)))) (while diffs - (wl-summary-mark-as-unread (car diffs) 'no-server 'no-modeline) + (wl-summary-mark-as-unread (car diffs) 'no-folder 'no-modeline) (setq diffs (cdr diffs))) (if (interactive-p) (message mes))))) @@ -1906,34 +1910,22 @@ If ARG is non-nil, checking is omitted." (buffer-read-only nil) gc-message overview number-alist - curp num i new-msgdb + curp num i diff append-list delete-list crossed update-thread update-top-list - expunged mes sync-result entity) + expunged mes entity) (unwind-protect (progn (unless wl-summary-buffer-elmo-folder (error "(Internal error) Folder is not set:%s" (buffer-name (current-buffer)))) - (fset 'wl-summary-append-message-func-internal - (wl-summary-get-append-message-func)) ;; Flush pending append operations (disconnected operation). ;;(setq seen-list ;;(wl-summary-flush-pending-append-operations seen-list)) (goto-char (point-max)) (wl-folder-confirm-existence folder (elmo-folder-plugged-p folder)) - (setq sync-result (elmo-folder-synchronize - folder - wl-summary-new-mark - wl-summary-unread-uncached-mark - wl-summary-unread-cached-mark - wl-summary-read-uncached-mark - wl-summary-important-mark - sync-all no-check)) - (setq new-msgdb (nth 0 sync-result)) - (setq delete-list (nth 1 sync-result)) - (setq crossed (nth 2 sync-result)) - (if sync-result + (setq crossed (elmo-folder-synchronize folder sync-all no-check)) + (if crossed (progn ;; Setup sync-all (if sync-all (wl-summary-sync-all-init)) @@ -1944,19 +1936,24 @@ If ARG is non-nil, checking is omitted." ; (wl-summary-delete-canceled-msgs-from-list ; delete-list ; (wl-summary-buffer-msgdb)))) + (setq diff (elmo-list-diff (elmo-folder-list-messages + folder + 'visible-only + 'in-msgdb) + wl-summary-buffer-number-list)) + (setq append-list (car diff)) + (setq delete-list (cadr diff)) + (when delete-list - (wl-summary-delete-messages-on-buffer delete-list "Deleting...") + (wl-summary-delete-messages-on-buffer + delete-list "Deleting...") (message "Deleting...done")) - (when new-msgdb - (wl-summary-replace-status-marks - wl-summary-new-mark - wl-summary-unread-uncached-mark)) - (setq append-list (elmo-msgdb-get-overview new-msgdb)) + (wl-summary-update-status-marks) (setq curp append-list) (setq num (length curp)) (when append-list (setq i 0) - + ;; set these value for append-message-func (setq overview (elmo-msgdb-get-overview (elmo-folder-msgdb folder))) @@ -1966,9 +1963,10 @@ If ARG is non-nil, checking is omitted." (setq wl-summary-delayed-update nil) (elmo-kill-buffer wl-summary-search-buf-name) (while curp - (setq entity (car curp)) + (setq entity (elmo-msgdb-overview-get-entity + (car curp) (elmo-folder-msgdb folder))) (when (setq update-thread - (wl-summary-append-message-func-internal + (wl-summary-insert-message entity (elmo-folder-msgdb folder) (not sync-all))) (wl-append update-top-list update-thread)) @@ -1981,7 +1979,10 @@ If ARG is non-nil, checking is omitted." (setq i (+ i 1)) (if (or (zerop (% i 5)) (= i num)) (elmo-display-progress - 'wl-summary-sync-update "Updating thread..." + 'wl-summary-sync-update + (if (eq wl-summary-buffer-view 'thread) + "Making thread..." + "Inserting message...") (/ (* i 100) num))))) (when wl-summary-delayed-update (while wl-summary-delayed-update @@ -1990,7 +1991,7 @@ If ARG is non-nil, checking is omitted." (elmo-msgdb-overview-entity-get-number (cdar wl-summary-delayed-update))) (when (setq update-thread - (wl-summary-append-message-func-internal + (wl-summary-insert-message (cdar wl-summary-delayed-update) (elmo-folder-msgdb folder) (not sync-all) t)) @@ -2001,17 +2002,15 @@ If ARG is non-nil, checking is omitted." update-top-list) (wl-thread-update-indent-string-thread (elmo-uniq-list update-top-list))) - (message "Updating thread...done")) - (unless (eq wl-summary-buffer-view 'thread) - (wl-summary-make-number-list)) + (message (if (eq wl-summary-buffer-view 'thread) + "Making thread...done" + "Inserting message...done"))) (wl-summary-set-message-modified) - (wl-summary-set-mark-modified) (when (and sync-all (eq wl-summary-buffer-view 'thread)) (elmo-kill-buffer wl-summary-search-buf-name) - (message "Inserting thread...") - (setq wl-thread-entity-cur 0) + (message "Inserting message...") (wl-thread-insert-top) - (message "Inserting thread...done")) + (message "Inserting message...done")) (if elmo-use-database (elmo-database-close)) (run-hooks 'wl-summary-sync-updated-hook) @@ -2025,7 +2024,7 @@ If ARG is non-nil, checking is omitted." (length delete-list) num)))) (setq mes "Quit updating."))) ;; synchronize marks. - (if (and wl-summary-auto-sync-marks sync-result) + (if (and crossed wl-summary-auto-sync-marks) (wl-summary-sync-marks)) ;; scoring (when wl-use-scoring @@ -2050,8 +2049,8 @@ If ARG is non-nil, checking is omitted." (wl-folder-set-folder-updated (elmo-folder-name-internal folder) (list 0 - (let ((pair (wl-summary-count-unread))) - (+ (car pair) (cdr pair))) + (let ((lst (wl-summary-count-unread))) + (+ (car lst) (nth 1 lst))) (elmo-folder-messages folder))) (wl-summary-update-modeline) ;; @@ -2161,7 +2160,6 @@ If ARG is non-nil, checking is omitted." dels) ;;; (elmo-msgdb-save (wl-summary-buffer-folder-name) nil) (wl-summary-set-message-modified) - (wl-summary-set-mark-modified) (wl-folder-set-folder-updated (wl-summary-buffer-folder-name) (list 0 0 0)) ;;; for thread. @@ -2272,7 +2270,6 @@ If ARG, without confirm." wl-summary-buffer-temp-mark-column wl-summary-buffer-persistent-mark-column wl-summary-buffer-message-modified - wl-summary-buffer-mark-modified wl-summary-buffer-thread-modified wl-summary-buffer-number-list wl-summary-buffer-msgdb @@ -2328,10 +2325,15 @@ If ARG, without confirm." (get-buffer-create wl-summary-buffer-name)))) (defun wl-summary-make-number-list () - (setq wl-summary-buffer-number-list - (mapcar - (lambda (x) (elmo-msgdb-overview-entity-get-number x)) - (elmo-msgdb-get-overview (wl-summary-buffer-msgdb))))) + (save-excursion + (goto-char (point-min)) + (while (not (eobp)) + (setq wl-summary-buffer-number-list + (cons (wl-summary-message-number) + wl-summary-buffer-number-list)) + (forward-line 1)) + (setq wl-summary-buffer-number-list + (nreverse wl-summary-buffer-number-list)))) (defun wl-summary-auto-select-msg-p (unread-msg) (and unread-msg @@ -2339,7 +2341,7 @@ If ARG, without confirm." (elmo-msgdb-get-mark (wl-summary-buffer-msgdb) unread-msg) - wl-summary-important-mark)))) + elmo-msgdb-important-mark)))) (defsubst wl-summary-open-folder (folder) ;; Select folder @@ -2414,9 +2416,14 @@ If ARG, without confirm." (decode-mime-charset-region (point-min)(point-max) wl-summary-buffer-mime-charset 'LF)) - (when (file-exists-p view) + (if (file-exists-p view) + (setq wl-summary-buffer-view + (wl-summary-load-file-object view)) (setq wl-summary-buffer-view - (wl-summary-load-file-object view))) + (or (wl-get-assoc-list-value + wl-summary-default-view-alist + (elmo-folder-name-internal folder)) + wl-summary-default-view))) (wl-thread-resume-entity folder) (wl-summary-open-folder folder)) (setq wl-summary-buffer-view @@ -2429,12 +2436,11 @@ If ARG, without confirm." (wl-summary-update-modeline))) (unless (eq wl-summary-buffer-view 'thread) (wl-summary-make-number-list)) - ;; XXX old summary format; do rescan. - (save-excursion - (goto-char (point-min)) - (if (and wl-summary-buffer-number-list - (not (re-search-forward "\r-?[0-9]+" (point-at-eol) t))) - (wl-summary-rescan))) + (when (and wl-summary-cache-use + (or (and wl-summary-check-line-format + (wl-summary-line-format-changed-p)) + (wl-summary-view-old-p))) + (wl-summary-rescan)) (wl-summary-toggle-disp-msg (if wl-summary-buffer-disp-msg 'on 'off)) (unless (and reuse-buf keep-cursor) ;(setq hilit wl-summary-highlight) @@ -2581,7 +2587,11 @@ If ARG, without confirm." (elmo-msgdb-get-mark msgdb (elmo-msgdb-overview-entity-get-number - entity)))))) + entity)))) + (setq wl-summary-buffer-number-list + (wl-append wl-summary-buffer-number-list + (list (elmo-msgdb-overview-entity-get-number entity)))) + nil)) (defun wl-summary-default-subject-filter (subject) (let ((case-fold-search t)) @@ -2603,6 +2613,7 @@ If ARG, without confirm." wl-summary-alike-hashtb))) (defun wl-summary-insert-headers (overview func mime-decode) + (message "Creating subject cache...") (let (ov this last alike) (buffer-disable-undo (current-buffer)) (make-local-variable 'wl-summary-alike-hashtb) @@ -2627,6 +2638,7 @@ If ARG, without confirm." elmo-mime-charset) (when (eq mime-decode 'mime) (eword-decode-region (point-min) (point-max)))) + (message "Creating subject cache...done") (run-hooks 'wl-summary-insert-headers-hook))) (defun wl-summary-search-by-subject (entity overview) @@ -2774,69 +2786,38 @@ If ARG, without confirm." (wl-thread-entity-get-linked thr-entity)))))) (defun wl-summary-mark-as-unread (&optional number - no-server-update + no-folder-mark no-modeline-update) (interactive) (save-excursion - (let* (eol - (inhibit-read-only t) - (buffer-read-only nil) + (let ((buffer-read-only nil) (folder wl-summary-buffer-elmo-folder) - (msgdb (wl-summary-buffer-msgdb)) -;;; (number-alist (elmo-msgdb-get-number-alist msgdb)) - new-mark visible mark cur-mark) - (if number - (progn - (setq visible (wl-summary-jump-to-msg number)) - (unless (setq mark (elmo-msgdb-get-mark msgdb number)) - (setq mark " "))) - ;; interactive - (setq visible t)) + mark new-mark visible) + (setq visible (if number + (wl-summary-jump-to-msg number) + t) + number (or number (wl-summary-message-number)) + mark (elmo-message-mark folder number)) + (unless (member mark (elmo-msgdb-unread-marks)) + (elmo-folder-unmark-read folder (list number) no-folder-mark)) + (setq new-mark (elmo-message-mark folder number)) + (unless no-modeline-update + ;; Update unread numbers. + ;; should elmo-folder-mark-as-read return unread numbers? + (wl-summary-count-unread) + (wl-summary-update-modeline) + (wl-folder-update-unread + (wl-summary-buffer-folder-name) + (+ wl-summary-buffer-unread-count + wl-summary-buffer-new-count))) (when visible - (if (null (wl-summary-message-number)) - (message "No message.") - (end-of-line) - (setq eol (point)) - (wl-summary-goto-previous-message-beginning))) - (if (or (and (not visible) - ;; already exists in msgdb. - (elmo-msgdb-overview-get-entity number msgdb)) - (progn - ;; visible. - (setq cur-mark (wl-summary-persistent-mark)) - (or (string= cur-mark " ") - (string= cur-mark wl-summary-read-uncached-mark)))) - (progn - (setq number (or number (wl-summary-message-number))) - (setq mark (or mark cur-mark)) - (save-match-data - (setq new-mark (if (string= mark - wl-summary-read-uncached-mark) - wl-summary-unread-uncached-mark - (if (elmo-message-use-cache-p folder number) - wl-summary-unread-mark - wl-summary-unread-uncached-mark)))) - ;; server side mark - (unless no-server-update - (save-match-data - (unless (elmo-folder-unmark-read folder (list number)) - (error "Setting mark failed")))) - (when visible - (delete-backward-char 1) - (insert new-mark)) - (elmo-msgdb-set-mark msgdb number new-mark) - (unless no-modeline-update - (setq wl-summary-buffer-unread-count - (+ 1 wl-summary-buffer-unread-count)) - (wl-summary-update-modeline) - (wl-folder-update-unread - (wl-summary-buffer-folder-name) - (+ wl-summary-buffer-unread-count - wl-summary-buffer-new-count))) - (wl-summary-set-mark-modified) - (if (and visible wl-summary-highlight) - (wl-highlight-summary-current-line)))))) - (set-buffer-modified-p nil)) + (unless (string= (wl-summary-persistent-mark) new-mark) + (delete-backward-char 1) + (insert (or new-mark " ")) + (if (and visible wl-summary-highlight) + (wl-highlight-summary-current-line)) + (set-buffer-modified-p nil))) + number))) (defun wl-summary-delete (&optional number) "Mark a delete mark 'D'. @@ -2956,9 +2937,6 @@ If optional argument NUMBER is specified, mark message specified by NUMBER." (let ((del-fld (wl-summary-get-delete-folder (wl-summary-buffer-folder-name))) (start (point)) - (unread-marks (list wl-summary-unread-cached-mark - wl-summary-unread-uncached-mark - wl-summary-new-mark)) (refiles (append moves dels)) (refile-failures 0) (copy-failures 0) @@ -2997,7 +2975,6 @@ If optional argument NUMBER is specified, mark message specified by NUMBER." (not (null (cdr dst-msgs))) nil ; no-delete nil ; same-number - unread-marks t)) (error nil)) (if result ; succeeded. @@ -3030,7 +3007,6 @@ If optional argument NUMBER is specified, mark message specified by NUMBER." (not (null (cdr dst-msgs))) t ; t is no-delete (copy) nil ; same number - unread-marks t)) (error nil)) (if result ; succeeded. @@ -3049,7 +3025,6 @@ If optional argument NUMBER is specified, mark message specified by NUMBER." ;; end cOpy (wl-summary-folder-info-update) (wl-summary-set-message-modified) - (wl-summary-set-mark-modified) (run-hooks 'wl-summary-exec-hook) (unless (and wl-message-buffer (eq (wl-summary-message-number) @@ -3383,7 +3358,7 @@ If optional argument NUMBER is specified, mark message specified by NUMBER." (defun wl-summary-refile-region (beg end) - "Put copy mark on messages in the region specified by BEG and END." + "Put refile mark on messages in the region specified by BEG and END." (interactive "r") (wl-summary-refile-region-subr "refile" beg end)) @@ -3721,11 +3696,9 @@ If ARG, exit virtual folder." number (wl-summary-buffer-msgdb))) (if (null entity) (error "Cannot %s" copy-or-refile)) - (funcall function - (setq folder (wl-summary-read-folder - (wl-refile-guess entity) - (format "for %s" copy-or-refile))) - number) + (setq folder (wl-summary-read-folder + (wl-refile-guess entity) + (format "for %s" copy-or-refile))) (goto-char (point-min)) (while (not (eobp)) (when (string= (wl-summary-temp-mark) "*") @@ -3788,15 +3761,17 @@ If ARG, exit virtual folder." ;; delete target-mark from buffer. (delete-backward-char 1) (insert " ") - (setq number (wl-summary-mark-as-read t)) + (setq number (wl-summary-message-number)) + (wl-summary-mark-as-read number) (if wl-summary-highlight (wl-highlight-summary-current-line)) (if number (setq wl-summary-buffer-target-mark-list - (delq number wl-summary-buffer-target-mark-list))))) + (delq number wl-summary-buffer-target-mark-list)))) + (forward-line 1)) (setq mlist wl-summary-buffer-target-mark-list) (while mlist - (wl-summary-mark-as-read t nil nil (car mlist)) + (wl-summary-mark-as-read (car mlist)) (setq wl-summary-buffer-target-mark-list (delq (car mlist) wl-summary-buffer-target-mark-list)) (setq mlist (cdr mlist))) @@ -3879,89 +3854,44 @@ If ARG, exit virtual folder." (interactive) (wl-summary-pick wl-summary-buffer-target-mark-list 'delete)) -(defun wl-summary-mark-as-read (&optional notcrosses - leave-server-side-mark-untouched - displayed - number - cached) +(defun wl-summary-mark-as-read (&optional number + no-folder-mark + no-modeline-update) (interactive) (save-excursion - (let* (eol - (inhibit-read-only t) - (buffer-read-only nil) - (folder wl-summary-buffer-elmo-folder) - (msgdb (wl-summary-buffer-msgdb)) -;;; (number-alist (elmo-msgdb-get-number-alist msgdb)) - (case-fold-search nil) - cur-mark mark stat visible uncached new-mark marked) - (if number - (progn - (setq visible (wl-summary-jump-to-msg number)) - (setq mark (elmo-msgdb-get-mark msgdb number))) - ;; interactive - (setq visible t)) - (beginning-of-line) - (if (or (not visible) - (progn - (setq cur-mark (wl-summary-persistent-mark)) - (or (string= cur-mark wl-summary-read-uncached-mark) - (string= cur-mark wl-summary-unread-uncached-mark) - (string= cur-mark wl-summary-unread-cached-mark) - (string= cur-mark wl-summary-new-mark)))) - (progn - (setq mark (or mark cur-mark)) - (when mark - (cond - ((string= mark wl-summary-new-mark) ; N - (setq stat 'new) - (setq uncached t)) - ((string= mark wl-summary-unread-uncached-mark) ; U - (setq stat 'unread) - (setq uncached t)) - ((string= mark wl-summary-unread-cached-mark) ; ! - (setq stat 'unread)) - (t - ;; no need to mark server. - (setq leave-server-side-mark-untouched t)))) - (setq number (or number (wl-summary-message-number))) - ;; set server side mark... - (setq new-mark - (if (and uncached - (if (elmo-message-use-cache-p folder number) - (not (elmo-folder-local-p folder))) - (not cached)) - wl-summary-read-uncached-mark - nil)) - (if (not leave-server-side-mark-untouched) - (save-match-data - (setq marked (elmo-folder-mark-as-read - folder - (list number))))) - (if (or leave-server-side-mark-untouched - marked) - (progn - (cond ((eq stat 'unread) - (setq wl-summary-buffer-unread-count - (1- wl-summary-buffer-unread-count))) - ((eq stat 'new) - (setq wl-summary-buffer-new-count - (1- wl-summary-buffer-new-count)))) - (wl-summary-update-modeline) - (wl-folder-update-unread - (wl-summary-buffer-folder-name) - (+ wl-summary-buffer-unread-count - wl-summary-buffer-new-count)) - (when (or stat cached) - (when visible - (delete-backward-char 1) - (insert (or new-mark " "))) - (elmo-msgdb-set-mark msgdb number new-mark) - (wl-summary-set-mark-modified)) - (if (and visible wl-summary-highlight) - (wl-highlight-summary-current-line nil nil t))) - (if mark (message "Warning: Changing mark failed."))))) - (set-buffer-modified-p nil) - (if stat + (let ((buffer-read-only nil) + (folder wl-summary-buffer-elmo-folder) + (msgdb (wl-summary-buffer-msgdb)) + (case-fold-search nil) + mark visible new-mark) + (setq visible (if number + (wl-summary-jump-to-msg number) + ;; interactive + t) + number (or number (wl-summary-message-number)) + mark (elmo-message-mark folder number)) + (when (member mark (elmo-msgdb-unread-marks)) + ;; folder mark. + (elmo-folder-mark-as-read folder (list number) no-folder-mark)) + (setq new-mark (elmo-message-mark folder number)) + (unless no-modeline-update + ;; Update unread numbers. + ;; should elmo-folder-mark-as-read return unread numbers? + (wl-summary-count-unread) + (wl-summary-update-modeline) + (wl-folder-update-unread + (wl-summary-buffer-folder-name) + (+ wl-summary-buffer-unread-count + wl-summary-buffer-new-count))) + ;; set mark on buffer + (when visible + (unless (string= (wl-summary-persistent-mark) 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)) + (if (member mark (elmo-msgdb-unread-marks)) (run-hooks 'wl-summary-unread-message-hook)) number ;return value ))) @@ -4005,7 +3935,7 @@ If ARG, exit virtual folder." wl-summary-buffer-elmo-folder number 'message-id)) - (if (string= mark wl-summary-important-mark) + (if (string= mark elmo-msgdb-important-mark) (progn ;; server side mark (save-match-data @@ -4028,17 +3958,16 @@ If ARG, exit virtual folder." (elmo-folder-mark-as-important folder (list number)))) (when visible (delete-backward-char 1) - (insert wl-summary-important-mark)) + (insert elmo-msgdb-important-mark)) (elmo-msgdb-set-mark msgdb number - wl-summary-important-mark) + 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. (elmo-message-encache folder number 'read)) (unless no-server-update (elmo-msgdb-global-mark-set message-id - wl-summary-important-mark))) - (wl-summary-set-mark-modified))) + elmo-msgdb-important-mark))))) (if (and visible wl-summary-highlight) (wl-highlight-summary-current-line nil nil t)))) (set-buffer-modified-p nil) @@ -4047,6 +3976,33 @@ If ARG, exit virtual folder." ;;; Summary line. (defvar wl-summary-line-formatter nil) +(defun wl-summary-view-old-p () + "Return non-nil when summary view cache has old format." + (save-excursion + (goto-char (point-min)) + (and wl-summary-buffer-number-list + (not (re-search-forward "\r-?[0-9]+" (point-at-eol) t))))) + +(defun wl-summary-line-format-changed-p () + "Return non-nil when summary line format is changed." + (not (string= + wl-summary-buffer-line-format + (or (elmo-object-load (expand-file-name + wl-summary-line-format-file + (elmo-folder-msgdb-path + wl-summary-buffer-elmo-folder)) + wl-summary-buffer-mime-charset) + wl-summary-buffer-line-format)))) + +(defun wl-summary-line-format-save () + "Save current summary line format." + (elmo-object-save + (expand-file-name wl-summary-line-format-file + (elmo-folder-msgdb-path + wl-summary-buffer-elmo-folder)) + wl-summary-buffer-line-format + wl-summary-buffer-mime-charset)) + (defun wl-summary-line-number () (wl-set-string-width (- wl-summary-buffer-number-column) @@ -4122,66 +4078,22 @@ If ARG, exit virtual folder." wl-message-entity)))) (defun wl-summary-line-list-info () - (let ((folder wl-summary-buffer-folder-name) - (sequence) (ml-name) (ml-count) (subject-string)) - (setq sequence (elmo-msgdb-overview-entity-get-extra-field - wl-message-entity "x-sequence") - ml-name (or (elmo-msgdb-overview-entity-get-extra-field - wl-message-entity "x-ml-name") - (and sequence - (car (split-string sequence " ")))) - ml-count (or (elmo-msgdb-overview-entity-get-extra-field - wl-message-entity "x-mail-count") - (elmo-msgdb-overview-entity-get-extra-field - wl-message-entity "x-ml-count") - (and sequence - (cadr (split-string sequence " ")))) - subject-string - (elmo-delete-char ?\n - (or (elmo-msgdb-overview-entity-get-subject - wl-message-entity) - wl-summary-no-subject-message))) - (if (string-match - "^\\s(\\(\\S)+\\)[ :]\\([0-9]+\\)\\s)[ \t]*" - subject-string) - (progn - (if (not ml-name) (setq ml-name (match-string 1 subject-string))) - (if (not ml-count) (setq ml-count (match-string 2 subject-string))))) - (condition-case nil - (if (and ml-name ml-count) - (format "(%s %05d)" - (car (split-string ml-name " ")) - (string-to-int ml-count)) - "") - (error "")))) + (let ((list-info (wl-summary-get-list-info wl-message-entity))) + (if (car list-info) + (format (if (cdr list-info) "(%s %05d)" "(%s)") + (car list-info) (cdr list-info)) + ""))) (defun wl-summary-line-list-count () - (let ((folder wl-summary-buffer-folder-name) - (sequence) (ml-count) (subject-string)) - (setq sequence (elmo-msgdb-overview-entity-get-extra-field - wl-message-entity "x-sequence") - ml-count (or (elmo-msgdb-overview-entity-get-extra-field - wl-message-entity "x-mail-count") - (elmo-msgdb-overview-entity-get-extra-field - wl-message-entity "x-ml-count") - (and sequence - (cadr (split-string sequence " "))))) + (let ((ml-count (cdr (wl-summary-get-list-info wl-message-entity)))) (if ml-count - (format "%d" (string-to-int ml-count)) - (setq subject-string - (elmo-delete-char ?\n - (or (elmo-msgdb-overview-entity-get-subject - wl-message-entity) - ""))) - (if (string-match - "^\\s(\\(\\S)+\\)[ :]\\([0-9]+\\)\\s)[ \t]*" - subject-string) - (match-string 2 subject-string) - "")))) + (format "%.0f" ml-count) + ""))) (defun wl-summary-line-attached () (let ((content-type (elmo-msgdb-overview-entity-get-extra-field - wl-message-entity "content-type"))) + wl-message-entity "content-type")) + (case-fold-search t)) (if (and content-type (string-match "multipart/mixed" content-type)) "@" @@ -4217,7 +4129,8 @@ If ARG, exit virtual folder." (setq line (funcall wl-summary-buffer-line-formatter)) (if wl-summary-width (setq line (wl-set-string-width - (- wl-summary-width 1) line))) + (- wl-summary-width 1) line nil + 'ignore-invalid))) (setq line (concat line "\r" (number-to-string @@ -4238,25 +4151,25 @@ If ARG, exit virtual folder." (defvar wl-summary-move-spec-plugged-alist (` ((new . ((t . nil) - (p . (, wl-summary-new-mark)) + (p . (, elmo-msgdb-new-mark)) (p . (, (wl-regexp-opt - (list wl-summary-unread-uncached-mark - wl-summary-unread-cached-mark)))) - (p . (, (regexp-quote wl-summary-important-mark))))) + (list elmo-msgdb-unread-uncached-mark + elmo-msgdb-unread-cached-mark)))) + (p . (, (regexp-quote elmo-msgdb-important-mark))))) (unread . ((t . nil) (p . (, (wl-regexp-opt - (list wl-summary-new-mark - wl-summary-unread-uncached-mark - wl-summary-unread-cached-mark)))) - (p . (, (regexp-quote wl-summary-important-mark)))))))) + (list elmo-msgdb-new-mark + elmo-msgdb-unread-uncached-mark + elmo-msgdb-unread-cached-mark)))) + (p . (, (regexp-quote elmo-msgdb-important-mark)))))))) (defvar wl-summary-move-spec-unplugged-alist (` ((new . ((t . nil) - (p . (, wl-summary-unread-cached-mark)) - (p . (, (regexp-quote wl-summary-important-mark))))) + (p . (, elmo-msgdb-unread-cached-mark)) + (p . (, (regexp-quote elmo-msgdb-important-mark))))) (unread . ((t . nil) - (p . (, wl-summary-unread-cached-mark)) - (p . (, (regexp-quote wl-summary-important-mark)))))))) + (p . (, elmo-msgdb-unread-cached-mark)) + (p . (, (regexp-quote elmo-msgdb-important-mark)))))))) (defsubst wl-summary-next-message (num direction hereto) (if wl-summary-buffer-next-message-function @@ -4337,13 +4250,17 @@ If ARG, exit virtual folder." (elmo-make-directory dir))) (if (eq save-view 'thread) (wl-thread-save-entity dir)) + (when wl-summary-check-line-format + (wl-summary-line-format-save)) (unwind-protect (progn (when (file-writable-p cache) (copy-to-buffer tmp-buffer (point-min) (point-max)) (with-current-buffer tmp-buffer (widen) - (setq wl-summary-buffer-target-mark-list mark-list + (make-local-variable 'wl-summary-highlight) + (setq wl-summary-highlight nil + wl-summary-buffer-target-mark-list mark-list wl-summary-buffer-refile-list refile-list wl-summary-buffer-copy-list copy-list wl-summary-buffer-delete-list delete-list @@ -4351,7 +4268,8 @@ If ARG, exit virtual folder." (wl-summary-delete-all-temp-marks) (encode-coding-region (point-min) (point-max) - (or (mime-charset-to-coding-system charset 'LF) + (or (and wl-on-mule ; one in mcs-ltn1 cannot take 2 arg. + (mime-charset-to-coding-system charset 'LF)) ;; Mule 2 doesn't have `*ctext*unix'. (mime-charset-to-coding-system charset))) (write-region-as-binary (point-min)(point-max) @@ -4765,6 +4683,7 @@ Return t if message exists." (defun wl-summary-jump-to-parent-message (arg) (interactive "P") (let ((cur-buf (current-buffer)) + (disp-msg wl-summary-buffer-disp-msg) (number (wl-summary-message-number)) (regexp "\\(<[^<>]*>\\)[ \t]*$") (i -1) ;; xxx @@ -4818,17 +4737,18 @@ Return t if message exists." (setq msg-id (if (null arg) (nth 0 ref-list) ;; previous (if (<= arg i) (nth (1- arg) ref-list) - (nth i ref-list))))))) - (set-buffer cur-buf) + (nth i ref-list)))))) + (set-buffer cur-buf) + (or disp-msg (wl-summary-toggle-disp-msg 'off))) (cond ((and (null msg-id) (null msg-num)) (message "No parent message!") nil) ((and msg-id (wl-summary-jump-to-msg-by-message-id msg-id)) - (wl-summary-redisplay) + (if wl-summary-buffer-disp-msg (wl-summary-redisplay)) (message "Searching parent message...done") t) ((and msg-num (wl-summary-jump-to-msg msg-num)) - (wl-summary-redisplay) + (if wl-summary-buffer-disp-msg (wl-summary-redisplay)) (message "Searching parent message...done") t) (t ; failed. @@ -4964,14 +4884,14 @@ Use function list is `wl-summary-write-current-folder-functions'." () (setq skip-pmark-regexp (wl-regexp-opt (list " " - wl-summary-unread-cached-mark - wl-summary-important-mark)))) + elmo-msgdb-unread-cached-mark + elmo-msgdb-important-mark)))) (while (and skip (not (if downward (eobp) (bobp)))) (if downward (forward-line 1) (forward-line -1)) - (setq skip (or (string-match skip-tmark-regexp + (setq skip (or (string-match skip-tmark-regexp (save-excursion (wl-summary-temp-mark))) (and skip-pmark-regexp @@ -5123,7 +5043,7 @@ Use function list is `wl-summary-write-current-folder-functions'." (num (or number (wl-summary-message-number))) (wl-mime-charset wl-summary-buffer-mime-charset) (default-mime-charset wl-summary-buffer-mime-charset) - fld-buf fld-win thr-entity) + no-folder-mark fld-buf fld-win thr-entity) (if (and wl-thread-open-reading-thread (eq wl-summary-buffer-view 'thread) (not (wl-thread-entity-get-opened @@ -5142,27 +5062,25 @@ Use function list is `wl-summary-write-current-folder-functions'." (if (setq fld-win (get-buffer-window fld-buf)) (delete-window fld-win))) (setq wl-current-summary-buffer (current-buffer)) - (wl-summary-mark-as-read - nil - ;; not fetched, then change server-mark. - (if (wl-message-redisplay folder num 'mime - (or force-reload - (string= (elmo-folder-name-internal - folder) - wl-draft-folder))) - nil - ;; plugged, then leave server-mark. - (if (and - (not - (elmo-folder-local-p - wl-summary-buffer-elmo-folder)) - (elmo-folder-plugged-p - wl-summary-buffer-elmo-folder)) - 'leave)) - t ; displayed - nil - 'cached ; cached by reading. - ) + (setq no-folder-mark + ;; If cache is used, change folder-mark. + (if (wl-message-redisplay folder num + 'mime + (or + force-reload + (string= (elmo-folder-name-internal + folder) + wl-draft-folder))) + nil + ;; plugged, then leave folder-mark. + (if (and (not (elmo-folder-local-p + wl-summary-buffer-elmo-folder)) + (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) (setq wl-summary-buffer-current-msg num) (when wl-summary-recenter (recenter (/ (- (window-height) 2) 2)) @@ -5200,7 +5118,7 @@ If ASK-CODING is non-nil, coding-system for the message is asked." (wl-message-redisplay fld num 'as-is (string= (elmo-folder-name-internal fld) wl-draft-folder)) - (wl-summary-mark-as-read nil nil t) + (wl-summary-mark-as-read num) (setq wl-summary-buffer-current-msg num) (when wl-summary-recenter (recenter (/ (- (window-height) 2) 2)) @@ -5227,7 +5145,7 @@ If ASK-CODING is non-nil, coding-system for the message is asked." (if (wl-message-redisplay fld num 'all-header (string= (elmo-folder-name-internal fld) wl-draft-folder)) - (wl-summary-mark-as-read nil nil t)) + (wl-summary-mark-as-read num)) (setq wl-summary-buffer-current-msg num) (when wl-summary-recenter (recenter (/ (- (window-height) 2) 2))