X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=wl%2Fwl-summary.el;h=5853eb0e88973b1971f2c8df4d944fbd7a808d6d;hb=2a6b1705041ddafbf36593de88bafd01e7c545fb;hp=adfd0873919516885c8076b8376344a811d10446;hpb=ac20a204df070834ce540f0c5d699b8c120f0ba0;p=elisp%2Fwanderlust.git diff --git a/wl/wl-summary.el b/wl/wl-summary.el index adfd087..5853eb0 100644 --- a/wl/wl-summary.el +++ b/wl/wl-summary.el @@ -75,14 +75,12 @@ (` (and wl-summary-buffer-elmo-folder (elmo-folder-msgdb wl-summary-buffer-elmo-folder)))) -(defvar wl-summary-buffer-folder-indicator nil) (defvar wl-summary-buffer-disp-msg nil) (defvar wl-summary-buffer-disp-folder nil) (defvar wl-summary-buffer-refile-list nil) (defvar wl-summary-buffer-delete-list nil) (defvar wl-summary-buffer-last-displayed-msg nil) (defvar wl-summary-buffer-current-msg nil) -(defvar wl-summary-buffer-unread-status " (0 new/0 unread)") (defvar wl-summary-buffer-unread-count 0) (defvar wl-summary-buffer-new-count 0) (defvar wl-summary-buffer-mime-charset nil) @@ -92,7 +90,11 @@ (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) +(defvar wl-summary-buffer-temp-mark-column nil) +(defvar wl-summary-buffer-persistent-mark-column nil) + (defvar wl-summary-buffer-persistent nil) (defvar wl-summary-buffer-thread-nodes nil) (defvar wl-summary-buffer-target-mark-list nil) @@ -108,6 +110,9 @@ (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) (defvar wl-thread-indent-level-internal nil) (defvar wl-thread-have-younger-brother-str-internal nil) @@ -126,9 +131,6 @@ (defvar wl-summary-get-petname-function 'wl-address-get-petname-1) -(defconst wl-summary-message-regexp "^ *-?[0-9]+" - "Regexp for the message.") - (defvar wl-summary-shell-command-last "") (defvar wl-ps-preprint-hook nil) @@ -142,9 +144,7 @@ (make-variable-buffer-local 'wl-summary-buffer-copy-list) (make-variable-buffer-local 'wl-summary-buffer-target-mark-list) (make-variable-buffer-local 'wl-summary-buffer-delete-list) -(make-variable-buffer-local 'wl-summary-buffer-folder-indicator) (make-variable-buffer-local 'wl-summary-buffer-last-displayed-msg) -(make-variable-buffer-local 'wl-summary-buffer-unread-status) (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-mime-charset) @@ -155,6 +155,8 @@ (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) +(make-variable-buffer-local 'wl-summary-buffer-persistent-mark-column) (make-variable-buffer-local 'wl-summary-buffer-persistent) (make-variable-buffer-local 'wl-summary-buffer-thread-nodes) (make-variable-buffer-local 'wl-summary-buffer-prev-refile-destination) @@ -180,6 +182,9 @@ (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) (defvar wl-datevec) (defvar wl-thr-indent-string) @@ -187,6 +192,8 @@ (defvar wl-thr-linked) (defvar wl-message-entity) (defvar wl-parent-message-entity) +(defvar wl-temp-mark) +(defvar wl-persistent-mark) ;; internal functions (dummy) (unless (fboundp 'wl-summary-append-message-func-internal) @@ -221,7 +228,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) @@ -245,6 +253,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] @@ -272,7 +283,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] @@ -541,6 +553,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))) @@ -548,6 +562,8 @@ (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))) @@ -625,7 +641,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)) @@ -688,14 +704,39 @@ you." (kill-buffer (current-buffer))) (message "Resending message to %s...done" address)))) +(defun wl-summary-detect-mark-position () + (let ((column wl-summary-buffer-number-column) + (formatter wl-summary-buffer-line-formatter) + (dummy-temp (char-to-string 200)) + (dummy-persistent (char-to-string 201)) + temp persistent) + (with-temp-buffer + (setq wl-summary-buffer-number-column column + wl-summary-buffer-line-formatter formatter) + (insert + (wl-summary-create-line + (elmo-msgdb-make-entity + :number 10000 + :from "foo" + :subject "bar" + :size 100) + nil + dummy-temp + dummy-persistent)) + (goto-char (point-min)) + (setq temp (save-excursion + (search-forward dummy-temp nil t) + (current-column)) + persistent (save-excursion + (search-forward dummy-persistent nil t) + (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))) (setq wl-summary-buffer-elmo-folder folder) - (setq wl-summary-buffer-folder-indicator - (if (memq 'modeline wl-use-folder-petname) - (wl-folder-get-petname (elmo-folder-name-internal folder)) - (elmo-folder-name-internal folder))) (make-local-variable 'wl-message-buffer) (setq wl-summary-buffer-mime-charset (or (wl-get-assoc-list-value wl-folder-mime-charset-alist @@ -716,11 +757,17 @@ 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 + wl-summary-mode-line-format + wl-summary-mode-line-format-spec-alist) + (wl-summary-detect-mark-position) (setq wl-summary-buffer-persistent (wl-folder-persistent-p (elmo-folder-name-internal folder))) (elmo-folder-set-persistent-internal folder wl-summary-buffer-persistent) @@ -748,13 +795,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 () @@ -776,13 +816,17 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'." ;;;(make-local-variable 'tab-width) ;;;(setq tab-width 1) (buffer-disable-undo (current-buffer)) - (wl-mode-line-buffer-identification '("Wanderlust: " - wl-summary-buffer-folder-indicator - wl-summary-buffer-unread-status)) + (setq selective-display t + selective-display-ellipses nil) + (wl-mode-line-buffer-identification '(wl-summary-buffer-mode-line)) (easy-menu-add wl-summary-mode-menu) (when wl-summary-lazy-highlight - (make-local-variable 'window-scroll-functions) - (add-hook 'window-scroll-functions 'wl-highlight-summary-window)) + (if wl-on-xemacs + (progn + (make-local-variable 'pre-idle-hook) + (add-hook 'pre-idle-hook 'wl-highlight-summary-window)) + (make-local-variable 'window-scroll-functions) + (add-hook 'window-scroll-functions 'wl-highlight-summary-window))) ;; This hook may contain the function `wl-setup-summary' for reasons ;; of system internal to accord facilities for the Emacs variants. (run-hooks 'wl-summary-mode-hook)) @@ -818,6 +862,49 @@ 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) + (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))))) + (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 list-info-x list-info-y) + (wl-summary-overview-entity-compare-by-date x y) + (if (string= (car list-info-x) (car list-info-y)) + (< (or (cdr list-info-x) 0) + (or (cdr list-info-y) 0)) + (string< (car list-info-x) (car list-info-y)))))) + (defun wl-summary-sort-by-date () (interactive) (wl-summary-rescan "date")) @@ -830,6 +917,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." @@ -871,7 +961,6 @@ 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) @@ -1284,13 +1373,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 @@ -1370,27 +1461,25 @@ If ARG is non-nil, checking is omitted." (message "Collecting marks...") (goto-char (point-min)) (while (not (eobp)) - (beginning-of-line) - (when (looking-at "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9]\\)") - (setq mark (wl-match-buffer 2)) - (setq msg (string-to-int (wl-match-buffer 1))) - (if (or (and (null prefetch-marks) - msg - (null (elmo-file-cache-exists-p - (cdr (assq msg - (elmo-msgdb-get-number-alist - (wl-summary-buffer-msgdb))))))) - (member mark prefetch-marks)) - (setq targets (nconc targets (list msg)))) - (setq entity (wl-thread-get-entity msg)) - (if (or (not (eq wl-summary-buffer-view 'thread)) - (wl-thread-entity-get-opened entity)) - (); opened. no hidden children. - ;; hidden children!! - (setq targets (nconc - targets - (wl-thread-get-children-msgs-uncached - msg prefetch-marks))))) + (setq mark (wl-summary-persistent-mark) + msg (wl-summary-message-number)) + (if (or (and (null prefetch-marks) + msg + (null (elmo-file-cache-exists-p + (elmo-message-field + wl-summary-buffer-elmo-folder + msg + 'message-id)))) + (member mark prefetch-marks)) + (setq targets (nconc targets (list msg)))) + (setq entity (wl-thread-get-entity msg)) + (if (or (not (eq wl-summary-buffer-view 'thread)) + (wl-thread-entity-get-opened entity)) + (); opened. no hidden children. + (setq targets (nconc + targets + (wl-thread-get-children-msgs-uncached + msg prefetch-marks)))) (forward-line 1)) (setq length (length targets)) (message "Prefetching...") @@ -1423,24 +1512,17 @@ If ARG is non-nil, checking is omitted." "Prefetch current message." (interactive "P") (save-excursion - (save-match-data - (beginning-of-line) - (when (looking-at "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9]\\)") - (goto-char (match-beginning 2)) - (let ((inhibit-read-only t) - (buffer-read-only nil) - (beg (match-beginning 2)) - (end (match-end 2)) - mark) - (setq mark (wl-summary-prefetch-msg - (string-to-int (wl-match-buffer 1)) arg)) - (when mark - (delete-region beg end) - (insert mark) - (if wl-summary-highlight - (wl-highlight-summary-current-line))) - (set-buffer-modified-p nil) - mark))))) + (let ((inhibit-read-only t) + (buffer-read-only nil) + (mark (wl-summary-persistent-mark))) + (setq mark (wl-summary-prefetch-msg (wl-summary-message-number) arg)) + (when mark + (delete-backward-char 1) + (insert mark) + (if wl-summary-highlight + (wl-highlight-summary-current-line))) + (set-buffer-modified-p nil) + mark))) (defun wl-summary-delete-marks-on-buffer (marks) (while marks @@ -1467,28 +1549,21 @@ If ARG is non-nil, checking is omitted." (defun wl-summary-delete-all-temp-marks-on-buffer (&optional sticky) ;; for summary view cache saving. - (interactive) (save-excursion (goto-char (point-min)) (let ((inhibit-read-only t) - (buffer-read-only nil) - (case-fold-search nil) - (regexp (concat wl-summary-message-regexp "\\([^ 0-9]\\)" ))) - (while (re-search-forward regexp nil t) - (delete-region (match-beginning 1) (match-end 1)) - (insert " ") - (if (and sticky wl-summary-highlight) - (wl-highlight-summary-current-line)))))) - -;; Does not work correctly... + (buffer-read-only nil)) + (while (not (eobp)) + (unless (string= (wl-summary-temp-mark) " ") + (delete-backward-char 1) + (insert " ")) + (forward-line 1))))) + (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 @@ -1498,17 +1573,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)) @@ -1597,13 +1671,13 @@ If ARG is non-nil, checking is omitted." wl-summary-new-mark))) (save-excursion (goto-char (point-min)) - (while (re-search-forward "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9 ]\\)" - nil t) - (setq msg (string-to-int (wl-match-buffer 1))) - (setq mark (wl-match-buffer 2)) - (when (and (not (string= mark wl-summary-important-mark)) + (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))) - (delete-region (match-beginning 2) (match-end 2)) + (delete-backward-char 1) (if (or (not (elmo-message-use-cache-p folder msg)) (string= mark wl-summary-unread-cached-mark)) (progn @@ -1614,7 +1688,8 @@ If ARG is non-nil, checking is omitted." (elmo-msgdb-set-mark msgdb msg wl-summary-read-uncached-mark)) (if wl-summary-highlight - (wl-highlight-summary-current-line nil nil t))))) + (wl-highlight-summary-current-line nil nil t))) + (forward-line 1))) (elmo-folder-replace-marks folder (list (cons wl-summary-unread-cached-mark @@ -1642,35 +1717,31 @@ If ARG is non-nil, checking is omitted." (number-alist (elmo-msgdb-get-number-alist msgdb)) (case-fold-search nil) mark number unread new-mark) - (beginning-of-line) - (when (looking-at "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9]\\)") - (progn - (setq mark (wl-match-buffer 2)) - (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 (string-to-int (wl-match-buffer 1))) - (delete-region (match-beginning 2) (match-end 2)) - (goto-char (match-beginning 2)) - (insert new-mark) - (elmo-file-cache-delete - (elmo-file-cache-get-path - (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))))))) + (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)) + (delete-backward-char 1) + (insert new-mark) + (elmo-file-cache-delete + (elmo-file-cache-get-path + (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))))) (defun wl-summary-resume-cache-status () "Resume the cache status of all messages in the current folder." @@ -1686,10 +1757,9 @@ If ARG is non-nil, checking is omitted." (message "Resuming cache status...") (save-excursion (goto-char (point-min)) - (while (re-search-forward "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9]\\)" nil t) - (setq msg (string-to-int - (wl-match-buffer 1))) - (setq mark (wl-match-buffer 2)) + (while (not (eobp)) + (setq msg (wl-summary-message-number)) + (setq mark (wl-summary-persistent-mark)) (setq msgid (elmo-msgdb-get-field msgdb msg 'message-id)) (setq set-mark nil) (if (elmo-file-cache-exists-p msgid) @@ -1706,12 +1776,13 @@ If ARG is non-nil, checking is omitted." (setq set-mark wl-summary-unread-uncached-mark) ; ! -> U ))) (when set-mark - (delete-region (match-beginning 2) (match-end 2)) + (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)))) + (wl-highlight-summary-current-line))) + (forward-line 1)) (wl-summary-set-mark-modified) (wl-summary-count-unread) (wl-summary-update-modeline) @@ -1737,10 +1808,9 @@ If ARG is non-nil, checking is omitted." (wl-thread-delete-message (car msgs)))) (setq update-list (delq (car msgs) update-list))) (goto-char (point-min)) - (if (re-search-forward (format "^ *%d[^0-9]\\([^0-9]\\).*$" - (car msgs)) nil t) + (if (wl-summary-jump-to-msg (car msgs)) (progn - (delete-region (match-beginning 0) (match-end 0)) + (delete-region (point-at-bol) (point-at-eol)) (delete-char 1) ; delete '\n' (setq wl-summary-buffer-number-list (delq (car msgs) wl-summary-buffer-number-list))))) @@ -1768,14 +1838,14 @@ If ARG is non-nil, checking is omitted." (save-excursion (goto-char (point-min)) (let ((inhibit-read-only t) - (buffer-read-only nil) - (regexp (concat wl-summary-message-regexp ".\\(\\%s\\)"))) - (while (re-search-forward - (format regexp (regexp-quote before)) nil t) - (delete-region (match-beginning 1) (match-end 1)) - (insert after) - (if wl-summary-highlight - (wl-highlight-summary-current-line)))))) + (buffer-read-only nil)) + (while (not (eobp)) + (when (string= (wl-summary-persistent-mark) before) + (delete-backward-char 1) + (insert after) + (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) @@ -1803,21 +1873,13 @@ If ARG is non-nil, checking is omitted." (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." @@ -1864,7 +1926,7 @@ 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) (setq diffs (cdr diffs))) (setq diffs (car diff)) ; unread-appends (setq mes (concat mes (format "/+%d) unread mark(s)." (length diffs)))) @@ -1986,7 +2048,6 @@ If ARG is non-nil, checking is omitted." (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) (wl-thread-insert-top) (message "Inserting thread...done")) (if elmo-use-database @@ -2058,18 +2119,16 @@ If ARG is non-nil, checking is omitted." (buffer-read-only nil) msg-num cur-mark) - (when (looking-at "^ *\\(-?[0-9]+\\)\\([^0-9]\\)") - (setq msg-num (string-to-int (wl-match-buffer 1))) - (setq cur-mark (wl-match-buffer 2)) - (when (member cur-mark (list " " - wl-summary-score-below-mark - wl-summary-score-over-mark)) - (goto-char (match-end 1)) - (delete-region (match-beginning 2) (match-end 2)) - (insert mark) - (if wl-summary-highlight - (wl-highlight-summary-current-line nil nil t)) - (set-buffer-modified-p nil)))))) + (setq msg-num (wl-summary-message-number)) + (setq cur-mark (wl-summary-temp-mark)) + (when (member cur-mark (list " " + wl-summary-score-below-mark + wl-summary-score-over-mark)) + (delete-backward-char 1) + (insert mark) + (if wl-summary-highlight + (wl-highlight-summary-current-line nil nil t)) + (set-buffer-modified-p nil))))) (defun wl-summary-get-score-mark (msg-num) (let ((score (cdr (assq msg-num wl-summary-scored)))) @@ -2080,23 +2139,19 @@ If ARG is non-nil, checking is omitted." "+"))))) (defun wl-summary-update-modeline () - (setq wl-summary-buffer-unread-status - (format " {%s}(%d new/%d unread)" - (if (eq wl-summary-buffer-view 'thread) - "T" "S") - wl-summary-buffer-new-count - (+ wl-summary-buffer-new-count - wl-summary-buffer-unread-count)))) - -(defsubst wl-summary-jump-to-msg (&optional number) + (setq wl-summary-buffer-mode-line + (funcall wl-summary-buffer-mode-line-formatter))) + +(defun wl-summary-jump-to-msg (&optional number) (interactive) (let ((num (or number (string-to-int (read-from-minibuffer "Jump to Message(No.): "))))) (setq num (int-to-string num)) (beginning-of-line) - (if (or (re-search-forward (concat "^[ \t]*" num "[^0-9]") nil t) - (re-search-backward (concat "^[ \t]*" num "[^0-9]") nil t)) + (if (or (and (re-search-forward (concat "\r" num "[^0-9]") nil t) + (progn (backward-char 1) t)) + (re-search-backward (concat "\r" num "[^0-9]") nil t)) (progn (beginning-of-line) t) nil))) @@ -2121,19 +2176,11 @@ If ARG is non-nil, checking is omitted." (defun wl-summary-message-number () (save-excursion (beginning-of-line) - (if (looking-at "^ *\\(-?[0-9]+\\)") + (if (or (re-search-forward "\r\\(-?[0-9]+\\)" (point-at-eol) t) + (re-search-forward "^ *\\(-?[0-9]+\\)" (point-at-eol) t)) (string-to-int (wl-match-buffer 1)) nil))) -(defun wl-summary-move (src dsts-msgs) - (let* ((dsts (car dsts-msgs)) ; (+foo +bar) -;;; (msgs (cdr dsts-msgs)) ; (1 2 3) -;;; (msgdb (wl-summary-buffer-msgdb)) -;;; result) - ) - (while dsts - (setq dsts (cdr dsts))))) - (defun wl-summary-delete-all-msgs () (interactive) (let ((cur-buf (current-buffer)) @@ -2260,6 +2307,8 @@ If ARG, without confirm." wl-summary-buffer-target-mark-list wl-summary-buffer-elmo-folder wl-summary-buffer-number-column + 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 @@ -2402,7 +2451,7 @@ If ARG, without confirm." default-enable-multibyte-characters) (decode-mime-charset-region (point-min)(point-max) - wl-summary-buffer-mime-charset)) + wl-summary-buffer-mime-charset 'LF)) (when (file-exists-p view) (setq wl-summary-buffer-view (wl-summary-load-file-object view))) @@ -2418,6 +2467,11 @@ If ARG, without confirm." (wl-summary-update-modeline))) (unless (eq wl-summary-buffer-view 'thread) (wl-summary-make-number-list)) + (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) @@ -2507,6 +2561,9 @@ If ARG, without confirm." ;; entity-id is unknown. (wl-folder-set-current-entity-id (wl-folder-get-entity-id entity))) + (when (and wl-summary-lazy-highlight + wl-on-xemacs) + (sit-for 0)) (unwind-protect (run-hooks 'wl-summary-prepared-hook) (set-buffer-modified-p nil)) @@ -2514,7 +2571,7 @@ If ARG, without confirm." (defun wl-summary-goto-previous-message-beginning () (end-of-line) - (re-search-backward wl-summary-message-regexp nil t) + (re-search-backward "\r\\(-?[0-9]+\\)" nil t) (beginning-of-line)) (defun wl-summary-goto-top-of-current-thread () @@ -2557,7 +2614,11 @@ If ARG, without confirm." buffer-read-only) (goto-char (point-max)) (wl-summary-insert-line - (wl-summary-create-line entity nil nil)))) + (wl-summary-create-line entity nil nil + (elmo-msgdb-get-mark + msgdb + (elmo-msgdb-overview-entity-get-number + entity)))))) (defun wl-summary-default-subject-filter (subject) (let ((case-fold-search t)) @@ -2579,6 +2640,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) @@ -2603,6 +2665,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) @@ -2727,8 +2790,8 @@ If ARG, without confirm." (let* ((this-id (elmo-msgdb-overview-entity-get-id entity)) (overview-entity entity) (parent-id (elmo-msgdb-overview-entity-get-id parent-entity)) - (parent-number (elmo-msgdb-overview-entity-get-number parent-entity)) - summary-line msg subject-differ) + (number (elmo-msgdb-overview-entity-get-number entity)) + (parent-number (elmo-msgdb-overview-entity-get-number parent-entity))) (cond ((or (not parent-id) (string= this-id parent-id)) @@ -2744,7 +2807,8 @@ If ARG, without confirm." entity parent-entity nil - (wl-thread-maybe-get-children-num msg) + (elmo-msgdb-get-mark (wl-summary-buffer-msgdb) number) + (wl-thread-maybe-get-children-num number) (wl-thread-make-indent-string thr-entity) (wl-thread-entity-get-linked thr-entity)))))) @@ -2759,7 +2823,7 @@ If ARG, without confirm." (folder wl-summary-buffer-elmo-folder) (msgdb (wl-summary-buffer-msgdb)) ;;; (number-alist (elmo-msgdb-get-number-alist msgdb)) - new-mark visible mark) + new-mark visible mark cur-mark) (if number (progn (setq visible (wl-summary-jump-to-msg number)) @@ -2775,17 +2839,15 @@ If ARG, without confirm." (wl-summary-goto-previous-message-beginning))) (if (or (and (not visible) ;; already exists in msgdb. - (assq number (elmo-msgdb-get-number-alist msgdb))) - (re-search-forward - (format (concat "^ *\\(" - (if number (int-to-string number) - "-?[0-9]+") - "\\)[^0-9]\\(%s\\|%s\\)") - wl-summary-read-uncached-mark - " ") eol t)) + (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 (string-to-int (wl-match-buffer 1)))) - (setq mark (or mark (elmo-match-buffer 2))) + (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) @@ -2799,7 +2861,7 @@ If ARG, without confirm." (unless (elmo-folder-unmark-read folder (list number)) (error "Setting mark failed")))) (when visible - (delete-region (match-beginning 2) (match-end 2)) + (delete-backward-char 1) (insert new-mark)) (elmo-msgdb-set-mark msgdb number new-mark) (unless no-modeline-update @@ -2816,7 +2878,7 @@ If ARG, without confirm." (set-buffer-modified-p nil)) (defun wl-summary-delete (&optional number) - "Mark Delete mark 'D'. + "Mark a delete mark 'D'. If optional argument NUMBER is specified, mark message specified by NUMBER." (interactive) (let* ((buffer-num (wl-summary-message-number)) @@ -2852,7 +2914,8 @@ If optional argument NUMBER is specified, mark message specified by NUMBER." sol eol rs re) (beginning-of-line) (setq sol (point)) - (end-of-line) + (search-forward "\r") + (forward-char -1) (setq eol (point)) (setq rs (next-single-property-change sol 'wl-summary-destination buf eol)) @@ -2900,12 +2963,10 @@ If optional argument NUMBER is specified, mark message specified by NUMBER." (wl-append msglist result))) (forward-line 1))) (elmo-uniq-list msglist)) - (let* ((case-fold-search nil) - (re (format (concat wl-summary-message-regexp "%s") - (regexp-quote mark)))) - (while (re-search-forward re nil t) + (while (not (eobp)) + (when (string= (wl-summary-temp-mark) mark) (setq msglist (cons (wl-summary-message-number) msglist))) - (nreverse msglist))))))) + (forward-line 1))))))) (defun wl-summary-exec () (interactive) @@ -3052,7 +3113,14 @@ If optional argument NUMBER is specified, mark message specified by NUMBER." (or wl-folder-completion-function (if (memq 'read-folder wl-use-folder-petname) (wl-folder-get-entity-with-petname) - wl-folder-entity-hashtb)) + (let (alist) + (mapatoms + (lambda (atom) + (setq alist + (cons (list (elmo-string + (symbol-name atom))) alist))) + wl-folder-entity-hashtb) + alist))) nil nil (or init wl-default-spec) 'wl-read-folder-hist))) (if (or (string= fld wl-default-spec) @@ -3081,7 +3149,10 @@ If optional argument NUMBER is specified, mark message specified by NUMBER." len rs re c) (setq len (string-width folder)) (if (< len 1) () - (end-of-line) + ;;(end-of-line) + (beginning-of-line) + (search-forward "\r") + (forward-char -1) (setq re (point)) (setq c 0) (while (< c len) @@ -3293,15 +3364,13 @@ If optional argument NUMBER is specified, unmark message specified by NUMBER." (setq visible (wl-summary-jump-to-msg number)) (setq visible t)) ;; Delete mark on buffer. - (when (and visible - (looking-at "^ *\\(-?[0-9]+\\)\\([^0-9]\\)")) - (goto-char (match-end 2)) - (or number - (setq number (string-to-int (wl-match-buffer 1)))) - (setq cur-mark (wl-match-buffer 2)) + (when visible + (setq cur-mark (wl-summary-temp-mark)) (if (string= cur-mark " ") () - (delete-region (match-beginning 2) (match-end 2)) + (delete-backward-char 1) + (or number + (setq number (wl-summary-message-number))) (if (setq score-mark (wl-summary-get-score-mark number)) (insert score-mark) (insert " "))) @@ -3311,7 +3380,7 @@ If optional argument NUMBER is specified, unmark message specified by NUMBER." (if wl-summary-highlight (wl-highlight-summary-current-line nil nil score-mark)) (set-buffer-modified-p nil)) - ;; Remove from temporary mark structure. + ;; Remove from temporal mark structure. (and number (wl-summary-delete-mark number))))) @@ -3360,7 +3429,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)) @@ -3467,18 +3536,18 @@ If optional argument NUMBER is specified, mark message specified by NUMBER." (defun wl-summary-delete-all-mark (mark) (goto-char (point-min)) - (let ((case-fold-search nil)) - (while (re-search-forward (format "^ *-?[0-9]+%s" - (regexp-quote mark)) nil t) + (while (not (eobp)) + (when (string= (wl-summary-temp-mark) mark) (wl-summary-unmark)) - (cond ((string= mark "*") - (setq wl-summary-buffer-target-mark-list nil)) - ((string= mark "D") - (setq wl-summary-buffer-delete-list nil)) - ((string= mark "O") - (setq wl-summary-buffer-copy-list nil)) - ((string= mark "o") - (setq wl-summary-buffer-refile-list nil))))) + (forward-line 1)) + (cond ((string= mark "*") + (setq wl-summary-buffer-target-mark-list nil)) + ((string= mark "D") + (setq wl-summary-buffer-delete-list nil)) + ((string= mark "O") + (setq wl-summary-buffer-copy-list nil)) + ((string= mark "o") + (setq wl-summary-buffer-refile-list nil)))) (defun wl-summary-unmark-all () "Unmark all according to what you input." @@ -3573,7 +3642,7 @@ If ARG, exit virtual folder." (message "Unmarking...")) (while (not (eobp)) (wl-summary-unmark) - (forward-line)) + (forward-line 1)) (unless no-msg (message "Unmarking...done")) (setq wl-summary-buffer-target-mark-list nil) @@ -3600,38 +3669,42 @@ If ARG, exit virtual folder." (setq wl-summary-buffer-refile-list (delq pair wl-summary-buffer-refile-list)))))))) +(defsubst wl-summary-temp-mark () + "Move to the temp-mark column and return mark string." + (move-to-column wl-summary-buffer-temp-mark-column) + (buffer-substring (- (point) 1) (point))) + +(defsubst wl-summary-persistent-mark () + "Move to the persistent-mark column and return mark string." + (move-to-column wl-summary-buffer-persistent-mark-column) + (buffer-substring (- (point) 1) (point))) + (defun wl-summary-mark-line (mark) "Put MARK on current line. Return message number." (save-excursion (beginning-of-line) (let ((inhibit-read-only t) - (buffer-read-only nil) - msg-num - cur-mark) - (when (looking-at "^ *\\(-?[0-9]+\\)\\([^0-9]\\)") - (setq msg-num (string-to-int (wl-match-buffer 1))) - (setq cur-mark (wl-match-buffer 2)) - (goto-char (match-end 1)) - (delete-region (match-beginning 2) (match-end 2)) -;;; (wl-summary-delete-mark msg-num) - (insert mark) - (if wl-summary-highlight - (wl-highlight-summary-current-line nil nil t)) - (set-buffer-modified-p nil) - msg-num)))) + (buffer-read-only nil)) + (wl-summary-temp-mark) ; mark + (delete-backward-char 1) + (insert mark) + (if wl-summary-highlight + (wl-highlight-summary-current-line nil nil t)) + (set-buffer-modified-p nil)))) (defun wl-summary-target-mark-delete () (interactive) (save-excursion (goto-char (point-min)) - (let ((regexp (concat wl-summary-message-regexp "\\(\\*\\)")) - number mlist) - (while (re-search-forward regexp nil t) - (let (wl-summary-buffer-disp-msg) - (when (setq number (wl-summary-message-number)) - (wl-summary-delete number) - (setq wl-summary-buffer-target-mark-list - (delq number wl-summary-buffer-target-mark-list))))) + (let (number mlist) + (while (not (eobp)) + (when (string= (wl-summary-temp-mark) "*") + (let (wl-summary-buffer-disp-msg) + (when (setq number (wl-summary-message-number)) + (wl-summary-delete number) + (setq 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-append wl-summary-buffer-delete-list (list (car mlist))) @@ -3659,9 +3732,8 @@ If ARG, exit virtual folder." (when (wl-summary-jump-to-msg (car mlist)) (wl-summary-unmark) (when new-mark - (when (looking-at "^ *-?[0-9]+[^0-9]\\([^0-9]\\)") - (delete-region (match-beginning 1) (match-end 1))) - (goto-char (match-beginning 1)) + (wl-summary-persistent-mark) ; move + (delete-backward-char 1) (insert new-mark) (if wl-summary-highlight (wl-highlight-summary-current-line)) @@ -3679,34 +3751,34 @@ If ARG, exit virtual folder." (intern (format "wl-summary-buffer-%s-list" copy-or-refile))) (function (intern (format "wl-summary-%s" copy-or-refile))) + (numlist wl-summary-buffer-number-list) regexp number msgid entity folder mlist) (save-excursion - (goto-char (point-min)) - (setq regexp (concat wl-summary-message-regexp "\\(\\*\\)")) ;; guess by first mark - (when (re-search-forward regexp nil t) - (setq msgid (cdr (assq (setq number (wl-summary-message-number)) - (elmo-msgdb-get-number-alist - (wl-summary-buffer-msgdb)))) - entity (assoc msgid - (elmo-msgdb-get-overview - (wl-summary-buffer-msgdb)))) + (while numlist + (if (memq (car numlist) wl-summary-buffer-target-mark-list) + (setq number (car numlist) + numlist nil)) + (setq numlist (cdr numlist))) + (when number + (setq msgid (elmo-message-field wl-summary-buffer-elmo-folder + number 'message-id) + entity (elmo-msgdb-overview-get-entity + 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) - (if number - (setq wl-summary-buffer-target-mark-list - (delq number wl-summary-buffer-target-mark-list))) - (while (re-search-forward regexp nil t) - (let (wl-summary-buffer-disp-msg) - (when (setq number (wl-summary-message-number)) - (funcall function folder number) - (setq wl-summary-buffer-target-mark-list - (delq number wl-summary-buffer-target-mark-list))))) + (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) "*") + (let (wl-summary-buffer-disp-msg) + (when (setq number (wl-summary-message-number)) + (funcall function folder number) + (setq wl-summary-buffer-target-mark-list + (delq number wl-summary-buffer-target-mark-list))))) + (forward-line 1)) ;; process invisible messages. (setq mlist wl-summary-buffer-target-mark-list) (while mlist @@ -3751,24 +3823,26 @@ If ARG, exit virtual folder." (interactive) (save-excursion (goto-char (point-min)) - (let ((regexp (concat wl-summary-message-regexp "\\(\\*\\)")) - (inhibit-read-only t) + (let ((inhibit-read-only t) (buffer-read-only nil) + wl-summary-buffer-disp-msg number mlist) - (while (re-search-forward regexp nil t) - (let (wl-summary-buffer-disp-msg) + (while (not (eobp)) + (when (string= (wl-summary-temp-mark) "*") ;; delete target-mark from buffer. - (delete-region (match-beginning 1) (match-end 1)) + (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))) @@ -3779,21 +3853,21 @@ If ARG, exit virtual folder." (interactive) (save-excursion (goto-char (point-min)) - (let ((regexp (concat wl-summary-message-regexp "\\(\\*\\)")) - (inhibit-read-only t) + (let ((inhibit-read-only t) (buffer-read-only nil) + wl-summary-buffer-disp-msg number mlist) - (while (re-search-forward regexp nil t) - (let (wl-summary-buffer-disp-msg) - ;; delete target-mark from buffer. - (delete-region (match-beginning 1) (match-end 1)) + (while (not (eobp)) + (when (string= (wl-summary-temp-mark) "*") + (delete-backward-char 1) (insert " ") (setq number (wl-summary-mark-as-unread)) (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-unread (car mlist)) @@ -3808,21 +3882,22 @@ If ARG, exit virtual folder." (interactive) (save-excursion (goto-char (point-min)) - (let ((regexp (concat wl-summary-message-regexp "\\(\\*\\)")) - (inhibit-read-only t) + (let ((inhibit-read-only t) (buffer-read-only nil) + wl-summary-buffer-disp-msg number mlist) - (while (re-search-forward regexp nil t) - (let (wl-summary-buffer-disp-msg) + (while (not (eobp)) + (when (string= (wl-summary-temp-mark) "*") ;; delete target-mark from buffer. - (delete-region (match-beginning 1) (match-end 1)) + (delete-backward-char 1) (insert " ") (setq number (wl-summary-mark-as-important)) (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-important (car mlist)) @@ -3835,108 +3910,82 @@ If ARG, exit virtual folder." (defun wl-summary-target-mark-save () (interactive) - (save-excursion - (goto-char (point-min)) - (let ((wl-save-dir - (wl-read-directory-name "Save to directory: " - wl-temporary-file-directory)) - (regexp (concat wl-summary-message-regexp "\\(\\*\\)")) - number mlist) - (if (null (file-exists-p wl-save-dir)) - (make-directory wl-save-dir)) - (while (re-search-forward regexp nil t) - (let (wl-summary-buffer-disp-msg) - (setq number (wl-summary-save t wl-save-dir)) - (wl-summary-unmark) - (if number - (setq wl-summary-buffer-target-mark-list - (delq number wl-summary-buffer-target-mark-list)))))))) + (let ((wl-save-dir + (wl-read-directory-name "Save to directory: " + wl-temporary-file-directory)) + number) + (if (null (file-exists-p wl-save-dir)) + (make-directory wl-save-dir)) + (while (setq number (car wl-summary-buffer-target-mark-list)) + (wl-thread-jump-to-msg number) + (wl-summary-save t wl-save-dir) + (wl-summary-unmark number)))) (defun wl-summary-target-mark-pick () (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) (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) - 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) - (looking-at - (format "^ *\\(-?[0-9]+\\)[^0-9]\\(%s\\|%s\\|%s\\|%s\\).*$" - (regexp-quote wl-summary-read-uncached-mark) - (regexp-quote wl-summary-unread-uncached-mark) - (regexp-quote wl-summary-unread-cached-mark) - (regexp-quote wl-summary-new-mark)))) - (progn - (setq mark (or mark (wl-match-buffer 2))) - (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 (string-to-int (wl-match-buffer 1)))) - ;; 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 - (goto-char (match-end 2)) - (delete-region (match-beginning 2) (match-end 2)) - (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."))))) + (let ((buffer-read-only nil) + (folder wl-summary-buffer-elmo-folder) + (msgdb (wl-summary-buffer-msgdb)) + (case-fold-search nil) + cur-mark mark stat visible uncached new-mark marked) + (setq number (or number (wl-summary-message-number)) + visible (if number + (wl-summary-jump-to-msg number) + ;; interactive + t) + mark (elmo-msgdb-get-mark msgdb number)) + (cond + ((string= mark wl-summary-new-mark) ; N + (setq stat 'new)) + ((string= mark wl-summary-unread-uncached-mark) ; U + (setq stat 'unread)) + ((string= mark wl-summary-unread-cached-mark) ; ! + (setq stat 'unread)) + ((string= mark wl-summary-read-uncached-mark) ; u + (setq stat 'read)) + (t + ;; no need to mark server. + (setq no-folder-mark t))) + (setq new-mark + (if (and (if (elmo-message-use-cache-p folder number) + (not (elmo-folder-local-p folder))) + (not (elmo-file-cache-exists-p + (elmo-message-field wl-summary-buffer-elmo-folder + number 'message-id)))) + wl-summary-read-uncached-mark + nil)) + ;; folder mark. + (unless no-folder-mark + (setq marked (elmo-folder-mark-as-read folder (list number)))) + (when (or no-folder-mark marked) + (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 stat + ;; set mark on buffer + (when visible + (unless (string= (wl-summary-persistent-mark) new-mark) + (delete-backward-char 1) + (insert (or new-mark " ")))) + ;; set msgdb mark. + (unless (string= mark 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))) (set-buffer-modified-p nil) (if stat (run-hooks 'wl-summary-unread-message-hook)) @@ -3957,7 +4006,7 @@ If ARG, exit virtual folder." (folder wl-summary-buffer-elmo-folder) (msgdb (wl-summary-buffer-msgdb)) (number-alist (elmo-msgdb-get-number-alist msgdb)) - message-id visible) + message-id visible cur-mark) (if number (progn (setq visible (wl-summary-jump-to-msg number)) @@ -3972,11 +4021,12 @@ If ARG, exit virtual folder." (setq eol (point)) (wl-summary-goto-previous-message-beginning))) (if (or (and (not visible) - (assq number (elmo-msgdb-get-number-alist msgdb))) - (re-search-forward "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9]\\)" eol t)) + ;; already exists in msgdb. + (elmo-msgdb-overview-get-entity number msgdb)) + (setq cur-mark (wl-summary-persistent-mark))) (progn - (setq number (or number (string-to-int (wl-match-buffer 1)))) - (setq mark (or mark (wl-match-buffer 2))) + (setq number (or number (wl-summary-message-number))) + (setq mark (or mark cur-mark)) (setq message-id (elmo-message-field wl-summary-buffer-elmo-folder number @@ -3995,7 +4045,7 @@ If ARG, exit virtual folder." (elmo-file-cache-delete (elmo-file-cache-get-path message-id)))) (when visible - (delete-region (match-beginning 2) (match-end 2)) + (delete-backward-char 1) (insert " ")) (elmo-msgdb-set-mark msgdb number nil)) ;; server side mark @@ -4003,7 +4053,7 @@ If ARG, exit virtual folder." (unless no-server-update (elmo-folder-mark-as-important folder (list number)))) (when visible - (delete-region (match-beginning 2) (match-end 2)) + (delete-backward-char 1) (insert wl-summary-important-mark)) (elmo-msgdb-set-mark msgdb number wl-summary-important-mark) @@ -4023,6 +4073,39 @@ 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) + (number-to-string + (elmo-msgdb-overview-entity-get-number wl-message-entity)))) + (defun wl-summary-line-year () (aref wl-datevec 0)) (defun wl-summary-line-month () @@ -4039,16 +4122,6 @@ If ARG, exit virtual folder." (format "%02d" (aref wl-datevec 3))) (defun wl-summary-line-minute () (format "%02d" (aref wl-datevec 4))) -(defun wl-summary-line-open-bracket () - (if wl-thr-linked "<" "[")) -(defun wl-summary-line-close-bracket () - (if wl-thr-linked ">" "]")) -(defun wl-summary-line-children-number () - (if wl-thr-children-number - (concat "+" (int-to-string wl-thr-children-number) ":") - "")) -(defun wl-summary-line-thread-indent () - (or wl-thr-indent-string "")) (defun wl-summary-line-size () (let ((size (elmo-msgdb-overview-entity-get-size wl-message-entity))) @@ -4061,6 +4134,7 @@ If ARG, exit virtual folder." (t (format "%dB" size))) ""))) +(defvar wl-summary-line-subject-minimum-length nil) (defun wl-summary-line-subject () (let (no-parent subject parent-raw-subject parent-subject) (if (string= wl-thr-indent-string "") @@ -4082,9 +4156,15 @@ If ARG, exit virtual folder." subject parent-subject))) (funcall wl-summary-subject-function subject) "")) + (when (and wl-summary-line-subject-minimum-length + (< (string-width subject) + wl-summary-line-subject-minimum-length)) + (while (< (string-width subject) + wl-summary-line-subject-minimum-length) + (setq subject (concat subject " ")))) (if (and (not wl-summary-width) wl-summary-subject-length-limit) - (truncate-string subject + (truncate-string subject wl-summary-subject-length-limit) subject))) @@ -4094,50 +4174,30 @@ If ARG, exit virtual folder." (elmo-msgdb-overview-entity-get-from wl-message-entity)))) -(defun wl-summary-line-children-and-from () - (concat - (wl-summary-line-children-number) " " - (wl-summary-line-from))) +(defun wl-summary-line-list-info () + (let ((list-info (wl-summary-get-list-info wl-message-entity))) + (if (and (car list-info) (cdr list-info)) + (format "(%s %05d)" (car list-info) (cdr list-info)) + ""))) (defun wl-summary-line-list-count () - (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) - (if (string= folder wl-default-folder) - (format "(%s %05d)" - (car (split-string ml-name " ")) - (string-to-int ml-count)) - (format "#%05d" (string-to-int ml-count))) - "") - (error "")))) + (let ((ml-count (cdr (wl-summary-get-list-info wl-message-entity)))) + (if ml-count + (format "%.0f" ml-count) + ""))) + +(defun wl-summary-line-attached () + (let ((content-type (elmo-msgdb-overview-entity-get-extra-field + wl-message-entity "content-type"))) + (if (and content-type + (string-match "multipart/mixed" content-type)) + "@" + ""))) (defun wl-summary-create-line (wl-message-entity wl-parent-message-entity - temp-mark + wl-temp-mark + wl-persistent-mark &optional wl-thr-children-number wl-thr-indent-string @@ -4161,29 +4221,20 @@ If ARG, exit virtual folder." (setq wl-thr-indent-string (wl-set-string-width wl-summary-indent-length-limit wl-thr-indent-string))) - (setq line - (concat - (format - (concat "%" - (number-to-string wl-summary-buffer-number-column) - "s%s%s") - (number-to-string - (elmo-msgdb-overview-entity-get-number wl-message-entity)) - (or temp-mark " ") - (setq mark - (or (elmo-msgdb-get-mark - (wl-summary-buffer-msgdb) - (elmo-msgdb-overview-entity-get-number - wl-message-entity)) - " "))) - (funcall wl-summary-buffer-line-formatter))) + (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 + (elmo-msgdb-overview-entity-get-number + wl-message-entity)))) (if wl-summary-highlight (wl-highlight-summary-line-string line - mark - temp-mark + wl-persistent-mark + wl-temp-mark wl-thr-indent-string)) line)) @@ -4285,6 +4336,7 @@ If ARG, exit virtual folder." (copy-list (copy-sequence wl-summary-buffer-copy-list)) (delete-list (copy-sequence wl-summary-buffer-delete-list)) (tmp-buffer (get-buffer-create " *wl-summary-save-view-cache*")) + (temp-column wl-summary-buffer-temp-mark-column) (charset wl-summary-buffer-mime-charset)) (if (file-directory-p dir) (); ok. @@ -4293,19 +4345,27 @@ 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) - (wl-summary-delete-all-temp-marks 'no-msg) - (encode-mime-charset-region - (point-min) (point-max) charset) + wl-summary-buffer-delete-list delete-list + wl-summary-buffer-temp-mark-column temp-column) + (wl-summary-delete-all-temp-marks) + (encode-coding-region + (point-min) (point-max) + (or (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) cache nil 'no-msg))) (when (file-writable-p view) ; 'thread or 'sequence @@ -4905,76 +4965,50 @@ Use function list is `wl-summary-write-current-folder-functions'." (if (wl-message-next-page) (wl-summary-down t))))) -(defun wl-summary-prev (&optional interactive) - "" - (interactive) +(defsubst wl-summary-cursor-move-surface (downward interactive) (if wl-summary-move-direction-toggle - (setq wl-summary-move-direction-downward nil)) - (let ((skip-mark-regexp (mapconcat - 'regexp-quote - wl-summary-skip-mark-list "")) - goto-next regex-list regex next-entity finfo) - (beginning-of-line) + (setq wl-summary-move-direction-downward downward)) + (let ((start (point)) + (skip-tmark-regexp (wl-regexp-opt wl-summary-skip-mark-list)) + (skip t) + skip-pmark-regexp goto-next next-entity finfo) (if (elmo-folder-plugged-p wl-summary-buffer-elmo-folder) - (setq regex (format "%s[^%s]" - wl-summary-message-regexp - skip-mark-regexp)) - (setq regex (format "%s[^%s]\\(%s\\|%s\\| \\)" - wl-summary-message-regexp - skip-mark-regexp - (regexp-quote wl-summary-unread-cached-mark) - (regexp-quote wl-summary-important-mark)))) - (unless (re-search-backward regex nil t) - (setq goto-next t)) - (beginning-of-line) - (if (not goto-next) - (progn - (if wl-summary-buffer-disp-msg - (wl-summary-redisplay))) - (if (or interactive (interactive-p)) - (if wl-summary-buffer-prev-folder-function - (funcall wl-summary-buffer-prev-folder-function) - (when wl-auto-select-next - (setq next-entity (wl-summary-get-prev-folder)) - (if next-entity - (setq finfo (wl-folder-get-entity-info next-entity)))) - (wl-ask-folder - '(lambda () (wl-summary-next-folder-or-exit next-entity)) - (format - "No more messages. Type SPC to go to %s." - (wl-summary-entity-info-msg next-entity finfo)))))))) + () + (setq skip-pmark-regexp + (wl-regexp-opt (list " " + wl-summary-unread-cached-mark + wl-summary-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 + (save-excursion + (wl-summary-temp-mark))) + (and skip-pmark-regexp + (not (string-match + skip-pmark-regexp + (save-excursion + (wl-summary-persistent-mark)))))))) + + (if (if downward (eobp) (and (bobp) skip)) (setq goto-next t)) + (if (or (eobp) (and (bobp) skip)) + (goto-char start)) -(defun wl-summary-next (&optional interactive) - "" - (interactive) - (if wl-summary-move-direction-toggle - (setq wl-summary-move-direction-downward t)) - (let ((skip-mark-regexp (mapconcat - 'regexp-quote - wl-summary-skip-mark-list "")) - goto-next regex regex-list next-entity finfo) - (end-of-line) - (if (elmo-folder-plugged-p wl-summary-buffer-elmo-folder) - (setq regex (format "%s[^%s]" - wl-summary-message-regexp - skip-mark-regexp)) - (setq regex (format "%s[^%s]\\(%s\\|%s\\| \\)" - wl-summary-message-regexp - skip-mark-regexp - (regexp-quote wl-summary-unread-cached-mark) - (regexp-quote wl-summary-important-mark)))) - (unless (re-search-forward regex nil t) - (forward-line 1) - (setq goto-next t)) (beginning-of-line) + (if (not goto-next) (if wl-summary-buffer-disp-msg (wl-summary-redisplay)) - (if (or interactive (interactive-p)) + (if interactive (if wl-summary-buffer-next-folder-function (funcall wl-summary-buffer-next-folder-function) (when wl-auto-select-next - (setq next-entity (wl-summary-get-next-folder)) + (setq next-entity + (if downward + (wl-summary-get-next-folder) + (wl-summary-get-prev-folder))) (if next-entity (setq finfo (wl-folder-get-entity-info next-entity)))) (wl-ask-folder @@ -4983,6 +5017,14 @@ Use function list is `wl-summary-write-current-folder-functions'." "No more messages. Type SPC to go to %s." (wl-summary-entity-info-msg next-entity finfo)))))))) +(defun wl-summary-prev (&optional interactive) + (interactive) + (wl-summary-cursor-move-surface nil (or interactive (interactive-p)))) + +(defun wl-summary-next (&optional interactive) + (interactive) + (wl-summary-cursor-move-surface t (or interactive (interactive-p)))) + (defun wl-summary-up (&optional interactive skip-no-unread) "" (interactive) @@ -5113,7 +5155,7 @@ Use function list is `wl-summary-write-current-folder-functions'." (delete-window fld-win))) (setq wl-current-summary-buffer (current-buffer)) (wl-summary-mark-as-read - nil + num ;; not fetched, then change server-mark. (if (wl-message-redisplay folder num 'mime (or force-reload @@ -5128,11 +5170,7 @@ Use function list is `wl-summary-write-current-folder-functions'." wl-summary-buffer-elmo-folder)) (elmo-folder-plugged-p wl-summary-buffer-elmo-folder)) - 'leave)) - t ; displayed - nil - 'cached ; cached by reading. - ) + 'leave))) (setq wl-summary-buffer-current-msg num) (when wl-summary-recenter (recenter (/ (- (window-height) 2) 2)) @@ -5170,7 +5208,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)) @@ -5197,7 +5235,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))