1 ;;; wl-summary.el -- Summary mode for Wanderlust.
3 ;; Copyright 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
5 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
6 ;; Keywords: mail, net news
7 ;; Time-stamp: <00/04/26 14:03:56 teranisi>
9 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
37 (require 'wl-highlight)
53 (condition-case () (require 'timer) (error nil))
57 (unless (boundp symbol)
58 (set (make-local-variable symbol) nil))))
59 '(dragdrop-drop-functions scrollbar-height mail-reply-buffer))
60 (defun-maybe ps-print-buffer-with-faces (a))
61 (defun-maybe elmo-database-msgid-put (a b c))
62 (defun-maybe elmo-database-close ())
63 (defun-maybe elmo-database-msgid-get (a))
64 (defun-maybe run-with-idle-timer (secs repeat function &rest args)))
66 (defvar wl-summary-buffer-name "Summary")
67 (defvar wl-summary-mode-map nil)
68 (defvar wl-current-summary-buffer nil)
70 (defvar wl-summary-buffer-msgdb nil)
71 (defvar wl-summary-buffer-folder-name nil)
72 (defvar wl-summary-buffer-disp-msg nil)
73 (defvar wl-summary-buffer-disp-folder nil)
74 (defvar wl-summary-buffer-refile-list nil)
75 (defvar wl-summary-buffer-delete-list nil)
76 (defvar wl-summary-buffer-last-displayed-msg nil)
77 (defvar wl-summary-buffer-current-msg nil)
78 (defvar wl-summary-buffer-unread-status " (0 new/0 unread)")
79 (defvar wl-summary-buffer-unread-count 0)
80 (defvar wl-summary-buffer-new-count 0)
81 (defvar wl-summary-buffer-mime-charset nil)
82 (defvar wl-summary-buffer-weekday-name-lang nil)
83 (defvar wl-summary-buffer-thread-indent-set-alist nil)
84 (defvar wl-summary-buffer-message-redisplay-func nil)
85 (defvar wl-summary-buffer-view 'thread)
86 (defvar wl-summary-buffer-message-modified nil)
87 (defvar wl-summary-buffer-mark-modified nil)
88 (defvar wl-summary-buffer-number-column nil)
89 (defvar wl-summary-buffer-number-regexp nil)
90 (defvar wl-summary-buffer-persistent nil)
91 (defvar wl-summary-buffer-thread-nodes nil)
92 (defvar wl-summary-buffer-target-mark-list nil)
93 (defvar wl-summary-buffer-copy-list nil)
94 (defvar wl-summary-buffer-prev-refile-destination nil)
95 (defvar wl-summary-buffer-prev-copy-destination nil)
96 (defvar wl-thread-indent-level-internal nil)
97 (defvar wl-thread-have-younger-brother-str-internal nil)
98 (defvar wl-thread-youngest-child-str-internal nil)
99 (defvar wl-thread-vertical-str-internal nil)
100 (defvar wl-thread-horizontal-str-internal nil)
101 (defvar wl-thread-space-str-internal nil)
102 (defvar wl-summary-last-visited-folder nil)
103 (defvar wl-read-folder-hist nil)
104 (defvar wl-summary-scored nil)
105 (defvar wl-crosspost-alist-modified nil)
107 (defvar wl-summary-message-regexp "^ *\\([0-9]+\\)")
109 (defvar wl-summary-shell-command-last "")
111 (defvar wl-ps-preprint-hook nil)
112 (defvar wl-ps-print-hook nil)
115 (function make-variable-buffer-local)
116 (list 'wl-summary-buffer-msgdb
117 'wl-summary-buffer-disp-msg
118 'wl-summary-buffer-disp-folder
119 'wl-summary-buffer-refile-list
120 'wl-summary-buffer-copy-list
121 'wl-summary-buffer-target-mark-list
122 'wl-summary-buffer-delete-list
123 'wl-summary-buffer-folder-name
124 'wl-summary-buffer-last-displayed-msg
125 'wl-summary-buffer-unread-status
126 'wl-summary-buffer-unread-count
127 'wl-summary-buffer-new-count
128 'wl-summary-buffer-mime-charset
129 'wl-summary-buffer-weekday-name-lang
130 'wl-summary-buffer-thread-indent-set
131 'wl-summary-buffer-message-redisplay-func
132 'wl-summary-buffer-view
133 'wl-summary-buffer-message-modified
134 'wl-summary-buffer-mark-modified
135 'wl-summary-buffer-number-column
136 'wl-summary-buffer-number-regexp
137 'wl-summary-buffer-persistent
138 'wl-summary-buffer-thread-nodes
139 'wl-summary-buffer-prev-refile-destination
141 'wl-summary-default-score
142 'wl-summary-move-direction-downward
143 'wl-summary-important-above
144 'wl-summary-temp-above
145 'wl-summary-mark-below
146 'wl-summary-expunge-below
147 'wl-thread-indent-level-internal
148 'wl-thread-have-younger-brother-str-internal
149 'wl-thread-youngest-child-str-internal
150 'wl-thread-vertical-str-internal
151 'wl-thread-horizontal-str-internal
152 'wl-thread-space-str-internal))
154 ;; internal functions (dummy)
155 (unless (fboundp 'wl-summary-append-message-func-internal)
156 (defun wl-summary-append-message-func-internal (entity overview
158 (unless (fboundp 'wl-summary-from-func-internal)
159 (defun wl-summary-from-func-internal (from)
161 (unless (fboundp 'wl-summary-subject-func-internal)
162 (defun wl-summary-subject-func-internal (subject)
164 (unless (fboundp 'wl-summary-subject-filter-func-internal)
165 (defun wl-summary-subject-filter-func-internal (subject)
168 (defmacro wl-summary-sticky-buffer-name (folder)
169 (` (concat wl-summary-buffer-name ":" (, folder))))
171 (defun wl-summary-default-subject (subject-string)
172 (if (string-match "^[ \t]*\\[[^:]+[,: ][0-9]+\\][ \t]*" subject-string)
173 (substring subject-string (match-end 0))
176 (eval-when-compile (defvar-maybe entity nil)) ; silence byte compiler.
177 (defun wl-summary-default-from (from)
180 (and (eq major-mode 'wl-summary-mode)
181 (stringp wl-summary-showto-folder-regexp)
182 (string-match wl-summary-showto-folder-regexp
183 wl-summary-buffer-folder-name)
184 (wl-address-user-mail-address-p from)
186 ((and (setq tos (elmo-msgdb-overview-entity-get-to entity))
187 (not (string= "" tos)))
195 (wl-address-get-petname to)
197 (std11-extract-address-components to))))))
198 (wl-parse-addresses tos)
200 ((setq ng (elmo-msgdb-overview-entity-get-extra-field
201 entity "newsgroups"))
202 (setq retval (concat "Ng:" ng)))))
204 (setq retval (wl-address-get-petname from))
208 (defun wl-summary-simple-from (string)
210 (wl-address-get-petname string)
213 (defvar wl-summary-mode-menu-spec
215 ["Read" wl-summary-read t]
216 ["Prev page" wl-summary-prev-page t]
217 ["Next page" wl-summary-next-page t]
218 ["Top" wl-summary-display-top t]
219 ["Bottom" wl-summary-display-bottom t]
220 ["Prev" wl-summary-prev t]
221 ["Next" wl-summary-next t]
222 ["Up" wl-summary-up t]
223 ["Down" wl-summary-down t]
224 ["Parent message" wl-summary-jump-to-parent-message t]
226 ["Sync" wl-summary-sync t]
227 ["Execute" wl-summary-exec t]
228 ["Go to other folder" wl-summary-goto-folder t]
229 ["Pick" wl-summary-pick t]
230 ["Mark as read all" wl-summary-mark-as-read-all t]
231 ["Unmark all" wl-summary-unmark-all t]
232 ["Toggle display message" wl-summary-toggle-disp-msg t]
233 ["Display folder" wl-summary-toggle-disp-folder t]
234 ["Toggle threading" wl-summary-toggle-thread t]
235 ["Stick" wl-summary-stick t]
237 ["By Number" wl-summary-sort-by-number t]
238 ["By Date" wl-summary-sort-by-date t]
239 ["By From" wl-summary-sort-by-from t]
240 ["By Subject" wl-summary-sort-by-subject t])
243 ["Mark as read" wl-summary-mark-as-read t]
244 ["Mark as important" wl-summary-mark-as-important t]
245 ["Mark as unread" wl-summary-mark-as-unread t]
246 ["Set delete mark" wl-summary-delete t]
247 ["Set refile mark" wl-summary-refile t]
248 ["Set copy mark" wl-summary-copy t]
249 ["Prefetch" wl-summary-prefetch t]
250 ["Set target mark" wl-summary-target-mark t]
251 ["Unmark" wl-summary-unmark t]
252 ["Save" wl-summary-save t]
253 ["Cancel posted news" wl-summary-cancel-message t]
254 ["Supersedes message" wl-summary-supersedes-message t]
255 ["Resend bounced mail" wl-summary-resend-bounced-mail t]
256 ["Resend message" wl-summary-resend-message t]
257 ["Enter the message" wl-summary-jump-to-current-message t]
258 ["Pipe message" wl-summary-pipe-message t]
259 ["Print message" wl-summary-print-message t])
261 ["Open or Close" wl-thread-open-close (eq wl-summary-buffer-view 'thread)]
262 ["Open all" wl-thread-open-all (eq wl-summary-buffer-view 'thread)]
263 ["Close all" wl-thread-close-all (eq wl-summary-buffer-view 'thread)]
264 ["Mark as read" wl-thread-mark-as-read (eq wl-summary-buffer-view 'thread)]
265 ["Mark as important" wl-thread-mark-as-important (eq wl-summary-buffer-view 'thread)]
266 ["Mark as unread" wl-thread-mark-as-unread (eq wl-summary-buffer-view 'thread)]
267 ["Set delete mark" wl-thread-delete (eq wl-summary-buffer-view 'thread)]
268 ["Set refile mark" wl-thread-refile (eq wl-summary-buffer-view 'thread)]
269 ["Set copy mark" wl-thread-copy (eq wl-summary-buffer-view 'thread)]
270 ["Prefetch" wl-thread-prefetch (eq wl-summary-buffer-view 'thread)]
271 ["Set target mark" wl-thread-target-mark (eq wl-summary-buffer-view 'thread)]
272 ["Unmark" wl-thread-unmark (eq wl-summary-buffer-view 'thread)]
273 ["Save" wl-thread-save (eq wl-summary-buffer-view 'thread)]
274 ["Execute" wl-thread-exec (eq wl-summary-buffer-view 'thread)])
276 ["Mark as read" wl-summary-mark-as-read-region t]
277 ["Mark as important" wl-summary-mark-as-important-region t]
278 ["Mark as unread" wl-summary-mark-as-unread-region t]
279 ["Set delete mark" wl-summary-delete-region t]
280 ["Set refile mark" wl-summary-refile-region t]
281 ["Set copy mark" wl-summary-copy-region t]
282 ["Prefetch" wl-summary-prefetch-region t]
283 ["Set target mark" wl-summary-target-mark-region t]
284 ["Unmark" wl-summary-unmark-region t]
285 ["Save" wl-summary-save-region t]
286 ["Execute" wl-summary-exec-region t])
288 ["Mark as read" wl-summary-target-mark-mark-as-read t]
289 ["Mark as important" wl-summary-target-mark-mark-as-important t]
290 ["Mark as unread" wl-summary-target-mark-mark-as-unread t]
291 ["Set delete mark" wl-summary-target-mark-delete t]
292 ["Set refile mark" wl-summary-target-mark-refile t]
293 ["Set copy mark" wl-summary-target-mark-copy t]
294 ["Prefetch" wl-summary-target-mark-prefetch t]
295 ["Save" wl-summary-target-mark-save t]
296 ["Reply with citation" wl-summary-target-mark-reply-with-citation t]
297 ["Forward" wl-summary-target-mark-forward t]
298 ["uudecode" wl-summary-target-mark-uudecode t])
300 ["Switch current score file" wl-score-change-score-file t]
301 ["Edit current score file" wl-score-edit-current-scores t]
302 ["Edit score file" wl-score-edit-file t]
303 ["Set mark below" wl-score-set-mark-below t]
304 ["Set expunge below" wl-score-set-expunge-below t]
305 ["Rescore buffer" wl-summary-rescore t]
306 ["Increase score" wl-summary-increase-score t]
307 ["Lower score" wl-summary-lower-score t])
310 ["Write a message" wl-summary-write t]
311 ["Reply" wl-summary-reply t]
312 ["Reply with citation" wl-summary-reply-with-citation t]
313 ["Forward" wl-summary-forward t])
315 ["Toggle Plug Status" wl-toggle-plugged t]
316 ["Change Plug Status" wl-plugged-change t]
318 ["Exit Current Folder" wl-summary-exit t]))
321 (defun wl-summary-setup-mouse ()
322 (define-key wl-summary-mode-map 'button4 'wl-summary-prev)
323 (define-key wl-summary-mode-map 'button5 'wl-summary-next)
324 (define-key wl-summary-mode-map [(shift button4)]
326 (define-key wl-summary-mode-map [(shift button5)]
328 (define-key wl-summary-mode-map 'button2 'wl-summary-click))
330 (defun wl-summary-setup-mouse ())
331 (defun wl-summary-setup-mouse ()
332 (define-key wl-summary-mode-map [mouse-4] 'wl-summary-prev)
333 (define-key wl-summary-mode-map [mouse-5] 'wl-summary-next)
334 (define-key wl-summary-mode-map [S-mouse-4] 'wl-summary-up)
335 (define-key wl-summary-mode-map [S-mouse-5] 'wl-summary-down)
336 (define-key wl-summary-mode-map [mouse-2] 'wl-summary-click))))
338 (if wl-summary-mode-map
340 (setq wl-summary-mode-map (make-sparse-keymap))
341 (define-key wl-summary-mode-map " " 'wl-summary-read)
342 (define-key wl-summary-mode-map "." 'wl-summary-redisplay)
343 (define-key wl-summary-mode-map "<" 'wl-summary-display-top)
344 (define-key wl-summary-mode-map ">" 'wl-summary-display-bottom)
345 (define-key wl-summary-mode-map "\177" 'wl-summary-prev-page)
347 (define-key wl-summary-mode-map [backspace] 'wl-summary-prev-page))
348 (define-key wl-summary-mode-map "\r" 'wl-summary-next-line-content)
349 (define-key wl-summary-mode-map "\C-m" 'wl-summary-next-line-content)
350 (define-key wl-summary-mode-map "/" 'wl-thread-open-close)
351 (define-key wl-summary-mode-map "[" 'wl-thread-open-all)
352 (define-key wl-summary-mode-map "]" 'wl-thread-close-all)
353 (define-key wl-summary-mode-map "-" 'wl-summary-prev-line-content)
354 (define-key wl-summary-mode-map "\e\r" 'wl-summary-prev-line-content)
355 (define-key wl-summary-mode-map "g" 'wl-summary-goto-folder)
356 (define-key wl-summary-mode-map "c" 'wl-summary-mark-as-read-all)
357 (define-key wl-summary-mode-map "D" 'wl-summary-drop-unsync)
359 (define-key wl-summary-mode-map "a" 'wl-summary-reply)
360 (define-key wl-summary-mode-map "A" 'wl-summary-reply-with-citation)
361 (define-key wl-summary-mode-map "C" 'wl-summary-cancel-message)
362 (define-key wl-summary-mode-map "E" 'wl-summary-reedit)
363 (define-key wl-summary-mode-map "\eE" 'wl-summary-resend-bounced-mail)
364 (define-key wl-summary-mode-map "f" 'wl-summary-forward)
365 (define-key wl-summary-mode-map "$" 'wl-summary-mark-as-important)
366 (define-key wl-summary-mode-map "@" 'wl-summary-edit-addresses)
368 (define-key wl-summary-mode-map "y" 'wl-summary-save)
369 (define-key wl-summary-mode-map "n" 'wl-summary-next)
370 (define-key wl-summary-mode-map "p" 'wl-summary-prev)
371 (define-key wl-summary-mode-map "N" 'wl-summary-down)
372 (define-key wl-summary-mode-map "P" 'wl-summary-up)
373 ; (define-key wl-summary-mode-map "w" 'wl-draft)
374 (define-key wl-summary-mode-map "w" 'wl-summary-write)
375 (define-key wl-summary-mode-map "W" 'wl-summary-write-current-newsgroup)
376 ; (define-key wl-summary-mode-map "e" 'wl-draft-open-file)
377 (define-key wl-summary-mode-map "e" 'wl-summary-save)
378 (define-key wl-summary-mode-map "\C-c\C-o" 'wl-jump-to-draft-buffer)
379 (define-key wl-summary-mode-map "H" 'wl-summary-redisplay-all-header)
380 (define-key wl-summary-mode-map "M" 'wl-summary-redisplay-no-mime)
381 (define-key wl-summary-mode-map "B" 'wl-summary-burst)
382 (define-key wl-summary-mode-map "Z" 'wl-status-update)
383 (define-key wl-summary-mode-map "#" 'wl-summary-print-message)
384 (define-key wl-summary-mode-map "|" 'wl-summary-pipe-message)
385 (define-key wl-summary-mode-map "q" 'wl-summary-exit)
386 (define-key wl-summary-mode-map "Q" 'wl-summary-force-exit)
388 (define-key wl-summary-mode-map "j" 'wl-summary-jump-to-current-message)
389 (define-key wl-summary-mode-map "J" 'wl-thread-jump-to-msg)
390 (define-key wl-summary-mode-map "I" 'wl-summary-incorporate)
391 (define-key wl-summary-mode-map "\M-j" 'wl-summary-jump-to-msg-by-message-id)
392 (define-key wl-summary-mode-map "^" 'wl-summary-jump-to-parent-message)
393 (define-key wl-summary-mode-map "!" 'wl-summary-mark-as-unread)
395 (define-key wl-summary-mode-map "s" 'wl-summary-sync)
396 (define-key wl-summary-mode-map "S" 'wl-summary-sort)
397 (define-key wl-summary-mode-map "\M-s" 'wl-summary-stick)
398 (define-key wl-summary-mode-map "T" 'wl-summary-toggle-thread)
400 (define-key wl-summary-mode-map "l" 'wl-summary-toggle-disp-folder)
401 (define-key wl-summary-mode-map "v" 'wl-summary-toggle-disp-msg)
402 (define-key wl-summary-mode-map "V" 'wl-summary-virtual)
404 (define-key wl-summary-mode-map "\C-i" 'wl-summary-goto-last-displayed-msg)
405 (define-key wl-summary-mode-map "?" 'wl-summary-pick)
406 (define-key wl-summary-mode-map "\ee" 'wl-summary-expire)
409 (define-key wl-summary-mode-map "R" 'wl-summary-mark-as-read)
410 (define-key wl-summary-mode-map "i" 'wl-summary-prefetch)
411 (define-key wl-summary-mode-map "x" 'wl-summary-exec)
412 (define-key wl-summary-mode-map "*" 'wl-summary-target-mark)
413 (define-key wl-summary-mode-map "o" 'wl-summary-refile)
414 (define-key wl-summary-mode-map "O" 'wl-summary-copy)
415 (define-key wl-summary-mode-map "\M-o" 'wl-summary-refile-prev-destination)
416 ; (define-key wl-summary-mode-map "\M-O" 'wl-summary-copy-prev-destination)
417 (define-key wl-summary-mode-map "\C-o" 'wl-summary-auto-refile)
418 (define-key wl-summary-mode-map "d" 'wl-summary-delete)
419 (define-key wl-summary-mode-map "u" 'wl-summary-unmark)
420 (define-key wl-summary-mode-map "U" 'wl-summary-unmark-all)
423 (define-key wl-summary-mode-map "t" (make-sparse-keymap))
424 (define-key wl-summary-mode-map "tR" 'wl-thread-mark-as-read)
425 (define-key wl-summary-mode-map "ti" 'wl-thread-prefetch)
426 (define-key wl-summary-mode-map "tx" 'wl-thread-exec)
427 (define-key wl-summary-mode-map "t*" 'wl-thread-target-mark)
428 (define-key wl-summary-mode-map "to" 'wl-thread-refile)
429 (define-key wl-summary-mode-map "tO" 'wl-thread-copy)
430 (define-key wl-summary-mode-map "td" 'wl-thread-delete)
431 (define-key wl-summary-mode-map "tu" 'wl-thread-unmark)
432 (define-key wl-summary-mode-map "t!" 'wl-thread-mark-as-unread)
433 (define-key wl-summary-mode-map "t$" 'wl-thread-mark-as-important)
434 (define-key wl-summary-mode-map "ty" 'wl-thread-save)
436 ;; target-mark commands
437 (define-key wl-summary-mode-map "m" (make-sparse-keymap))
438 (define-key wl-summary-mode-map "mi" 'wl-summary-target-mark-prefetch)
439 (define-key wl-summary-mode-map "mR" 'wl-summary-target-mark-mark-as-read)
440 (define-key wl-summary-mode-map "mo" 'wl-summary-target-mark-refile)
441 (define-key wl-summary-mode-map "mO" 'wl-summary-target-mark-copy)
442 (define-key wl-summary-mode-map "md" 'wl-summary-target-mark-delete)
443 (define-key wl-summary-mode-map "my" 'wl-summary-target-mark-save)
444 (define-key wl-summary-mode-map "m!" 'wl-summary-target-mark-mark-as-unread)
445 (define-key wl-summary-mode-map "m$" 'wl-summary-target-mark-mark-as-important)
446 (define-key wl-summary-mode-map "mu" 'wl-summary-delete-all-temp-marks)
447 (define-key wl-summary-mode-map "mU" 'wl-summary-target-mark-uudecode)
448 (define-key wl-summary-mode-map "ma" 'wl-summary-target-mark-all)
449 (define-key wl-summary-mode-map "mt" 'wl-summary-target-mark-thread)
450 (define-key wl-summary-mode-map "mA" 'wl-summary-target-mark-reply-with-citation)
451 (define-key wl-summary-mode-map "mf" 'wl-summary-target-mark-forward)
452 (define-key wl-summary-mode-map "m?" 'wl-summary-target-mark-pick)
455 (define-key wl-summary-mode-map "r" (make-sparse-keymap))
456 (define-key wl-summary-mode-map "rR" 'wl-summary-mark-as-read-region)
457 (define-key wl-summary-mode-map "ri" 'wl-summary-prefetch-region)
458 (define-key wl-summary-mode-map "rx" 'wl-summary-exec-region)
459 (define-key wl-summary-mode-map "mr" 'wl-summary-target-mark-region)
460 (define-key wl-summary-mode-map "r*" 'wl-summary-target-mark-region)
461 (define-key wl-summary-mode-map "ro" 'wl-summary-refile-region)
462 (define-key wl-summary-mode-map "rO" 'wl-summary-copy-region)
463 (define-key wl-summary-mode-map "rd" 'wl-summary-delete-region)
464 (define-key wl-summary-mode-map "ru" 'wl-summary-unmark-region)
465 (define-key wl-summary-mode-map "r!" 'wl-summary-mark-as-unread-region)
466 (define-key wl-summary-mode-map "r$" 'wl-summary-mark-as-important-region)
467 (define-key wl-summary-mode-map "ry" 'wl-summary-save-region)
470 (define-key wl-summary-mode-map "K" 'wl-summary-increase-score)
471 (define-key wl-summary-mode-map "L" 'wl-summary-lower-score)
472 (define-key wl-summary-mode-map "h" (make-sparse-keymap))
473 (define-key wl-summary-mode-map "hR" 'wl-summary-rescore)
474 (define-key wl-summary-mode-map "hc" 'wl-score-change-score-file)
475 (define-key wl-summary-mode-map "he" 'wl-score-edit-current-scores)
476 (define-key wl-summary-mode-map "hf" 'wl-score-edit-file)
477 (define-key wl-summary-mode-map "hF" 'wl-score-flush-cache)
478 (define-key wl-summary-mode-map "hm" 'wl-score-set-mark-below)
479 (define-key wl-summary-mode-map "hx" 'wl-score-set-expunge-below)
481 (define-key wl-summary-mode-map "\M-t" 'wl-toggle-plugged)
482 (define-key wl-summary-mode-map "\C-t" 'wl-plugged-change)
484 (wl-summary-setup-mouse)
488 "Menu used in Summary mode."
489 wl-summary-mode-menu-spec))
491 (defun wl-status-update ()
495 (defun wl-summary-display-top ()
497 (goto-char (point-min))
498 (if wl-summary-buffer-disp-msg
499 (wl-summary-redisplay)))
501 (defun wl-summary-display-bottom ()
503 (goto-char (point-max))
505 (if wl-summary-buffer-disp-msg
506 (wl-summary-redisplay)))
508 (defun wl-summary-collect-unread (mark-alist &optional folder)
511 (setq mark (cadr (car mark-alist)))
513 (or (string= mark wl-summary-new-mark)
514 (string= mark wl-summary-unread-uncached-mark)
515 (string= mark wl-summary-unread-cached-mark))
516 (setq ret-val (cons (car (car mark-alist)) ret-val)))
517 (setq mark-alist (cdr mark-alist)))
520 (defun wl-summary-count-unread (mark-alist &optional folder)
525 (setq mark (cadr (car mark-alist)))
528 ((string= mark wl-summary-new-mark)
529 (setq new (+ 1 new)))
530 ((or (string= mark wl-summary-unread-uncached-mark)
531 (string= mark wl-summary-unread-cached-mark))
532 (setq unread (+ 1 unread)))))
533 (setq mark-alist (cdr mark-alist)))
534 (if (eq major-mode 'wl-summary-mode)
535 (setq wl-summary-buffer-new-count new
536 wl-summary-buffer-unread-count unread))
539 (defun wl-summary-make-modeline ()
540 "Create new modeline format for Wanderlust"
541 (let* ((duplicated (copy-sequence mode-line-format))
542 (cur-entry duplicated)
544 (if (memq 'wl-plug-state-indicator mode-line-format)
548 (if (or (and (symbolp (car cur-entry))
549 (eq 'mode-line-buffer-identification
551 (and (consp (car cur-entry))
553 (eq 'modeline-buffer-identification
554 (car (car cur-entry)))
555 (eq 'modeline-buffer-identification
556 (cdr (car cur-entry))))))
558 (setq return-modeline (append return-modeline
560 'wl-plug-state-indicator
562 'wl-summary-buffer-unread-status)
564 (throw 'done return-modeline))
565 (setq return-modeline (append return-modeline
566 (list (car cur-entry)))))
567 (setq cur-entry (cdr cur-entry)))))))
569 (defun wl-summary-reedit (&optional arg)
570 "Re-edit current message.
571 If optional argument is non-nil, Supersedes message"
574 (wl-summary-supersedes-message)
575 (if (string= wl-summary-buffer-folder-name wl-draft-folder)
576 (if (wl-summary-message-number)
578 (wl-draft-reedit (wl-summary-message-number))
579 (if (wl-message-news-p)
580 (mail-position-on-field "Newsgroups")
581 (mail-position-on-field "To"))
582 (delete-other-windows)))
584 (let ((mmelmo-force-fetch-entire-message t))
585 (wl-summary-set-message-buffer-or-redisplay)
586 (set-buffer (wl-message-get-original-buffer))
587 (wl-draft-edit-string (buffer-substring (point-min)
590 (defun wl-summary-resend-bounced-mail ()
591 "Re-mail the current message.
592 This only makes sense if the current message is a bounce message which
593 contains some mail you have written but has been bounced back to
597 (let ((mmelmo-force-fetch-entire-message t))
598 (wl-summary-set-message-buffer-or-redisplay)
599 (set-buffer (wl-message-get-original-buffer))
600 (goto-char (point-min))
601 (let ((case-fold-search nil))
605 (concat "^\\($\\|[Cc]ontent-[Tt]ype:[ \t]+multipart/report\\)") nil t)
607 (re-search-forward "boundary=\"\\([^\"]+\\)\"" nil t))
608 (let ((boundary (buffer-substring (match-beginning 1) (match-end 1)))
611 ((and (setq start (re-search-forward
612 (concat "^--" boundary "\n"
613 "[Cc]ontent-[Tt]ype:[ \t]+"
614 "\\(message/rfc822\\|text/rfc822-headers\\)\n"
615 "\\(.+\n\\)*\n") nil t))
617 (concat "\n\\(--" boundary "\\)--\n") nil t))
618 (wl-draft-edit-string (buffer-substring start (match-beginning 1))))
620 (message "Seems no message/rfc822 part.")))))
621 ((let ((case-fold-search t))
622 (re-search-forward wl-rejected-letter-start nil t))
623 (skip-chars-forward " \t\n")
624 (wl-draft-edit-string (buffer-substring (point) (point-max))))
626 (message "Does not appear to be a rejected letter.")))))))
628 (defun wl-summary-resend-message (address)
629 "Resend the current message to ADDRESS."
630 (interactive "sResend message to: ")
631 (if (or (null address) (string-match "^[ \t]*$" address))
632 (message "No address specified.")
633 (message "Resending message to %s..." address)
635 (let ((mmelmo-force-fetch-entire-message t))
636 (wl-summary-set-message-buffer-or-redisplay)
637 ;; We first set up a normal mail buffer.
638 (set-buffer (get-buffer-create " *wl-draft-resend*"))
639 (buffer-disable-undo (current-buffer))
641 (setq wl-sent-message-via nil)
642 ;; Insert our usual headers.
643 (wl-draft-insert-from-field)
644 (wl-draft-insert-date-field)
645 (insert "to: " address "\n")
646 (goto-char (point-min))
647 ;; Rename them all to "Resent-*".
648 (while (re-search-forward "^[A-Za-z]" nil t)
653 (delete-region (point) (point-max))
655 ;; Insert the message to be resent.
656 (insert-buffer-substring (wl-message-get-original-buffer))
657 (goto-char (point-min))
658 (search-forward "\n\n")
661 (narrow-to-region beg (point))
662 (wl-draft-delete-fields wl-ignored-resent-headers)
663 (goto-char (point-max)))
664 (insert mail-header-separator)
665 ;; Rename all old ("Previous-")Resent headers.
666 (while (re-search-backward "^\\(Previous-\\)*Resent-" beg t)
668 (insert "Previous-"))
669 ;; Quote any "From " lines at the beginning.
671 (when (looking-at "From ")
672 (replace-match "X-From-Line: ")))
674 (wl-draft-dispatch-message)
675 (kill-buffer (current-buffer)))
676 (message "Resending message to %s...done" address))))
678 (defun wl-summary-msgdb-load-async (folder)
679 "Loading msgdb and selecting folder is executed asynchronously in IMAP4.
680 Returns nil if selecting folder was in failure."
681 (if (and (elmo-folder-plugged-p folder)
682 (eq (elmo-folder-get-type folder) 'imap4))
683 (let* ((spec (elmo-folder-get-spec folder))
684 (connection (elmo-imap4-get-connection spec))
685 (process (elmo-imap4-connection-get-process connection))
690 (elmo-imap4-send-command (process-buffer process)
692 (format "select \"%s\""
693 (elmo-imap4-spec-folder
695 (setq msgdb (elmo-msgdb-load (elmo-string folder)))
696 (setq response (elmo-imap4-read-response
697 (process-buffer process)
701 (setcar (cddr connection) nil)
702 (error "Select folder failed"))
703 (setcar (cddr connection) (elmo-imap4-spec-folder spec))))
704 (if response msgdb)))
705 (elmo-msgdb-load (elmo-string folder))))
707 (defun wl-summary-buffer-set-folder (folder)
708 (setq wl-summary-buffer-folder-name folder)
709 (when (wl-summary-sticky-p)
710 (make-local-variable 'wl-message-buf-name)
711 (setq wl-message-buf-name (format "%s:%s" wl-message-buf-name folder)))
712 (setq wl-summary-buffer-mime-charset (or (wl-get-assoc-list-value
713 wl-folder-mime-charset-alist
716 (setq wl-summary-buffer-weekday-name-lang
717 (or (wl-get-assoc-list-value
718 wl-folder-weekday-name-lang-alist
720 wl-summary-weekday-name-lang))
721 (setq wl-summary-buffer-thread-indent-set
722 (wl-get-assoc-list-value
723 wl-folder-thread-indent-set-alist
725 (setq wl-summary-buffer-persistent (wl-folder-persistent-p folder))
727 wl-thread-indent-level-internal
728 (or (nth 0 wl-summary-buffer-thread-indent-set)
729 wl-thread-indent-level)
730 wl-thread-have-younger-brother-str-internal
731 (or (nth 1 wl-summary-buffer-thread-indent-set)
732 wl-thread-have-younger-brother-str)
733 wl-thread-youngest-child-str-internal
734 (or (nth 2 wl-summary-buffer-thread-indent-set)
735 wl-thread-youngest-child-str)
736 wl-thread-vertical-str-internal
737 (or (nth 3 wl-summary-buffer-thread-indent-set)
738 wl-thread-vertical-str)
739 wl-thread-horizontal-str-internal
740 (or (nth 4 wl-summary-buffer-thread-indent-set)
741 wl-thread-horizontal-str)
742 wl-thread-space-str-internal
743 (or (nth 5 wl-summary-buffer-thread-indent-set)
744 wl-thread-space-str))
745 (setq wl-thread-indent-regexp
747 (regexp-quote wl-thread-have-younger-brother-str-internal) "\\|"
748 (regexp-quote wl-thread-youngest-child-str-internal) "\\|"
749 (regexp-quote wl-thread-vertical-str-internal) "\\|"
750 (regexp-quote wl-thread-horizontal-str-internal) "\\|"
751 (regexp-quote wl-thread-space-str-internal)))
752 (run-hooks 'wl-summary-buffer-set-folder-hook))
754 (defun wl-summary-mode ()
755 "Major mode for reading threaded messages.
756 The keys that are defined for this mode are:\\<wl-summary-mode-map>
759 DEL Back-scroll this message.
760 . Force to display this message.
761 RET Make this message scroll up with one line.
762 M-RET - Make this message scroll down with one line.
764 C-n Go to the next line.
765 C-p Go to the previous line.
766 n Move to below then display.
767 N Move to next unread.
768 p Move to above then display.
769 P Move to previous unread.
770 s Sync current folder.
771 t Same as 's' but force update.
772 g Go to the folder which you input.
773 w Write a message. A new draft is prepared.
774 a Answer to this message. A new draft is prepared in Draft mode.
775 f Forward this message to a third person. A new draft is prepared in
776 Draft mode and this message is automatically attached.
777 v Toggle \"Summary and Folder view\".
778 You can quickly put the delete marks since the next message is not
780 i Prefetch message if uncached.
781 o Put the refile mark('o') on this message.
782 ! Mark current message as unread.
783 $ Toggle mark current message as important.
784 d Put the delete mark('D') on this message.
785 c Check all messages as read.
786 * Put the temporal mark('*') on this message.
787 u Cancel the mark on this message.
788 x Process marked messages.
790 mo Put the refile mark onto all messages marked with '*'.
791 This is very convenient to refile all messages picked by '?'.
792 md Put the delete mark onto all messages marked with '*'.
793 mi Prefetch all messages marked with '*'.
794 mu Unmark all target-marked messages.
795 mt Put the '*' mark onto all messages which belong to th current thread.
796 ma Put the '*' mark onto all messages.
797 ? Pick messages according to a pick pattern which you input,
798 then put the '*' mark onto them.
802 (setq major-mode 'wl-summary-mode)
803 (setq mode-name "Summary")
804 (use-local-map wl-summary-mode-map)
805 (setq wl-summary-buffer-refile-list nil)
806 (setq wl-summary-buffer-target-mark-list nil)
807 (setq wl-summary-buffer-delete-list nil)
808 (setq wl-summary-scored nil)
809 (setq wl-summary-buffer-disp-msg nil)
810 ;; (setq default-directory (or wl-tmp-dir (expand-file-name "~/")))
811 (setq buffer-read-only t)
812 (setq truncate-lines t)
813 ; (make-local-variable 'tab-width)
815 (buffer-disable-undo (current-buffer))
817 (setq wl-summary-buffer-message-redisplay-func
818 'wl-mmelmo-message-redisplay)
819 (setq wl-summary-buffer-message-redisplay-func
820 'wl-normal-message-redisplay))
821 (wl-xmas-setup-summary) ; setup toolbar, dnd, etc.
822 (when wl-show-plug-status-on-modeline
823 (setq mode-line-format (wl-summary-make-modeline)))
824 (easy-menu-add wl-summary-mode-menu)
825 (run-hooks 'wl-summary-mode-hook))
827 (defun wl-summary-overview-entity-compare-by-date (x y)
828 "Compare entity by date"
831 (timezone-make-date-sortable
832 (elmo-msgdb-overview-entity-get-date x))
833 (timezone-make-date-sortable
834 (elmo-msgdb-overview-entity-get-date y)))
835 (error))) ;; ignore error.
837 (defun wl-summary-overview-entity-compare-by-number (x y)
838 "Compare entity by number"
840 (elmo-msgdb-overview-entity-get-number x)
841 (elmo-msgdb-overview-entity-get-number y)))
843 (defun wl-summary-overview-entity-compare-by-from (x y)
844 "Compare entity by from"
846 (wl-address-header-extract-address
847 (or (elmo-msgdb-overview-entity-get-from-no-decode x)
848 wl-summary-no-from-message))
849 (wl-address-header-extract-address
850 (or (elmo-msgdb-overview-entity-get-from-no-decode y)
851 wl-summary-no-from-message))))
853 (defun wl-summary-overview-entity-compare-by-subject (x y)
854 "Compare entity by subject"
855 (string< (elmo-msgdb-overview-entity-get-subject-no-decode x)
856 (elmo-msgdb-overview-entity-get-subject-no-decode y)))
858 (defun wl-summary-sort-by-date ()
860 (wl-summary-rescan "date"))
861 (defun wl-summary-sort-by-number ()
863 (wl-summary-rescan "number"))
864 (defun wl-summary-sort-by-subject ()
866 (wl-summary-rescan "subject"))
867 (defun wl-summary-sort-by-from ()
869 (wl-summary-rescan "from"))
871 (defun wl-summary-rescan (&optional sort-by)
872 "Rescan current folder without updating."
874 (let* ((cur-buf (current-buffer))
875 (msgdb wl-summary-buffer-msgdb)
876 (overview (elmo-msgdb-get-overview msgdb))
877 (number-alist (elmo-msgdb-get-number-alist msgdb))
878 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
879 (elmo-mime-charset wl-summary-buffer-mime-charset)
883 (inhibit-read-only t)
884 (buffer-read-only nil)
886 (fset 'wl-summary-append-message-func-internal
887 (wl-summary-get-append-message-func))
889 (message "Re-scanning...")
891 (setq num (length overview))
893 (message "Sorting by %s..." sort-by)
896 (intern (format "wl-summary-overview-entity-compare-by-%s"
898 (message "Sorting by %s...done" sort-by)
899 (elmo-msgdb-set-overview wl-summary-buffer-msgdb
903 (setq wl-thread-entity-hashtb (elmo-make-hash (* (length overview) 2)))
904 (setq wl-thread-entity-list nil)
905 (setq wl-thread-entities nil)
906 (setq wl-summary-buffer-target-mark-list nil)
907 (setq wl-summary-buffer-refile-list nil)
908 (setq wl-summary-buffer-delete-list nil)
909 (message "Constructing summary structure..." percent)
911 (setq entity (car curp))
912 (wl-summary-append-message-func-internal entity overview mark-alist
914 (setq curp (cdr curp))
916 (elmo-display-progress
917 'wl-summary-rescan "Constructing summary structure..."
919 (message "Constructing summary structure...done." percent)
921 (when (eq wl-summary-buffer-view 'thread)
922 (message "Inserting thread...")
923 (wl-thread-insert-top)
924 (message "Inserting thread...done."))
926 (setq wl-summary-scored nil)
927 (wl-summary-score-headers nil msgdb
928 (wl-summary-rescore-msgs number-alist)
930 (setq expunged (wl-summary-score-update-all-lines))
932 (message "%d message(s) are expunged by scoring." (length expunged))))
933 (wl-summary-set-message-modified)
934 (wl-summary-count-unread mark-alist)
935 (wl-summary-update-modeline)
936 (goto-char (point-max))
938 (set-buffer-modified-p nil)))
940 (defun wl-summary-next-folder-or-exit (&optional next-entity upward)
944 (wl-summary-toggle-disp-msg 'off)
947 (wl-summary-goto-folder-subr next-entity
953 (wl-folder-set-current-entity-id (wl-folder-get-entity-id next-entity))
954 (if (and (eq retval 'more-next)
955 (memq wl-auto-select-next '(unread skip-no-unread))
956 (memq this-command wl-summary-next-no-unread-command))
959 t (eq wl-auto-select-next 'skip-no-unread))
960 (goto-char (point-max))
963 t (eq wl-auto-select-next 'skip-no-unread))))))
966 (defun wl-summary-entity-info-msg (entity finfo)
969 (elmo-replace-in-string
970 (if (memq 'ask-folder wl-use-folder-petname)
971 (wl-folder-get-petname entity)
974 (if (null (car finfo))
977 " (%d new/%d unread)"
983 (defun wl-summary-set-message-modified ()
984 (setq wl-summary-buffer-message-modified t))
985 (defun wl-summary-message-modified-p ()
986 wl-summary-buffer-message-modified)
987 (defun wl-summary-set-mark-modified ()
988 (setq wl-summary-buffer-mark-modified t))
989 (defun wl-summary-mark-modified-p ()
990 wl-summary-buffer-mark-modified)
992 (defun wl-summary-msgdb-save ()
993 "Save msgdb if modified."
994 (when wl-summary-buffer-msgdb
997 (when (wl-summary-message-modified-p)
998 (setq path (elmo-msgdb-expand-path wl-summary-buffer-folder-name))
999 (elmo-msgdb-overview-save
1001 (elmo-msgdb-get-overview wl-summary-buffer-msgdb))
1002 (elmo-msgdb-number-save
1004 (elmo-msgdb-get-number-alist wl-summary-buffer-msgdb))
1005 (elmo-folder-set-info-max-by-numdb
1006 (elmo-string wl-summary-buffer-folder-name)
1007 (elmo-msgdb-get-number-alist
1008 wl-summary-buffer-msgdb))
1009 (setq wl-summary-buffer-message-modified nil))
1010 (when (wl-summary-mark-modified-p)
1012 (setq path (elmo-msgdb-expand-path
1013 wl-summary-buffer-folder-name)))
1014 (elmo-msgdb-mark-save
1016 (elmo-msgdb-get-mark-alist wl-summary-buffer-msgdb))
1017 ;; (elmo-folder-set-info-hashtb
1018 ;; (elmo-string wl-summary-buffer-folder-name)
1021 ;; (+ wl-summary-buffer-new-count wl-summary-buffer-unread-count))
1022 ;; (setq wl-folder-info-alist-modified t)
1023 (setq wl-summary-buffer-mark-modified nil))))))
1025 (defsubst wl-summary-cleanup-temp-marks (&optional sticky)
1026 (if (or wl-summary-buffer-refile-list
1027 wl-summary-buffer-copy-list
1028 wl-summary-buffer-delete-list)
1029 (if (y-or-n-p "Marks remain to be executed. Execute them?")
1032 (if (or wl-summary-buffer-refile-list
1033 wl-summary-buffer-copy-list
1034 wl-summary-buffer-delete-list)
1035 (error "Some execution was failed")))
1036 ;; delete temp-marks
1038 (wl-summary-delete-all-refile-marks)
1039 (wl-summary-delete-all-copy-marks)
1040 (wl-summary-delete-all-delete-marks)))
1041 (if wl-summary-buffer-target-mark-list
1043 (wl-summary-delete-all-target-marks)
1044 (setq wl-summary-buffer-target-mark-list nil)))
1045 (wl-summary-delete-all-temp-marks-on-buffer sticky)
1046 (setq wl-summary-scored nil))
1048 ;; a subroutine for wl-summary-exit/wl-save-status
1049 (defun wl-summary-save-status (&optional sticky)
1050 ;; already in summary buffer.
1051 (when wl-summary-buffer-persistent
1052 ;; save the current summary buffer view.
1053 (if (and wl-summary-cache-use
1054 (or (wl-summary-message-modified-p)
1055 (wl-summary-mark-modified-p)))
1056 (wl-summary-save-view-cache sticky))
1058 (wl-summary-msgdb-save)))
1060 (defun wl-summary-force-exit ()
1061 "Exit current summary. Buffer is deleted even the buffer is sticky"
1063 (wl-summary-exit 'force-exit))
1065 (defun wl-summary-exit (&optional force-exit)
1066 "Exit current summary. if FORCE-EXIT, exits even the summary is sticky."
1068 (let ((summary-buf (current-buffer))
1069 (sticky (wl-summary-sticky-p))
1070 (message-buf (get-buffer wl-message-buf-name))
1072 message-buf message-win
1073 folder-buf folder-win)
1074 (wl-summary-cleanup-temp-marks sticky)
1076 ;; save summary status
1078 (wl-summary-save-status sticky)
1079 ;(wl-summary-msgdb-save)
1082 ;; for sticky summary
1083 (wl-delete-all-overlays)
1084 (setq wl-summary-buffer-disp-msg nil)
1085 ;; delete message window if displayed.
1086 (if (setq message-buf (get-buffer wl-message-buf-name))
1087 (if (setq message-win (get-buffer-window message-buf))
1088 (delete-window message-win)))
1089 (if (setq folder-buf (get-buffer wl-folder-buffer-name))
1090 (if (setq folder-win (get-buffer-window folder-buf))
1091 ;; folder win is already displayed.
1092 (select-window folder-win)
1093 ;; folder win is not displayed.
1094 (switch-to-buffer folder-buf))
1095 ;; currently no folder buffer
1097 (and wl-folder-move-cur-folder
1098 wl-folder-buffer-cur-point
1099 (goto-char wl-folder-buffer-cur-point))
1100 (setq wl-folder-buffer-cur-path nil)
1101 (setq wl-folder-buffer-cur-entity-id nil)
1102 (wl-delete-all-overlays)
1103 (if wl-summary-exit-next-move
1104 (wl-folder-next-unsync t)
1105 (beginning-of-line))
1106 (if (setq summary-win (get-buffer-window summary-buf))
1107 (delete-window summary-win))
1111 (set-buffer summary-buf)
1112 (and (get-buffer wl-message-buf-name)
1113 (kill-buffer wl-message-buf-name))
1114 ;; kill buffers of mime-view-caesar
1116 (format "^%s-([0-9 ]+)$" (regexp-quote wl-message-buf-name)))
1117 (kill-buffer summary-buf)))
1118 (run-hooks 'wl-summary-exit-hook))))
1120 (defun wl-summary-sync-force-update (&optional unset-cursor)
1122 (let ((msgdb-dir (elmo-msgdb-expand-path wl-summary-buffer-folder-name))
1126 (setq seen-list (elmo-msgdb-seen-load msgdb-dir))
1127 (setq ret-val (wl-summary-sync-update3 seen-list unset-cursor))
1128 (elmo-msgdb-seen-save msgdb-dir nil))
1129 (set-buffer (current-buffer)))
1131 (message "%s" ret-val))
1134 (defun wl-summary-sync (&optional unset-cursor force-range)
1136 (let* ((folder wl-summary-buffer-folder-name)
1137 (inhibit-read-only t)
1138 (buffer-read-only nil)
1139 (msgdb-dir (elmo-msgdb-expand-path
1141 (range (or force-range (wl-summary-input-range folder)))
1143 (cond ((string= range "all")
1144 ;; initialize buffer local databases.
1145 (unless (elmo-folder-plugged-p folder) ; forbidden
1146 (error "Unplugged"))
1147 (wl-summary-cleanup-temp-marks)
1150 (elmo-msgdb-mark-alist-to-seen-list
1151 (elmo-msgdb-get-number-alist
1152 wl-summary-buffer-msgdb)
1153 (elmo-msgdb-get-mark-alist
1154 wl-summary-buffer-msgdb)
1155 (concat wl-summary-important-mark
1156 wl-summary-read-uncached-mark))
1157 (elmo-msgdb-seen-load msgdb-dir)))
1158 (setq wl-thread-entity-hashtb (elmo-make-hash
1159 (* (length (elmo-msgdb-get-number-alist
1160 wl-summary-buffer-msgdb)) 2)))
1161 (setq wl-summary-buffer-msgdb '(nil nil nil nil))
1162 (setq wl-thread-entity-list nil)
1163 (setq wl-thread-entities nil)
1164 (setq wl-summary-buffer-target-mark-list nil)
1165 (setq wl-summary-buffer-refile-list nil)
1166 (setq wl-summary-buffer-copy-list nil)
1167 (setq wl-summary-buffer-delete-list nil)
1168 (wl-summary-buffer-number-column-detect nil)
1169 (setq mes (wl-summary-sync-update3 seen-list unset-cursor))
1170 (elmo-msgdb-seen-save msgdb-dir nil) ; delete all seen.
1171 (if mes (message "%s" mes)))
1172 ; (wl-summary-sync-all folder t))
1173 ((string= range "rescan")
1174 (let ((msg (wl-summary-message-number)))
1176 (and msg (wl-summary-jump-to-msg msg))))
1177 ((string= range "rescan-noscore")
1178 (let ((msg (wl-summary-message-number))
1181 (and msg (wl-summary-jump-to-msg msg))))
1182 ((or (string-match "last:" range)
1183 (string-match "first:" range))
1184 (wl-summary-goto-folder-subr (concat "/" range "/" folder)
1185 'force-update nil nil t))
1186 ((string= range "no-sync")
1190 (setq seen-list (elmo-msgdb-seen-load msgdb-dir))
1191 (setq mes (wl-summary-sync-update3 seen-list unset-cursor))
1192 (elmo-msgdb-seen-save msgdb-dir nil) ; delete all seen.
1193 (if mes (message "%s" mes))))))
1195 (defvar wl-summary-edit-addresses-candidate-fields
1196 ;; First element becomes default.
1197 '("from" "to" "cc"))
1199 (defun wl-summary-edit-addresses-collect-candidate-fields (mime-charset)
1200 (let ((fields wl-summary-edit-addresses-candidate-fields)
1201 body candidates components)
1204 (mapconcat 'identity (elmo-multiple-field-body (car fields))
1206 (setq body (wl-parse-addresses body))
1207 (if body (setq candidates (append candidates body)))
1208 (setq fields (cdr fields)))
1209 (setq candidates (elmo-uniq-list candidates))
1211 (elmo-set-buffer-multibyte default-enable-multibyte-characters)
1214 (setq components (std11-extract-address-components x))
1215 (cons (nth 1 components)
1216 (and (car components)
1217 (eword-decode-string
1218 (decode-mime-charset-string
1223 (defun wl-summary-edit-addresses-subr (the-email name-in-addr)
1224 ;; returns nil if there's no change.
1225 (if (elmo-get-hash-val (downcase the-email) wl-address-petname-hash)
1227 (message (format "'%s' already exists. (e)dit/(d)elete/(c)ancel?"
1229 (while (not (or (eq (setq char (read-char)) ?\r)
1236 "Please answer `e' or `d' or `c'. (e)dit/(d)elete/(c)ancel?"))
1243 (wl-address-petname-add-or-change
1245 (elmo-get-hash-val the-email wl-address-petname-hash)
1246 (wl-address-header-extract-realname
1247 (cdr (assoc (downcase the-email)
1248 wl-address-completion-list))) t)
1252 (if (y-or-n-p (format "Delete '%s'? "
1255 (wl-address-petname-delete the-email)
1262 (wl-address-petname-add-or-change
1263 the-email name-in-addr name-in-addr)
1266 (defun wl-summary-edit-addresses (&optional addr-str)
1267 "Edit address book interactively.
1268 Optional argument ADDR-STR is used as a target address if specified."
1269 (interactive (if current-prefix-arg
1270 (list (read-from-minibuffer "Target address: "))))
1272 (wl-summary-set-message-buffer-or-redisplay))
1273 (let* ((charset wl-summary-buffer-mime-charset)
1275 (with-current-buffer (wl-message-get-original-buffer)
1276 (wl-summary-edit-addresses-collect-candidate-fields
1278 address pair result)
1280 (setq address addr-str)
1282 (setq address (car (car candidates)))
1285 (format "Target address (%s): " address)
1287 (function (lambda (x) (cons (car x) (car x))))
1289 nil nil nil nil address))))
1291 (setq pair (assoc address candidates))
1293 (setq pair (cons address nil)))
1294 (when (setq result (wl-summary-edit-addresses-subr (car pair) (cdr pair)))
1297 (setq address (assoc (car pair) wl-address-list))
1299 (message "%s, %s, <%s> is %s."
1304 ;; i'd like to update summary-buffer, but...
1305 ;;(wl-summary-rescan)
1306 (run-hooks 'wl-summary-edit-addresses-hook))))
1308 (defun wl-summary-incorporate (&optional arg)
1309 "Check and prefetch all uncached messages.
1310 If optional argument is non-nil, checking is omitted."
1314 (wl-summary-sync-force-update)))
1315 (wl-summary-prefetch-region (point-min) (point-max)
1316 wl-summary-incorporate-marks))
1318 (defun wl-summary-prefetch-msg (number)
1319 "Returns status-mark. if skipped, returns nil."
1320 ;; prefetching procedure.
1322 (let* ((msgdb wl-summary-buffer-msgdb)
1323 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1324 (number-alist (elmo-msgdb-get-number-alist msgdb))
1325 (message-id (cdr (assq number number-alist)))
1326 (ov (assoc message-id
1327 (elmo-msgdb-get-overview msgdb)))
1329 (size (elmo-msgdb-overview-entity-get-size ov))
1330 (inhibit-read-only t)
1331 (buffer-read-only nil)
1332 (force-read (and size
1333 (or (null wl-prefetch-threshold)
1334 (< size wl-prefetch-threshold))))
1338 (when (and size (not force-read) wl-prefetch-confirm)
1344 "Message from %s has %d bytes. Prefetch it?"
1348 (wl-set-string-width
1350 (wl-summary-from-func-internal
1351 (eword-decode-string
1355 (elmo-msgdb-overview-entity-get-from ov)
1358 (message "")); flush.
1359 (setq mark (cadr (assq number mark-alist)))
1363 (if (and (null (elmo-folder-plugged-p
1364 wl-summary-buffer-folder-name))
1365 elmo-enable-disconnected-operation)
1366 (progn ;; append-queue for offline
1367 (elmo-dop-prefetch-msgs
1368 wl-summary-buffer-folder-name (list number))
1372 wl-summary-unread-uncached-mark)
1373 wl-summary-unread-cached-mark)
1374 ((string= mark wl-summary-new-mark)
1375 (setq wl-summary-buffer-new-count
1376 (- wl-summary-buffer-new-count 1))
1377 (setq wl-summary-buffer-unread-count
1378 (+ wl-summary-buffer-unread-count 1))
1379 wl-summary-unread-cached-mark)
1381 (string= mark wl-summary-read-uncached-mark))
1382 (setq wl-summary-buffer-unread-count
1383 (+ wl-summary-buffer-unread-count 1))
1384 wl-summary-unread-cached-mark)
1387 (elmo-prefetch-msg wl-summary-buffer-folder-name
1389 (wl-message-get-original-buffer)
1394 wl-summary-unread-uncached-mark)
1395 wl-summary-unread-cached-mark)
1396 ((string= mark wl-summary-new-mark)
1397 (setq wl-summary-buffer-new-count
1398 (- wl-summary-buffer-new-count 1))
1399 (setq wl-summary-buffer-unread-count
1400 (+ wl-summary-buffer-unread-count 1))
1401 wl-summary-unread-cached-mark)
1402 ((string= mark wl-summary-read-uncached-mark)
1405 (setq mark-alist (elmo-msgdb-mark-set
1406 mark-alist number new-mark))
1407 (or new-mark (setq new-mark " "))
1408 (elmo-msgdb-set-mark-alist msgdb mark-alist)
1409 (wl-summary-set-mark-modified)
1410 (wl-summary-update-modeline)
1411 (wl-folder-update-unread
1412 wl-summary-buffer-folder-name
1413 (+ wl-summary-buffer-unread-count
1414 wl-summary-buffer-new-count)))
1417 ;(defvar wl-summary-message-uncached-marks
1418 ; (list wl-summary-new-mark
1419 ; wl-summary-unread-uncached-mark
1420 ; wl-summary-read-uncached-mark))
1422 (defun wl-summary-prefetch-region (beg end &optional prefetch-marks)
1430 (setq start-pos (point))
1432 (narrow-to-region beg end)
1433 ;; collect prefetch targets.
1434 (message "Collecting marks...")
1435 (goto-char (point-min))
1438 (when (looking-at "^ *\\([0-9]+\\)[^0-9]\\([^0-9]\\)")
1439 (setq mark (wl-match-buffer 2))
1440 (setq msg (string-to-int (wl-match-buffer 1)))
1441 (if (or (and (null prefetch-marks)
1443 (null (elmo-cache-exists-p
1445 (elmo-msgdb-get-number-alist
1446 wl-summary-buffer-msgdb))))))
1447 (member mark prefetch-marks))
1448 (setq targets (nconc targets (list msg))))
1449 (setq entity (wl-thread-get-entity msg))
1450 (if (or (not (eq wl-summary-buffer-view 'thread))
1451 (wl-thread-entity-get-opened entity))
1452 (); opened. no hidden children.
1453 ;; hidden children!!
1454 (setq targets (nconc
1456 (wl-thread-get-children-msgs-uncached
1457 msg prefetch-marks)))))
1459 (setq length (length targets))
1460 (message "Prefetching...")
1462 (setq mark (if (not (wl-thread-entity-parent-invisible-p
1463 (wl-thread-get-entity (car targets))))
1465 (wl-summary-jump-to-msg (car targets))
1466 (wl-summary-prefetch))
1467 (wl-summary-prefetch-msg (car targets))))
1468 (if (if prefetch-marks
1469 (string= mark wl-summary-unread-cached-mark)
1470 (or (string= mark wl-summary-unread-cached-mark)
1471 (string= mark " ")))
1472 (message "Prefetching... %d/%d message(s)"
1473 (setq count (+ 1 count)) length))
1477 (goto-char start-pos)
1478 (if (pos-visible-in-window-p pos)
1482 (setq targets (cdr targets)))
1483 (message "Prefetched %d/%d message(s)" count length)
1484 (cons count length)))))
1486 (defun wl-summary-prefetch ()
1487 "Prefetch current message."
1492 (when (looking-at "^ *\\([0-9]+\\)[^0-9]\\([^0-9]\\)")
1493 (goto-char (match-beginning 2))
1494 (let ((inhibit-read-only t)
1495 (buffer-read-only nil)
1497 (setq mark (wl-summary-prefetch-msg
1498 (string-to-int (wl-match-buffer 1))))
1500 (delete-region (match-beginning 2)
1503 (if wl-summary-highlight
1504 (wl-highlight-summary-current-line)))
1505 (set-buffer-modified-p nil)
1508 (defun wl-summary-delete-all-status-marks-on-buffer ()
1511 (goto-char (point-min))
1512 (let ((inhibit-read-only t)
1513 (buffer-read-only nil)
1514 (case-fold-search nil))
1515 (while (re-search-forward
1516 (concat "^" wl-summary-buffer-number-regexp ".\\(.\\)") nil t)
1517 (delete-region (match-beginning 1) (match-end 1))
1520 (defun wl-summary-delete-copy-marks-on-buffer (cpys)
1523 (wl-summary-unmark x)))
1526 (defun wl-summary-delete-all-refile-marks ()
1529 (wl-summary-unmark (car x)))) wl-summary-buffer-refile-list))
1531 (defun wl-summary-delete-all-copy-marks ()
1534 (wl-summary-unmark (car x)))) wl-summary-buffer-copy-list))
1536 (defun wl-summary-delete-all-delete-marks ()
1537 (mapcar 'wl-summary-unmark wl-summary-buffer-delete-list))
1539 (defun wl-summary-delete-all-target-marks ()
1540 (mapcar 'wl-summary-unmark wl-summary-buffer-target-mark-list))
1542 (defun wl-summary-delete-all-temp-marks-on-buffer (&optional sticky)
1543 ;; for summary view cache saving.
1546 (goto-char (point-min))
1547 (let ((inhibit-read-only t)
1548 (buffer-read-only nil)
1549 (case-fold-search nil)
1550 (regexp (concat "^" wl-summary-buffer-number-regexp "\\([^ ]\\)" )))
1551 (while (re-search-forward regexp nil t)
1552 (delete-region (match-beginning 1) (match-end 1))
1554 (if (and sticky wl-summary-highlight)
1555 (wl-highlight-summary-current-line))))))
1557 (defun wl-summary-delete-all-marks (mark-alist mark)
1558 "Delete all MARKs in MARK-ALIST"
1559 (let ((malist mark-alist)
1560 (ret-val mark-alist)
1563 (setq entity (car malist))
1564 (if (string= (cadr entity) mark)
1565 ;; delete this entity
1566 (setq ret-val (delete entity ret-val)))
1567 (setq malist (cdr malist)))
1570 ;; Does not work correctly...
1571 (defun wl-summary-mark-as-read-region (beg end)
1575 (narrow-to-region beg end);(save-excursion (goto-char end)
1576 ; (end-of-line) (point)))
1577 (goto-char (point-min))
1578 (if (eq wl-summary-buffer-view 'thread)
1581 (let* ((number (wl-summary-message-number))
1582 (entity (wl-thread-get-entity number))
1584 (if (wl-thread-entity-get-opened entity)
1585 ;; opened...mark line.
1586 ;; Crossposts are not processed
1587 (wl-summary-mark-as-read t)
1589 (wl-summary-mark-as-read t) ; mark itself.
1590 (setq children (wl-thread-get-children-msgs number))
1592 (wl-thread-msg-mark-as-read (car children))
1593 (setq children (cdr children))))
1596 (wl-summary-mark-as-read t)
1597 (forward-line 1)))))
1598 (wl-summary-count-unread (elmo-msgdb-get-mark-alist wl-summary-buffer-msgdb))
1599 (wl-summary-update-modeline))
1601 (defun wl-summary-mark-as-unread-region (beg end)
1605 (narrow-to-region beg end);(save-excursion (goto-char end)
1606 ; (end-of-line) (point)))
1607 (goto-char (point-min))
1608 (if (eq wl-summary-buffer-view 'thread)
1611 (let* ((number (wl-summary-message-number))
1612 (entity (wl-thread-get-entity number))
1614 (if (wl-thread-entity-get-opened entity)
1615 ;; opened...mark line.
1616 ;; Crossposts are not processed
1617 (wl-summary-mark-as-unread)
1619 (wl-summary-mark-as-unread) ; mark itself.
1621 (delq number (wl-thread-get-children-msgs number)))
1623 (wl-thread-msg-mark-as-unread (car children))
1624 (setq children (cdr children))))
1627 (wl-summary-mark-as-unread)
1628 (forward-line 1)))))
1629 (wl-summary-count-unread (elmo-msgdb-get-mark-alist wl-summary-buffer-msgdb))
1630 (wl-summary-update-modeline))
1632 (defun wl-summary-mark-as-important-region (beg end)
1636 (narrow-to-region beg end);(save-excursion (goto-char end)
1637 ; (end-of-line) (point)))
1638 (goto-char (point-min))
1639 (if (eq wl-summary-buffer-view 'thread)
1642 (let* ((number (wl-summary-message-number))
1643 (entity (wl-thread-get-entity number))
1645 (if (wl-thread-entity-get-opened entity)
1646 ;; opened...mark line.
1647 ;; Crossposts are not processed
1648 (wl-summary-mark-as-important)
1650 (wl-summary-mark-as-important) ; mark itself.
1652 (delq number (wl-thread-get-children-msgs number)))
1654 (wl-thread-msg-mark-as-important (car children))
1655 (setq children (cdr children))))
1658 (wl-summary-mark-as-important)
1659 (forward-line 1)))))
1660 (wl-summary-count-unread (elmo-msgdb-get-mark-alist wl-summary-buffer-msgdb))
1661 (wl-summary-update-modeline))
1663 (defun wl-summary-mark-as-read-all ()
1665 (if (or (not (interactive-p))
1666 (y-or-n-p "Mark all messages as read?"))
1667 (let* ((folder wl-summary-buffer-folder-name)
1668 (cur-buf (current-buffer))
1669 (msgdb wl-summary-buffer-msgdb)
1670 ;;(number-alist (elmo-msgdb-get-number-alist msgdb))
1671 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1673 (inhibit-read-only t)
1674 (buffer-read-only nil)
1675 (case-fold-search nil)
1677 (message "Setting all msgs as read...")
1678 (elmo-mark-as-read folder (wl-summary-collect-unread mark-alist)
1681 (goto-char (point-min))
1682 (while (re-search-forward "^ *\\([0-9]+\\)[^0-9]\\([^0-9 ]\\)" nil t)
1683 (setq msg (string-to-int (wl-match-buffer 1)))
1684 (setq mark (wl-match-buffer 2))
1685 (when (and (not (string= mark wl-summary-important-mark))
1686 (not (string= mark wl-summary-read-uncached-mark)))
1687 (delete-region (match-beginning 2) (match-end 2))
1688 (if (or (not (elmo-use-cache-p folder msg))
1689 (string= mark wl-summary-unread-cached-mark))
1693 (elmo-msgdb-mark-set
1695 msg ;(cdr (assq msg number-alist))
1697 ;; New mark and unread-uncached mark
1698 (insert wl-summary-read-uncached-mark)
1700 (elmo-msgdb-mark-set mark-alist
1702 ; (cdr (assq msg number-alist))
1703 wl-summary-read-uncached-mark)))
1704 (if wl-summary-highlight
1705 (wl-highlight-summary-current-line nil nil t)))))
1706 (setq mark-alist (wl-summary-set-as-read-mark-alist mark-alist))
1707 (wl-summary-set-mark-modified)
1708 (set-buffer cur-buf); why is this needed???
1709 (elmo-msgdb-set-mark-alist msgdb mark-alist)
1710 (wl-folder-update-unread wl-summary-buffer-folder-name 0)
1711 (setq wl-summary-buffer-unread-count 0)
1712 (setq wl-summary-buffer-new-count 0)
1713 (wl-summary-update-modeline)
1714 (message "Setting all msgs as read...done.")
1715 (set-buffer-modified-p nil))))
1717 (defun wl-summary-delete-cache ()
1718 "Delete cache of current message."
1721 (let* ((inhibit-read-only t)
1722 (buffer-read-only nil)
1723 (folder wl-summary-buffer-folder-name)
1724 (msgdb wl-summary-buffer-msgdb)
1725 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1726 (number-alist (elmo-msgdb-get-number-alist msgdb))
1727 (case-fold-search nil)
1728 mark number unread new-mark)
1729 ; (re-search-backward "^ *[0-9]+..[0-9]+/[0-9]+" nil t) ; set cursor line
1731 (when (looking-at "^ *\\([0-9]+\\)[^0-9]\\([^0-9]\\)")
1733 (setq mark (wl-match-buffer 2))
1735 ((or (string= mark wl-summary-new-mark)
1736 (string= mark wl-summary-unread-uncached-mark)
1737 (string= mark wl-summary-important-mark))
1740 ((string= mark wl-summary-unread-cached-mark)
1741 (setq new-mark wl-summary-unread-uncached-mark))
1743 (setq new-mark wl-summary-read-uncached-mark)))
1745 (setq number (string-to-int (wl-match-buffer 1)))
1746 (delete-region (match-beginning 2) (match-end 2))
1747 (goto-char (match-beginning 2))
1749 (elmo-cache-delete (cdr (assq number number-alist))
1750 wl-summary-buffer-folder-name
1753 (elmo-msgdb-mark-set mark-alist number new-mark))
1754 (elmo-msgdb-set-mark-alist msgdb mark-alist)
1755 (wl-summary-set-mark-modified)
1756 (if wl-summary-highlight
1757 (wl-highlight-summary-current-line nil nil t))
1758 (set-buffer-modified-p nil)))))))
1760 (defun wl-summary-resume-cache-status ()
1761 "Resume the cache status of all messages in the current folder."
1763 (let* ((folder wl-summary-buffer-folder-name)
1764 (cur-buf (current-buffer))
1765 (msgdb wl-summary-buffer-msgdb)
1766 (number-alist (elmo-msgdb-get-number-alist msgdb))
1767 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1768 (inhibit-read-only t)
1769 (buffer-read-only nil)
1770 (case-fold-search nil)
1771 msg mark msgid set-mark)
1772 (message "Resuming cache status...")
1774 (goto-char (point-min))
1775 (while (re-search-forward "^ *\\([0-9]+\\)[^0-9]\\([^0-9]\\)" nil t)
1776 (setq msg (string-to-int
1777 (wl-match-buffer 1)))
1778 (setq mark (wl-match-buffer 2))
1779 (setq msgid (cdr (assq msg number-alist)))
1781 (if (elmo-cache-exists-p msgid folder msg)
1783 (string= mark wl-summary-unread-uncached-mark) ; U -> !
1784 (string= mark wl-summary-new-mark) ; N -> !
1786 (setq set-mark wl-summary-unread-cached-mark)
1787 (if (string= mark wl-summary-read-uncached-mark) ; u -> ' '
1788 (setq set-mark " ")))
1789 (if (string= mark " ")
1790 (setq set-mark wl-summary-read-uncached-mark) ;' ' -> u
1791 (if (string= mark wl-summary-unread-cached-mark)
1792 (setq set-mark wl-summary-unread-uncached-mark) ; ! -> U
1795 (delete-region (match-beginning 2) (match-end 2))
1798 (elmo-msgdb-mark-set
1799 mark-alist msg ; msgid
1800 (if (string= set-mark " ") nil set-mark)))
1801 (if wl-summary-highlight
1802 (wl-highlight-summary-current-line))))
1803 (wl-summary-set-mark-modified)
1804 (set-buffer cur-buf); why is this needed???
1805 (elmo-msgdb-set-mark-alist msgdb mark-alist)
1806 (wl-summary-count-unread mark-alist)
1807 (wl-summary-update-modeline)
1808 (message "Resuming cache status...done.")
1809 (set-buffer-modified-p nil))))
1811 (defun wl-summary-resume-marks-and-highlight ()
1812 (let* ((msgdb wl-summary-buffer-msgdb)
1813 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1814 ;;(number-alist (elmo-msgdb-get-number-alist msgdb))
1815 (count (count-lines (point-min)(point-max)))
1817 msg-num percent smark)
1819 (goto-char (point-min))
1820 (message "Resuming all marks...")
1822 (setq msg-num (wl-summary-message-number))
1823 (setq smark (car (cdr (assq msg-num mark-alist))))
1824 (if (looking-at (format "^ *%s \\( \\)" msg-num))
1826 (goto-char (match-end 1))
1827 (delete-region (match-beginning 1) (match-end 1))
1828 (insert (or smark " "))))
1829 (wl-highlight-summary-current-line smark)
1831 (setq percent (/ (* i 100) count))
1832 (elmo-display-progress
1833 'wl-summary-resume-marks-and-highlight "Resuming all marks..."
1836 (message "Resuming all marks...done.")))
1838 (defun wl-summary-resume-marks ()
1839 (let* ((msgdb wl-summary-buffer-msgdb)
1840 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1841 (number-alist (elmo-msgdb-get-number-alist msgdb))
1842 (count (length mark-alist))
1844 entity msg-num percent)
1846 (message "Resuming all marks...")
1848 (setq entity (car mark-alist))
1849 (if (setq msg-num (car (rassoc (car entity) number-alist)))
1850 (progn ;(goto-char (point-min))
1851 (if (re-search-forward (format "^ *%s \\( \\)" msg-num) nil t)
1853 (delete-region (match-beginning 1) (match-end 1))
1854 (insert (or (cadr entity)
1856 (if (re-search-backward (format "^ *%s \\( \\)" msg-num) nil t)
1858 (goto-char (match-end 1))
1859 (delete-region (match-beginning 1) (match-end 1))
1860 (insert (or (cadr entity)
1863 (setq percent (/ (* i 100) count))
1864 (elmo-display-progress
1865 'wl-summary-resume-marks "Resuming all marks..."
1867 (setq mark-alist (cdr mark-alist)))
1868 (message "Resuming all marks...done."))))
1870 (defun wl-summary-delete-messages-on-buffer (msgs &optional deleting-info)
1873 (let ((inhibit-read-only t)
1874 (buffer-read-only nil)
1880 (if (eq wl-summary-buffer-view 'thread)
1883 (wl-append update-list
1884 (wl-thread-delete-message (car msgs))))
1885 (setq update-list (and update-list
1886 (delete (car msgs) update-list))))
1887 (goto-char (point-min))
1888 (if (re-search-forward (format "^ *%d[^0-9]\\([^0-9]\\).*$"
1891 (delete-region (match-beginning 0) (match-end 0))
1892 (delete-char 1) ; delete '\n'
1896 (and (zerop (% i 10))
1897 (elmo-display-progress
1898 'wl-summary-delete-messages-on-buffer "Deleting..."
1899 (/ (* i 100) len))))
1900 (setq msgs (cdr msgs)))
1901 (if (eq wl-summary-buffer-view 'thread)
1902 (wl-thread-update-line-msgs (elmo-uniq-list update-list)))
1903 (wl-thread-cleanup-symbols msgs2)
1904 (wl-summary-count-unread
1905 (elmo-msgdb-get-mark-alist wl-summary-buffer-msgdb))
1906 (wl-summary-update-modeline)
1907 (wl-folder-update-unread
1908 wl-summary-buffer-folder-name
1909 (+ wl-summary-buffer-unread-count wl-summary-buffer-new-count)))))
1911 (defun wl-summary-set-as-read-mark-alist (mark-alist)
1912 (let ((marks (list (cons wl-summary-unread-cached-mark
1914 (cons wl-summary-unread-uncached-mark
1915 wl-summary-read-uncached-mark)
1916 (cons wl-summary-new-mark
1917 wl-summary-read-uncached-mark)))
1918 (ret-val mark-alist)
1921 (setq entity (car mark-alist))
1922 (when (setq pair (assoc (cadr entity) marks))
1923 (if (elmo-use-cache-p wl-summary-buffer-folder-name
1926 (setcar (cdr entity) (cdr pair))
1927 (setq ret-val (delete entity ret-val)))
1928 (setq ret-val (delete entity ret-val))))
1929 (setq mark-alist (cdr mark-alist)))
1932 (defun wl-summary-set-status-marks (mark-alist before after)
1933 "Set the BEFORE marks to AFTER"
1934 (let ((ret-val mark-alist)
1937 (setq entity (car mark-alist))
1938 (when (string= (cadr entity) before)
1940 (setcar (cdr entity) after)
1941 (setq ret-val (delete entity ret-val))))
1942 (setq mark-alist (cdr mark-alist)))
1945 (defun wl-summary-set-status-marks-on-buffer (before after)
1946 "Set the MARKS marks on buffer"
1949 (goto-char (point-min))
1950 (let ((inhibit-read-only t)
1951 (buffer-read-only nil)
1952 (regexp (concat "^" wl-summary-buffer-number-regexp ".\\(\\%s\\)")))
1953 (while (re-search-forward
1954 (format regexp (regexp-quote before)) nil t)
1955 (delete-region (match-beginning 1) (match-end 1))
1957 (if wl-summary-highlight
1958 (wl-highlight-summary-current-line))))))
1960 (defun wl-summary-get-delete-folder (folder)
1961 (if (string= folder wl-trash-folder)
1963 (let* ((type (or (wl-get-assoc-list-value wl-delete-folder-alist folder)
1965 (cond ((stringp type)
1967 ((or (equal type 'remove) (equal type 'null))
1969 (t;; (equal type 'trash)
1970 wl-trash-folder)))))
1972 (defun wl-summary-delete-important-msgs-from-list (delete-list
1974 (let ((dlist delete-list))
1976 (if (string= wl-summary-important-mark
1977 (car (cdr (assq (car dlist) mark-alist))))
1978 (setq delete-list (delete (car dlist) delete-list)))
1979 (setq dlist (cdr dlist)))
1982 (defun wl-summary-delete-canceled-msgs-from-list (delete-list msgdb)
1983 (let ((dlist delete-list))
1985 (if (null (cdr (assq (car dlist) (cadr msgdb))))
1986 (setq delete-list (delete (car dlist) delete-list)))
1987 (setq dlist (cdr dlist)))
1990 (defun wl-summary-get-append-message-func ()
1991 (if (eq wl-summary-buffer-view 'thread)
1992 'wl-summary-insert-thread-entity
1993 ; 'wl-summary-insert-thread
1994 'wl-summary-insert-summary))
1996 (defun wl-summary-sort ()
1998 (let ((sort-by (let ((input-range-list '("number" "date" "subject" "from"))
2003 (format "Sort by (%s): " default)
2005 (function (lambda (x) (cons x x)))
2010 (if (not (member sort-by '("number" "date" "subject" "from")))
2011 (error "Sort by %s is not implemented" sort-by))
2012 (wl-summary-rescan sort-by)))
2014 (defun wl-summary-sync-marks ()
2015 "Update marks in summary."
2017 (let ((plugged (elmo-folder-plugged-p wl-summary-buffer-folder-name))
2019 mark-alist unread-marks msgs mark importants unreads
2020 importants-in-db unreads-in-db has-imap4 diff diffs
2021 mes num-ma ma-length progress)
2022 ;; synchronize marks.
2023 (when (not (eq (elmo-folder-get-type
2024 wl-summary-buffer-folder-name)
2026 (message "Updating marks...")
2027 (setq unread-marks (list wl-summary-unread-cached-mark
2028 wl-summary-unread-uncached-mark
2029 wl-summary-new-mark)
2030 mark-alist (elmo-msgdb-get-mark-alist wl-summary-buffer-msgdb)
2031 num-ma (length mark-alist)
2033 importants (elmo-list-folder-important
2034 wl-summary-buffer-folder-name
2035 (elmo-msgdb-get-overview wl-summary-buffer-msgdb))
2036 has-imap4 (elmo-folder-contains-type
2037 wl-summary-buffer-folder-name 'imap4)
2038 unreads (if (and has-imap4 plugged)
2039 (elmo-list-folder-unread
2040 wl-summary-buffer-folder-name
2041 mark-alist unread-marks)))
2043 (setq progress (/ (* (- num-ma ma-length) 100) num-ma))
2044 (if (not (eq progress last-progress))
2045 (elmo-display-progress 'wl-summary-sync-marks
2048 (setq last-progress progress)
2049 (if (string= (cadr (car mark-alist))
2050 wl-summary-important-mark)
2051 (setq importants-in-db (cons (car (car mark-alist))
2053 (if (member (cadr (car mark-alist)) unread-marks)
2054 (setq unreads-in-db (cons (car (car mark-alist))
2056 (setq mark-alist (cdr mark-alist)
2057 ma-length (1- ma-length)))
2058 (elmo-display-progress 'wl-summary-sync-marks
2061 (setq diff (elmo-list-diff importants importants-in-db))
2062 (setq diffs (cadr diff)) ; important-deletes
2063 (setq mes (format "Updated (-%d" (length diffs)))
2065 (wl-summary-mark-as-important (car diffs)
2066 wl-summary-important-mark
2068 (setq diffs (cdr diffs)))
2069 (setq diffs (car diff)) ; important-appends
2070 (setq mes (concat mes (format "/+%d) important," (length diffs))))
2072 (wl-summary-mark-as-important (car diffs) " " 'no-server)
2073 (setq diffs (cdr diffs)))
2074 (when (and has-imap4 plugged)
2075 (setq diff (elmo-list-diff unreads unreads-in-db))
2076 (setq diffs (cadr diff))
2077 (setq mes (concat mes (format "(-%d" (length diffs))))
2079 (wl-summary-mark-as-read t 'no-server nil (car diffs) 'no-cache)
2080 (setq diffs (cdr diffs)))
2081 (setq diffs (car diff)) ; unread-appends
2082 (setq mes (concat mes (format "/+%d) unread mark(s)." (length diffs))))
2084 (wl-summary-mark-as-unread (car diffs) 'no-server 'no-modeline)
2085 (setq diffs (cdr diffs))))
2086 (if (interactive-p) (message mes)))))
2088 (defun wl-summary-confirm-appends (appends)
2090 (let ((len (length appends))
2092 (if (> len wl-summary-update-confirm-threshold)
2093 (if (y-or-n-p (format "Too many messages(%d). Continue?" len))
2095 (setq in wl-summary-update-confirm-threshold)
2098 (setq in (read-from-minibuffer "Update number: "
2100 in (string-to-int in))
2101 (if (y-or-n-p (format "%d messages are disappeared. OK?"
2104 (nthcdr (max (- len in) 0) appends))
2109 (defun wl-summary-sync-update3 (&optional seen-list unset-cursor)
2110 "Update the summary view."
2112 (let* ((folder wl-summary-buffer-folder-name)
2113 (cur-buf (current-buffer))
2114 (msgdb wl-summary-buffer-msgdb)
2115 (number-alist (elmo-msgdb-get-number-alist msgdb))
2116 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
2117 (overview (elmo-msgdb-get-overview msgdb))
2118 ;;(location (elmo-msgdb-get-location msgdb))
2119 (case-fold-search nil)
2120 (elmo-mime-charset wl-summary-buffer-mime-charset)
2121 (inhibit-read-only t)
2122 (buffer-read-only nil)
2123 diff append-list delete-list
2124 i percent num result
2129 entity ret-val crossed crossed2 sync-all
2130 top-num update-top-list mark
2131 expunged msgs unreads importants)
2132 ;(setq seen-list nil) ;for debug.
2133 (fset 'wl-summary-append-message-func-internal
2134 (wl-summary-get-append-message-func))
2135 ;; Flush pending append operations (disconnected operation).
2137 (wl-summary-flush-pending-append-operations seen-list))
2138 (goto-char (point-max))
2139 (message "Checking folder diff...")
2140 (setq in-folder (elmo-list-folder folder))
2141 (setq in-db (sort (mapcar 'car number-alist) '<))
2142 (when (or (eq msgdb nil) ; trick for unplugged...
2143 (equal msgdb '(nil nil nil nil)))
2145 (wl-summary-set-message-modified)
2146 (wl-summary-set-mark-modified)
2148 (setq diff (if (eq (elmo-folder-get-type folder) 'multi)
2149 (elmo-multi-list-bigger-diff in-folder in-db)
2150 (elmo-list-bigger-diff in-folder in-db)))
2151 (setq append-list (car diff))
2152 (setq delete-list (cadr diff))
2153 (message "Checking folder diff...done.")
2154 ;; Don't delete important-marked msgs other than 'internal.
2155 (unless (eq (elmo-folder-get-type folder) 'internal)
2157 (wl-summary-delete-important-msgs-from-list delete-list
2159 (if (and (elmo-folder-contains-type folder 'nntp)
2160 (elmo-nntp-max-number-precedes-list-active-p))
2161 ;; XXX this does not work correctly in rare case.
2163 (wl-summary-delete-canceled-msgs-from-list delete-list
2165 (if (or (equal diff '(nil nil))
2167 (and (eq (length delete-list) 0)
2168 (eq (length append-list) 0)))
2170 ;; For max-number update...
2171 (if (and (elmo-folder-contains-type folder 'nntp)
2172 (elmo-nntp-max-number-precedes-list-active-p)
2173 (elmo-update-number folder msgdb))
2174 (wl-summary-set-message-modified)
2175 (setq ret-val (format "No update is needed for \"%s\"" folder))))
2177 (message "Deleting...")
2178 (elmo-msgdb-delete-msgs folder delete-list msgdb t) ; reserve cache.
2179 ;;(set-buffer cur-buf)
2180 (wl-summary-delete-messages-on-buffer delete-list t)
2181 (message "Deleting...done."))
2182 ;;(set-buffer cur-buf)
2183 ;; Change "New" marks to "Uncached Unread" marks.
2184 (wl-summary-set-status-marks mark-alist
2186 wl-summary-unread-uncached-mark)
2187 (wl-summary-set-status-marks-on-buffer
2189 wl-summary-unread-uncached-mark)
2190 ;; Confirm appended message number.
2191 (setq append-list (wl-summary-confirm-appends append-list))
2192 (setq num (length append-list))
2196 (setq result (elmo-msgdb-create
2200 wl-summary-unread-cached-mark ; !
2201 wl-summary-read-uncached-mark ; u ;; XXXX
2202 wl-summary-important-mark
2204 ;; delete duplicated messages.
2205 (when (elmo-folder-contains-multi folder)
2206 (setq crossed (elmo-multi-delete-crossposts
2208 (setq result (cdr crossed))
2209 (setq crossed (car crossed)))
2210 (setq overview-append (car result))
2211 (setq msgdb (elmo-msgdb-append msgdb result))
2212 ;; set these value for append-message-func
2213 (setq overview (elmo-msgdb-get-overview msgdb))
2214 (setq number-alist (elmo-msgdb-get-number-alist msgdb))
2215 (setq mark-alist (elmo-msgdb-get-mark-alist msgdb))
2216 ;; (setq location (elmo-msgdb-get-location msgdb))
2217 (setq curp overview-append)
2218 (setq num (length curp))
2220 (setq entity (car curp))
2222 (wl-summary-append-message-func-internal
2223 entity overview mark-alist
2226 (wl-append update-top-list (list top-num)))
2227 (if elmo-use-database
2228 (elmo-database-msgid-put
2230 (elmo-msgdb-overview-entity-get-number entity)))
2231 (setq curp (cdr curp))
2233 (setq percent (/ (* i 100) num))
2234 (elmo-display-progress
2235 'wl-summary-sync-update3 "Updating thread..."
2237 (setq update-top-list
2238 (elmo-uniq-list update-top-list))
2239 (when (and (eq wl-summary-buffer-view 'thread)
2241 (message "Updating indent...")
2242 (wl-thread-update-indent-string-thread update-top-list)
2243 (message "Updating indent...done."))
2244 (message "Updating thread...done.")
2245 ;;(set-buffer cur-buf)
2247 (wl-summary-set-message-modified)
2248 (wl-summary-set-mark-modified)
2249 (setq wl-summary-buffer-msgdb msgdb)
2250 (when (and sync-all (eq wl-summary-buffer-view 'thread))
2251 (message "Inserting thread...")
2252 (setq wl-thread-entity-cur 0)
2253 (wl-thread-insert-top)
2254 (message "Inserting thread...done."))
2255 (if elmo-use-database
2256 (elmo-database-close))
2257 (run-hooks 'wl-summary-sync-updated-hook)
2258 (setq ret-val (format "Updated (-%d/+%d) message(s)"
2259 (length delete-list) num)))
2260 ;; synchronize marks.
2261 (if wl-summary-auto-sync-marks
2262 (wl-summary-sync-marks))
2264 (when wl-use-scoring
2265 (setq wl-summary-scored nil)
2266 (wl-summary-score-headers nil msgdb
2268 (wl-summary-rescore-msgs number-alist))
2270 (setq expunged (wl-summary-score-update-all-lines))
2272 (setq ret-val (concat ret-val
2273 (format " (%d expunged)"
2274 (length expunged))))))
2276 (setq crossed2 (wl-summary-update-crosspost))
2277 (if (or crossed crossed2)
2278 (let ((crosses (+ (or crossed 0)
2283 (format " (%d crosspost)" crosses))
2284 (format "%d crosspost message(s)" crosses))))
2286 (setq ret-val (concat ret-val "."))))
2287 ;; Update Folder mode
2288 (wl-folder-set-folder-updated folder (list 0
2289 (wl-summary-count-unread
2290 (elmo-msgdb-get-mark-alist
2292 (length in-folder)))
2293 (wl-summary-update-modeline)
2295 (unless unset-cursor
2296 (goto-char (point-min))
2297 (if (not (wl-summary-cursor-down t))
2299 (goto-char (point-max))
2301 (if (and wl-summary-highlight
2302 (not (get-text-property (point) 'face)))
2306 wl-summary-partial-highlight-above-lines
2307 wl-summary-highlight-partial-threshold)))
2308 (wl-highlight-summary (point) (point-max))))))
2309 (wl-delete-all-overlays)
2310 (set-buffer-modified-p nil)
2313 (defun wl-summary-set-score-mark (mark)
2316 (let ((inhibit-read-only t)
2317 (buffer-read-only nil)
2320 (when (looking-at "^ *\\([0-9]+\\)\\([^0-9]\\)")
2321 (setq msg-num (string-to-int (wl-match-buffer 1)))
2322 (setq cur-mark (wl-match-buffer 2))
2323 (when (member cur-mark (list " "
2324 wl-summary-score-below-mark
2325 wl-summary-score-over-mark))
2326 (goto-char (match-end 1))
2327 (delete-region (match-beginning 2) (match-end 2))
2329 (if wl-summary-highlight
2330 (wl-highlight-summary-current-line nil nil t))
2331 (set-buffer-modified-p nil))))))
2333 (defun wl-summary-get-score-mark (msg-num)
2334 (let ((score (cdr (assq msg-num wl-summary-scored))))
2336 (cond ((< score wl-summary-default-score)
2338 ((> score wl-summary-default-score)
2341 (defun wl-summary-update-modeline ()
2342 (setq wl-summary-buffer-unread-status
2343 (format " {%s}(%d new/%d unread)"
2344 (if (eq wl-summary-buffer-view 'thread)
2346 wl-summary-buffer-new-count
2347 (+ wl-summary-buffer-new-count
2348 wl-summary-buffer-unread-count))))
2350 (defsubst wl-summary-jump-to-msg (&optional number)
2352 (let ((num (or number
2354 (read-from-minibuffer "Jump to Message(No.): ")))))
2355 (setq num (int-to-string num))
2356 (if (re-search-forward (concat "^[ \t]*" num "[^0-9]") nil t)
2360 (if (re-search-backward (concat "^[ \t]*" num "[^0-9]") nil t)
2366 (defun wl-summary-highlight-msgs (msgs)
2368 (let ((len (length msgs))
2370 (message "Hilighting...")
2374 (elmo-display-progress
2375 'wl-summary-highlight-msgs "Highlighting..."
2377 (if (wl-summary-jump-to-msg (car msgs))
2378 (wl-highlight-summary-current-line))
2379 (setq msgs (cdr msgs)))
2380 (message "Highlighting...done."))))
2382 (defun wl-summary-message-number ()
2385 (if (looking-at "^ *\\([0-9]+\\)")
2386 (string-to-int (wl-match-buffer 1))
2389 (defun wl-summary-move (src dsts-msgs)
2390 (let* ((dsts (car dsts-msgs)) ; (+foo +bar)
2391 ;; (msgs (cdr dsts-msgs)) ; (1 2 3)
2392 ;; (msgdb wl-summary-buffer-msgdb)
2396 (setq dsts (cdr dsts)))))
2398 (defun wl-summary-flush-pending-append-operations (&optional seen-list)
2399 "Execute append operations that are done while offline status."
2400 (when (and (elmo-folder-plugged-p wl-summary-buffer-folder-name)
2401 elmo-enable-disconnected-operation)
2402 (let* ((resumed-list (elmo-dop-append-list-load
2403 wl-summary-buffer-folder-name t))
2404 (append-list (elmo-dop-append-list-load
2405 wl-summary-buffer-folder-name))
2406 (appends (append resumed-list append-list))
2407 (number-alist (elmo-msgdb-get-number-alist wl-summary-buffer-msgdb))
2411 (if (setq pair (rassoc (car appends) number-alist))
2412 (setq dels (append dels (list (car pair)))))
2413 (setq appends (cdr appends)))
2416 (elmo-msgdb-add-msgs-to-seen-list-subr
2418 wl-summary-buffer-msgdb
2419 (concat wl-summary-important-mark
2420 wl-summary-read-uncached-mark)
2422 (message "Resuming summary status...")
2423 (elmo-msgdb-delete-msgs wl-summary-buffer-folder-name
2424 dels wl-summary-buffer-msgdb t)
2425 (wl-summary-delete-messages-on-buffer dels)
2426 (message "Resuming summary status...done."))
2427 ;; delete resume-file
2428 (elmo-dop-append-list-save wl-summary-buffer-folder-name nil t)
2430 (elmo-dop-flush-pending-append-operations
2431 wl-summary-buffer-folder-name append-list)))))
2434 (defun wl-summary-delete-all-msgs ()
2436 (let ((cur-buf (current-buffer))
2437 (dels (elmo-list-folder wl-summary-buffer-folder-name)))
2438 (set-buffer cur-buf)
2440 (message "No message to delete.")
2441 (if (y-or-n-p (format "%s has %d message(s). Delete all?"
2442 wl-summary-buffer-folder-name
2445 (message "Deleting...")
2446 (elmo-delete-msgs wl-summary-buffer-folder-name dels
2447 wl-summary-buffer-msgdb)
2448 (elmo-msgdb-delete-msgs wl-summary-buffer-folder-name
2449 dels wl-summary-buffer-msgdb)
2450 ;;(elmo-msgdb-save wl-summary-buffer-folder-name nil)
2451 (wl-summary-set-message-modified)
2452 (wl-summary-set-mark-modified)
2453 (wl-folder-set-folder-updated wl-summary-buffer-folder-name
2456 ;; (setq wl-thread-top-entity '(nil t nil nil))
2457 (setq wl-summary-buffer-unread-count 0)
2458 (setq wl-summary-buffer-new-count 0)
2459 (wl-summary-update-modeline)
2460 (set-buffer cur-buf)
2461 (let ((inhibit-read-only t)
2462 (buffer-read-only nil))
2464 ;; (if wl-summary-cache-use (wl-summary-save-view-cache))
2465 (message "Deleting...done.")
2469 (defun wl-summary-toggle-thread (&optional arg)
2470 "Toggle thread status (T)hread and (S)equencial."
2473 (y-or-n-p (format "Toggle threading? (y=%s): "
2474 (if (eq wl-summary-buffer-view 'thread)
2475 "\"off\"" "\"on\""))))
2476 (if (eq wl-summary-buffer-view 'thread)
2477 (setq wl-summary-buffer-view 'sequence)
2478 (setq wl-summary-buffer-view 'thread))
2479 (wl-summary-update-modeline)
2480 (force-mode-line-update)
2481 (wl-summary-rescan)))
2483 (defun wl-summary-load-file-object (filename)
2484 "Load lisp object from dir."
2486 (let ((tmp-buffer (get-buffer-create " *wl-summary-load-file-object*"))
2487 insert-file-contents-pre-hook ; To avoid autoconv-xmas...
2488 insert-file-contents-post-hook
2490 (if (not (file-readable-p filename))
2492 (set-buffer tmp-buffer)
2493 (as-binary-input-file (insert-file-contents filename))
2496 (read (current-buffer))
2497 (error (error "reading failed")))))
2498 (kill-buffer tmp-buffer)
2501 (defun wl-summary-goto-folder (&optional arg)
2503 (wl-summary-goto-folder-subr nil nil nil arg t))
2505 (defun wl-summary-goto-last-visited-folder ()
2508 (wl-folder-search-entity-by-name wl-summary-last-visited-folder
2511 (if entity (wl-folder-set-current-entity-id
2512 (wl-folder-get-entity-id entity))))
2513 (wl-summary-goto-folder-subr wl-summary-last-visited-folder nil nil nil t))
2515 (defun wl-summary-sticky-p (&optional fld)
2517 (get-buffer (wl-summary-sticky-buffer-name fld))
2518 (not (string= wl-summary-buffer-name (buffer-name)))))
2520 (defmacro wl-summary-always-sticky-folder-p (fld)
2521 (` (wl-string-match-member (, fld) wl-summary-always-sticky-folder-list)))
2523 (defun wl-summary-stick (&optional force)
2524 "Make current summary buffer sticky."
2526 (if (wl-summary-sticky-p)
2527 (message "Current summary buffer is already sticky.")
2528 (when (or force (y-or-n-p "Stick current summary buffer?"))
2529 (wl-summary-toggle-disp-msg 'off)
2530 (wl-summary-switch-to-clone-buffer
2531 (wl-summary-sticky-buffer-name
2532 wl-summary-buffer-folder-name))
2534 ; (rename-buffer (wl-summary-sticky-buffer-name
2535 ; wl-summary-buffer-folder-name)))
2536 (message "Folder `%s' is now sticky." wl-summary-buffer-folder-name))))
2538 (defun wl-summary-switch-to-clone-buffer (buffer-name)
2539 (let ((cur-buf (current-buffer))
2540 (msg (wl-summary-message-number))
2541 (buf (get-buffer-create buffer-name))
2542 (folder wl-summary-buffer-folder-name)
2544 (append '(wl-summary-buffer-view
2545 wl-summary-buffer-refile-list
2546 wl-summary-buffer-delete-list
2547 wl-summary-buffer-copy-list
2548 wl-summary-buffer-target-mark-list
2549 wl-summary-buffer-msgdb
2550 wl-summary-buffer-number-column
2551 wl-summary-buffer-number-regexp
2552 wl-summary-buffer-message-modified
2553 wl-summary-buffer-mark-modified)
2554 (and (eq wl-summary-buffer-view 'thread)
2555 '(wl-thread-entity-hashtb
2557 wl-thread-entity-list))
2560 wl-summary-default-score
2561 wl-summary-important-above
2562 wl-summary-temp-above
2563 wl-summary-mark-below
2564 wl-summary-expunge-below))
2565 (and (featurep 'wl-score)
2566 '(wl-current-score-file
2569 (wl-summary-buffer-set-folder folder)
2571 (let ((buffer-read-only nil))
2572 (insert-buffer cur-buf))
2573 (set-buffer-modified-p nil)
2577 (set var (save-excursion
2578 (set-buffer cur-buf)
2579 (symbol-value var)))))
2581 (switch-to-buffer buf)
2582 (kill-buffer cur-buf)
2583 (setq mode-line-buffer-identification
2584 (format "Wanderlust: %s"
2585 (if (memq 'modeline wl-use-folder-petname)
2586 (wl-folder-get-petname folder)
2588 (wl-summary-count-unread
2589 (elmo-msgdb-get-mark-alist wl-summary-buffer-msgdb))
2590 (wl-summary-update-modeline)
2592 (if (eq wl-summary-buffer-view 'thread)
2593 (wl-thread-jump-to-msg msg)
2594 (wl-summary-jump-to-msg msg))
2595 (goto-char (point-max))
2596 (beginning-of-line))))
2598 (defun wl-summary-get-buffer (folder)
2600 (get-buffer (wl-summary-sticky-buffer-name folder)))
2601 (get-buffer wl-summary-buffer-name)))
2603 (defun wl-summary-get-buffer-create (folder &optional force-sticky)
2606 (wl-summary-sticky-buffer-name folder))
2607 (or (get-buffer (wl-summary-sticky-buffer-name folder))
2608 (get-buffer-create wl-summary-buffer-name))))
2610 (defun wl-summary-disp-msg (folder disp-msg)
2613 wl-summary-buffer-disp-msg)
2614 (let ((view-message-buffer (get-buffer wl-message-buf-name))
2615 (number (wl-summary-message-number))
2616 cur-folder cur-number sel-win)
2617 (when view-message-buffer
2619 (set-buffer view-message-buffer)
2620 (setq cur-folder wl-message-buffer-cur-folder
2621 cur-number wl-message-buffer-cur-number))
2622 (when (and (string= folder cur-folder)
2623 (eq number cur-number))
2624 (setq sel-win (selected-window))
2625 (wl-select-buffer view-message-buffer)
2626 (select-window sel-win)
2629 (setq wl-summary-buffer-disp-msg nil))
2630 (when (and (not disp)
2631 (setq mes-win (wl-message-buffer-window)))
2632 (delete-window mes-win)
2633 (run-hooks 'wl-summary-toggle-disp-off-hook))))
2635 (defun wl-summary-goto-folder-subr (&optional folder scan-type other-window
2636 sticky interactive scoring)
2637 "Display target folder on summary"
2639 (let* ((keep-cursor (memq this-command
2640 wl-summary-keep-cursor-command))
2641 (fld (or folder (wl-summary-read-folder wl-default-folder)))
2642 (cur-fld wl-summary-buffer-folder-name)
2643 buf mes hilit reuse-buf
2645 (if (string= fld "")
2646 (setq fld wl-default-folder))
2647 (when (and (not (string= cur-fld fld)) ; folder is moved.
2648 (eq major-mode 'wl-summary-mode)) ; called in summary.
2649 (setq wl-summary-last-visited-folder wl-summary-buffer-folder-name)
2650 (wl-summary-cleanup-temp-marks (wl-summary-sticky-p))
2651 (wl-summary-save-status 'keep)) ;; keep current buffer, anyway.
2652 (setq buf (wl-summary-get-buffer-create fld sticky))
2656 (string= fld wl-summary-buffer-folder-name)))
2660 (switch-to-buffer buf)
2663 (delete-other-windows))
2665 (wl-summary-buffer-set-folder fld)
2666 (unless (eq major-mode 'wl-summary-mode)
2668 (setq wl-summary-buffer-disp-msg nil)
2669 (setq wl-summary-buffer-last-displayed-msg nil)
2670 (setq wl-summary-buffer-current-msg nil)
2671 (let ((case-fold-search nil)
2672 (inhibit-read-only t)
2673 (buffer-read-only nil))
2675 (setq mode-line-buffer-identification
2676 (format "Wanderlust: %s"
2677 (if (memq 'modeline wl-use-folder-petname)
2678 (wl-folder-get-petname fld)
2680 ;; resume summary cache
2681 (if wl-summary-cache-use
2682 (let* ((dir (elmo-msgdb-expand-path fld))
2683 (cache (expand-file-name wl-summary-cache-file dir))
2684 (view (expand-file-name wl-summary-view-file dir)))
2685 (when (file-exists-p cache)
2686 (as-binary-input-file
2687 (insert-file-contents cache))
2688 (elmo-set-buffer-multibyte
2689 default-enable-multibyte-characters)
2690 (decode-mime-charset-region
2691 (point-min)(point-max)
2692 wl-summary-buffer-mime-charset))
2693 (when (file-exists-p view)
2694 (setq wl-summary-buffer-view
2695 (wl-summary-load-file-object view)))
2696 (if (eq wl-summary-buffer-view 'thread)
2697 (wl-thread-resume-entity fld))))
2699 (setq wl-summary-buffer-msgdb nil) ; new msgdb
2700 (setq wl-summary-buffer-msgdb
2701 (wl-summary-msgdb-load-async fld))
2702 (if (null wl-summary-buffer-msgdb)
2703 (setq wl-summary-buffer-msgdb
2704 (elmo-msgdb-load (elmo-string fld))))
2705 (wl-summary-count-unread
2706 (elmo-msgdb-get-mark-alist wl-summary-buffer-msgdb))
2707 (wl-summary-update-modeline)))
2708 (wl-summary-buffer-number-column-detect t)
2709 (wl-summary-disp-msg fld (and reuse-buf keep-cursor))
2710 (unless (and reuse-buf keep-cursor)
2711 (setq hilit wl-summary-highlight)
2713 (let ((wl-summary-highlight (if reuse-buf wl-summary-highlight))
2715 (if (or scoring interactive) wl-use-scoring)))
2716 (if (and (not scan-type)
2719 (setq scan-type (wl-summary-get-sync-range fld)))
2722 (wl-summary-sync 'unset-cursor))
2723 ((eq scan-type 'all)
2724 (wl-summary-sync 'unset-cursor "all"))
2725 ((eq scan-type 'no-sync))
2726 ((or (eq scan-type 'force-update)
2727 (eq scan-type 'update))
2728 (setq mes (wl-summary-sync-force-update 'unset-cursor)))))
2730 (switch-to-buffer buf)
2732 ;; stick always-sticky-folder
2733 (when (wl-summary-always-sticky-folder-p fld)
2734 (or (wl-summary-sticky-p) (wl-summary-stick t)))
2735 (run-hooks 'wl-summary-prepared-pre-hook)
2736 (set-buffer-modified-p nil)
2737 (goto-char (point-min))
2738 (if (wl-summary-cursor-down t)
2739 (let ((unreadp (wl-thread-next-mark-p
2740 (wl-thread-entity-get-mark
2741 (wl-summary-message-number))
2742 wl-summary-move-order)))
2743 (cond ((and wl-auto-select-first unreadp)
2744 (setq retval 'disp-msg))
2746 (setq retval 'more-next))))
2747 (goto-char (point-max))
2748 (if (elmo-folder-plugged-p folder)
2751 (setq retval 'more-next))
2752 (setq wl-summary-highlight hilit)
2753 (if (and wl-summary-highlight
2755 (if (and wl-summary-highlight-partial-threshold
2756 (> (count-lines (point-min) (point-max))
2757 wl-summary-highlight-partial-threshold))
2762 wl-summary-partial-highlight-above-lines
2763 wl-summary-highlight-partial-threshold)))
2764 (wl-highlight-summary (point) (point-max)))
2765 (wl-highlight-summary (point-min) (point-max))))
2766 (if (null wl-summary-buffer-msgdb) ;; one more try.
2767 (setq wl-summary-buffer-msgdb
2768 (elmo-msgdb-load (elmo-string fld))))
2769 (if (eq retval 'disp-msg)
2770 (wl-summary-redisplay))
2771 (if mes (message "%s" mes))
2772 (if (and interactive wl-summary-recenter)
2773 (recenter (/ (- (window-height) 2) 2))))))
2774 ;; set current entity-id
2775 (if (and (not folder)
2777 (wl-folder-search-entity-by-name fld
2780 ;; entity-id is unknown.
2781 (wl-folder-set-current-entity-id
2782 (wl-folder-get-entity-id entity)))
2784 (run-hooks 'wl-summary-prepared-hook)
2785 (set-buffer-modified-p nil))
2788 (defun wl-summary-summary-line-already-exists-p (parent-number buffer)
2789 "returns the depth."
2791 (goto-char (point-max))
2793 (when (re-search-backward (format "^ *%s..../..\(.*\)..:.. "
2794 parent-number) nil t)
2795 (goto-char (match-end 0))
2796 (while (string-match wl-thread-indent-regexp
2798 (char-after (point))))
2799 (setq depth (+ 1 depth))
2801 (/ depth wl-thread-indent-level-internal))))
2803 (defun wl-summary-goto-bottom-of-current-thread ()
2804 (if (re-search-forward (concat "^" wl-summary-buffer-number-regexp
2805 "..../..\(.*\)..:.. \\[") nil t)
2807 (goto-char (point-max))))
2809 (defun wl-summary-goto-top-of-current-thread ()
2810 (wl-summary-jump-to-msg
2811 (wl-thread-entity-get-number
2812 (wl-thread-entity-get-top-entity (wl-thread-get-entity
2813 (wl-summary-message-number))))))
2815 (defun wl-summary-goto-bottom-of-sub-thread (&optional depth)
2817 (let ((depth (or depth
2818 (wl-thread-get-depth-of-current-line))))
2820 (while (and (not (eobp))
2821 (>= (wl-thread-get-depth-of-current-line)
2824 (beginning-of-line)))
2826 (defun wl-summary-insert-line (line)
2827 "Insert LINE in the Summary."
2828 (if wl-use-highlight-mouse-line
2829 ;; remove 'mouse-face of current line.
2831 (save-excursion (beginning-of-line)(point))
2832 (save-excursion (end-of-line)(point))
2835 (if wl-use-highlight-mouse-line
2836 ;; remove 'mouse-face of current line.
2838 (save-excursion (beginning-of-line)(point))
2839 (save-excursion (end-of-line)(point))
2841 (condition-case nil ; it's dangerous, so ignore error.
2842 (run-hooks 'wl-summary-line-inserted-hook)
2844 (message "Error in wl-summary-line-inserted-hook"))))
2846 (defun wl-summary-insert-summary (entity database mark-alist dummy)
2847 (let ((overview-entity entity)
2849 (setq msg (elmo-msgdb-overview-entity-get-number entity))
2850 (when (setq summary-line
2851 (wl-summary-overview-create-summary-line
2852 msg entity nil 0 mark-alist))
2853 (let ((inhibit-read-only t)
2855 (goto-char (point-max))
2856 (wl-summary-insert-line summary-line)))))
2858 (defun wl-summary-default-subject-filter (subject)
2859 (let ((case-fold-search t))
2860 (setq subject (elmo-replace-in-string subject "[ \t]*\\(re\\|was\\):" ""))
2861 (setq subject (elmo-replace-in-string subject "[ \t]" ""))
2862 (elmo-replace-in-string subject "^\\[.*\\]" "")))
2864 (defun wl-summary-subject-equal (subject1 subject2)
2865 (string= (wl-summary-subject-filter-func-internal subject1)
2866 (wl-summary-subject-filter-func-internal subject2)))
2868 (defun wl-summary-insert-thread-entity (entity overview mark-alist update)
2869 (let* ((this-id (elmo-msgdb-overview-entity-get-id entity))
2871 (elmo-msgdb-overview-get-parent-entity entity overview));; temp
2872 ;;(parent-id (elmo-msgdb-overview-entity-get-id parent-entity))
2873 (parent-number (elmo-msgdb-overview-entity-get-number parent-entity))
2875 (if (and parent-number
2876 wl-summary-divide-thread-when-subject-changed
2877 (not (wl-summary-subject-equal
2878 (or (elmo-msgdb-overview-entity-get-subject
2880 (or (elmo-msgdb-overview-entity-get-subject
2881 parent-entity) ""))))
2882 (setq parent-number nil))
2883 (setq msg (elmo-msgdb-overview-entity-get-number entity))
2884 (wl-thread-insert-message entity overview mark-alist
2885 msg parent-number update)))
2887 (defun wl-summary-update-thread (entity
2893 (this-id (elmo-msgdb-overview-entity-get-id entity))
2894 (overview-entity entity)
2895 (parent-id (elmo-msgdb-overview-entity-get-id parent-entity))
2896 (parent-number (elmo-msgdb-overview-entity-get-number parent-entity))
2897 summary-line msg subject-differ)
2899 ((or (not parent-id)
2900 (string= this-id parent-id))
2901 (goto-char (point-max))
2902 (beginning-of-line))
2903 ;; parent already exists in buffer.
2904 ((setq depth (or (wl-summary-summary-line-already-exists-p
2905 parent-number (current-buffer)) -1))
2906 (setq depth (+ 1 depth))
2907 (wl-thread-goto-bottom-of-sub-thread)))
2908 (if (and (elmo-msgdb-overview-entity-get-number entity))
2909 (if (setq summary-line
2910 (wl-summary-overview-create-summary-line
2911 (elmo-msgdb-overview-entity-get-number entity)
2912 entity parent-entity depth mark-alist nil nil
2914 (let ((inhibit-read-only t)
2915 (buffer-read-only nil))
2916 (wl-summary-insert-line summary-line))))))
2918 (defun wl-summary-mark-as-unread (&optional number
2924 (inhibit-read-only t)
2925 (buffer-read-only nil)
2926 (folder wl-summary-buffer-folder-name)
2927 (msgdb wl-summary-buffer-msgdb)
2928 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
2929 ;;(number-alist (elmo-msgdb-get-number-alist msgdb))
2930 new-mark visible mark)
2933 (setq visible (wl-summary-jump-to-msg number))
2934 (unless (setq mark (cadr (assq number mark-alist)))
2940 (re-search-backward (concat "^" wl-summary-buffer-number-regexp
2941 "..../..")) ; set cursor line
2943 (if (or (and (not visible)
2944 ;; already exists in msgdb.
2945 (assq number (elmo-msgdb-get-number-alist msgdb)))
2947 (format (concat "^ *\\("
2948 (if number (int-to-string number)
2950 "\\)[^0-9]\\(%s\\|%s\\)")
2951 wl-summary-read-uncached-mark
2954 (setq number (or number (string-to-int (wl-match-buffer 1))))
2955 (setq mark (or mark (elmo-match-buffer 2)))
2957 (setq new-mark (if (string= mark
2958 wl-summary-read-uncached-mark)
2959 wl-summary-unread-uncached-mark
2960 (if (elmo-use-cache-p folder number)
2961 wl-summary-unread-mark
2962 wl-summary-unread-uncached-mark))))
2964 (unless no-server-update
2965 (elmo-mark-as-unread folder (list number)
2968 (delete-region (match-beginning 2) (match-end 2))
2971 (elmo-msgdb-mark-set mark-alist
2974 (elmo-msgdb-set-mark-alist msgdb mark-alist)
2975 (unless no-modeline-update
2976 (setq wl-summary-buffer-unread-count
2977 (+ 1 wl-summary-buffer-unread-count))
2978 (wl-summary-update-modeline)
2979 (wl-folder-update-unread
2981 (+ wl-summary-buffer-unread-count
2982 wl-summary-buffer-new-count)))
2983 (wl-summary-set-mark-modified)
2984 (if (and visible wl-summary-highlight)
2985 (wl-highlight-summary-current-line))))))
2986 (set-buffer-modified-p nil))
2988 (defun wl-summary-delete (&optional number)
2989 "Mark Delete mark 'D'.
2990 If optional argument NUMBER is specified, mark message specified by NUMBER."
2992 (let* ((buffer-num (wl-summary-message-number))
2993 (msg-num (or number buffer-num))
2996 (when (null msg-num)
2998 (message "No message."))
3000 (when (setq mark (wl-summary-get-mark msg-num))
3001 (when (wl-summary-reserve-temp-mark-p mark)
3003 (error "Already marked as `%s'" mark))
3005 (wl-summary-unmark msg-num))
3006 (if (or (interactive-p)
3007 (eq number buffer-num))
3008 (wl-summary-mark-line "D"))
3009 (setq wl-summary-buffer-delete-list
3010 (cons msg-num wl-summary-buffer-delete-list))
3012 (if (eq wl-summary-move-direction-downward nil)
3017 (defun wl-summary-remove-destination ()
3019 (let ((inhibit-read-only t)
3020 (buffer-read-only nil)
3021 (buf (current-buffer))
3027 (setq rs (next-single-property-change sol 'wl-summary-destination
3029 (setq re (next-single-property-change rs 'wl-summary-destination
3031 (put-text-property rs re 'wl-summary-destination nil)
3032 (put-text-property rs re 'invisible nil)
3034 (delete-char (- eol re)))))
3036 (defun wl-summary-check-mark (msg mark)
3037 (let ((check-func (cond ((string= mark "o")
3038 'wl-summary-msg-marked-as-refiled)
3040 'wl-summary-msg-marked-as-copied)
3042 'wl-summary-msg-marked-as-deleted)
3044 'wl-summary-msg-marked-as-target))))
3046 (funcall check-func msg))))
3048 (defun wl-summary-mark-collect (mark &optional begin end)
3052 (narrow-to-region (or begin (point-min))
3053 (or end (point-max)))
3054 (goto-char (point-min))
3056 (if (eq wl-summary-buffer-view 'thread)
3059 (let* ((number (wl-summary-message-number))
3060 (entity (wl-thread-get-entity number))
3062 ;; opened...only myself is checked.
3063 (if (wl-summary-check-mark number mark)
3064 (wl-append msglist (list number)))
3065 (unless (wl-thread-entity-get-opened entity)
3066 ;; closed...children is also checked.
3067 (if (setq result (wl-thread-get-children-msgs-with-mark
3070 (wl-append msglist result)))
3072 (elmo-uniq-list msglist))
3073 (let* ((case-fold-search nil)
3074 (re (format (concat wl-summary-message-regexp "%s")
3075 (regexp-quote mark))))
3076 (while (re-search-forward re nil t)
3077 (setq msglist (cons (wl-summary-message-number) msglist)))
3078 (nreverse msglist)))))))
3080 (defun wl-summary-exec ()
3082 (wl-summary-exec-subr (mapcar 'car wl-summary-buffer-refile-list)
3083 (reverse wl-summary-buffer-delete-list)
3084 (mapcar 'car wl-summary-buffer-copy-list)))
3086 (defun wl-summary-exec-region (beg end)
3088 (message "Collecting marks ...")
3093 (goto-char (1- end))
3096 (wl-summary-exec-subr (wl-summary-mark-collect "o" beg end)
3097 (wl-summary-mark-collect "D" beg end)
3098 (wl-summary-mark-collect "O" beg end))))
3100 (defun wl-summary-exec-subr (msgs dels cpys)
3102 (let* ((del-fld (wl-summary-get-delete-folder
3103 wl-summary-buffer-folder-name))
3105 dst tmp msg msgs2 cpys2
3106 msg-dst dst-msgs len
3109 succeeds result executed)
3110 (if (not (or msgs dels cpys))
3111 (message "No marks")
3112 (message "Executing ...")
3113 (setq msgs (append msgs dels))
3116 (when (not (assq (car dels) wl-summary-buffer-refile-list))
3117 (wl-append wl-summary-buffer-refile-list
3118 (list (cons (car dels) del-fld)))
3119 (setq wl-summary-buffer-delete-list
3120 (delete (car dels) wl-summary-buffer-delete-list)))
3121 (setq dels (cdr dels)))
3122 (setq len (length msgs2))
3125 (setq msg (car msgs))
3126 (setq msgs (cdr msgs))
3127 (setq msg-dst (assq msg wl-summary-buffer-refile-list))
3128 (setq dst (cdr msg-dst))
3130 (if (setq tmp (assoc dst dst-msgs))
3131 (setq dst-msgs (cons (append tmp (list msg))
3132 (delete tmp dst-msgs)))
3133 (setq dst-msgs (cons (list dst msg) dst-msgs)))))
3134 (setq refile-failures 0)
3135 (goto-char start) ; avoid moving cursor to the bottom line.
3138 ;;(elmo-msgdb-add-msgs-to-seen-list
3139 ;; (car (car dst-msgs)) ;dst-folder
3140 ;; (cdr (car dst-msgs)) ;msgs
3141 ;; wl-summary-buffer-msgdb
3142 ;; (concat wl-summary-important-mark
3143 ;; wl-summary-read-uncached-mark))
3146 (setq result (elmo-move-msgs wl-summary-buffer-folder-name
3147 (cdr (car dst-msgs))
3148 (car (car dst-msgs))
3149 wl-summary-buffer-msgdb
3150 len executed (cdr dst-msgs)
3153 (list wl-summary-unread-cached-mark
3154 wl-summary-unread-uncached-mark
3155 wl-summary-new-mark)))
3157 (if result ; succeeded.
3160 (wl-summary-delete-messages-on-buffer
3161 (cdr (car dst-msgs)))
3162 ;; update refile-alist.
3166 (setq wl-summary-buffer-refile-list
3167 (delq (assq x wl-summary-buffer-refile-list)
3168 wl-summary-buffer-refile-list))))
3169 (cdr (car dst-msgs))))
3170 (setq refile-failures
3171 (+ refile-failures (length (cdr (car dst-msgs))))))
3172 (setq executed (+ executed (length (cdr (car dst-msgs)))))
3173 (setq dst-msgs (cdr dst-msgs)))
3177 (setq len (length cpys2))
3179 (setq msg (car cpys))
3180 (setq cpys (cdr cpys))
3181 (setq msg-dst (assq msg wl-summary-buffer-copy-list))
3182 (setq dst (cdr msg-dst))
3184 (if (setq tmp (assoc dst dst-msgs))
3185 (setq dst-msgs (cons (append tmp (list msg))
3186 (delete tmp dst-msgs)))
3187 (setq dst-msgs (cons (list dst msg) dst-msgs)))))
3188 (setq copy-failures 0)
3191 ;;(elmo-msgdb-add-msgs-to-seen-list
3192 ;;(car (car dst-msgs)) ;dst-folder
3193 ;;(cdr (car dst-msgs)) ;msgs
3194 ;;wl-summary-buffer-msgdb
3195 ;;(concat wl-summary-important-mark
3196 ;;wl-summary-read-uncached-mark))
3199 (setq result (elmo-move-msgs wl-summary-buffer-folder-name
3200 (cdr (car dst-msgs))
3201 (car (car dst-msgs))
3202 wl-summary-buffer-msgdb
3205 t ; t is no-delete (copy)
3208 wl-summary-unread-cached-mark
3209 wl-summary-unread-uncached-mark
3210 wl-summary-new-mark)))
3212 (if result ; succeeded.
3215 (wl-summary-delete-copy-marks-on-buffer (cdr (car dst-msgs)))
3216 ;; update copy-alist
3220 (setq wl-summary-buffer-copy-list
3221 (delq (assq x wl-summary-buffer-copy-list)
3222 wl-summary-buffer-copy-list))))
3223 (cdr (car dst-msgs))))
3225 (+ copy-failures (length (cdr (car dst-msgs))))))
3226 (setq executed (+ executed (length (cdr (car dst-msgs)))))
3227 (setq dst-msgs (cdr dst-msgs)))
3229 (wl-summary-folder-info-update)
3230 (wl-summary-set-message-modified)
3231 (wl-summary-set-mark-modified)
3232 (run-hooks 'wl-summary-exec-hook)
3233 (set-buffer-modified-p nil)
3234 (message (concat "Executing ... done"
3235 (if (> refile-failures 0)
3236 (format " (%d refiling failed)" refile-failures)
3238 (if (> copy-failures 0)
3239 (format " (%d copying failed)" copy-failures)
3243 (defun wl-summary-read-folder (default &optional purpose ignore-error
3245 (let ((fld (completing-read
3246 (format "Folder name %s(%s): " (or purpose "")
3248 (or wl-folder-completion-func
3249 (if (memq 'read-folder wl-use-folder-petname)
3250 (wl-folder-get-entity-with-petname)
3251 wl-folder-entity-hashtb))
3252 nil nil (or init wl-default-spec)
3253 'wl-read-folder-hist)))
3254 (setq fld (elmo-string (wl-folder-get-realname fld)))
3255 (if (string-match "\n" fld)
3256 (error "Not supported folder name: %s" fld))
3257 (if (or (string= fld wl-default-spec)
3261 (wl-folder-confirm-existence fld ignore-error))
3264 (defun wl-summary-print-destination (msg-num folder)
3265 "Print refile destination on line."
3266 (wl-summary-remove-destination)
3267 (let ((inhibit-read-only t)
3268 (folder (copy-sequence folder))
3269 (buffer-read-only nil)
3271 (setq len (string-width folder))
3278 (setq c (+ c (char-width (following-char)))))
3280 (put-text-property rs re 'invisible t)
3281 (put-text-property rs re 'wl-summary-destination t)
3283 (wl-highlight-refile-destination-string folder)
3285 (set-buffer-modified-p nil))))
3289 (defun wl-summary-print-destination (msg-num &optional folder))
3290 (defun wl-summary-remove-destination ()))
3292 (defsubst wl-summary-get-mark (number)
3293 "Returns a temporal mark of message specified by NUMBER."
3294 (or (and (memq number wl-summary-buffer-delete-list) "D")
3295 (and (assq number wl-summary-buffer-copy-list) "O")
3296 (and (assq number wl-summary-buffer-refile-list) "o")
3297 (and (assq number wl-summary-buffer-target-mark-list) "*")))
3299 (defsubst wl-summary-reserve-temp-mark-p (mark)
3300 "Returns t if temporal MARK should be reserved."
3301 (member mark wl-summary-reserve-mark-list))
3303 (defun wl-summary-refile (&optional dst number)
3304 "Put refile mark on current line message.
3305 If optional argument DST is specified, put mark without asking
3307 If optional argument NUMBER is specified, mark message specified by NUMBER.
3309 If folder is read-only, message should be copied.
3310 See `wl-refile-policy-alist' for more details."
3312 (let ((policy (wl-get-assoc-list-value wl-refile-policy-alist
3313 wl-summary-buffer-folder-name)))
3314 (cond ((eq policy 'copy)
3316 (call-interactively 'wl-summary-copy)
3317 (wl-summary-copy dst number)))
3319 (wl-summary-refile-subr "refile" (interactive-p) dst number)))))
3321 (defun wl-summary-copy (&optional dst number)
3322 "Put refile mark on current line message.
3323 If optional argument DST is specified, put mark without asking
3325 If optional argument NUMBER is specified, mark message specified by NUMBER."
3327 (wl-summary-refile-subr "copy" (interactive-p) dst number))
3329 (defun wl-summary-refile-subr (copy-or-refile interactive &optional dst number)
3331 (let* ((buffer-num (wl-summary-message-number))
3332 (msg-num (or number buffer-num))
3335 (elmo-msgdb-get-number-alist
3336 wl-summary-buffer-msgdb)))))
3337 (entity (and msg-num
3338 (elmo-msgdb-overview-get-entity-by-number
3339 (elmo-msgdb-get-overview wl-summary-buffer-msgdb)
3342 (intern (format "wl-summary-buffer-%s-list" copy-or-refile)))
3343 folder mark already tmp-folder)
3348 (message "Cannot refile."))
3350 (when (null msg-num)
3352 (message "No message."))
3354 (when (setq mark (wl-summary-get-mark msg-num))
3355 (when (wl-summary-reserve-temp-mark-p mark)
3357 (error "Already marked as `%s'" mark))
3359 (setq folder (and msg-num
3360 (or dst (wl-summary-read-folder
3361 (or (wl-refile-guess entity) wl-trash-folder)
3362 (format "for %s" copy-or-refile)))))
3363 ;; Cache folder hack by okada@opaopa.org
3364 (if (and (eq (car (elmo-folder-get-spec folder)) 'cache)
3365 (not (string= folder
3368 (elmo-cache-get-path-subr
3369 (elmo-msgid-to-cache msgid)))))))
3371 (setq folder tmp-folder)
3372 (message "Force refile to %s." folder)))
3373 (if (string= folder wl-summary-buffer-folder-name)
3374 (error "Same folder"))
3376 (not (elmo-folder-plugged-p folder))
3378 (not (elmo-cache-exists-p msgid))))
3379 (error "Unplugged (no cache or msgid)"))
3380 (if (or (string= folder wl-queue-folder)
3381 (string= folder wl-draft-folder))
3382 (error "Don't %s messages to %s" copy-or-refile folder))
3383 ;; learn for refile.
3384 (if (string= "refile" copy-or-refile)
3385 (wl-refile-learn entity folder))
3386 (wl-summary-unmark msg-num)
3387 (set variable (append
3388 (symbol-value variable)
3389 (list (cons msg-num folder))))
3390 (when (or interactive
3391 (eq number buffer-num))
3392 (wl-summary-mark-line (if (string= "refile" copy-or-refile)
3394 ;; print refile destination
3395 (wl-summary-print-destination msg-num folder))
3397 (if (eq wl-summary-move-direction-downward nil)
3400 (run-hooks (intern (format "wl-summary-%s-hook" copy-or-refile)))
3401 (setq wl-summary-buffer-prev-refile-destination folder)
3404 (defun wl-summary-refile-prev-destination ()
3405 "Refile message to previously refiled destination"
3407 (wl-summary-refile wl-summary-buffer-prev-refile-destination
3408 (wl-summary-message-number))
3409 (if (eq wl-summary-move-direction-downward nil)
3413 (defun wl-summary-copy-prev-destination ()
3414 "Refile message to previously refiled destination"
3416 (wl-summary-copy wl-summary-buffer-prev-copy-destination
3417 (wl-summary-message-number))
3418 (if (eq wl-summary-move-direction-downward nil)
3422 (defsubst wl-summary-no-auto-refile-message-p (msg mark-alist)
3423 (member (cadr (assq msg mark-alist)) wl-summary-auto-refile-skip-marks))
3425 (defun wl-summary-auto-refile (&optional open-all)
3426 "Set refile mark automatically according to wl-refile-guess-by-rule."
3428 (message "Marking...")
3430 (if (and (eq wl-summary-buffer-view 'thread)
3432 (wl-thread-open-all))
3433 (let* ((spec wl-summary-buffer-folder-name)
3434 (overview (elmo-msgdb-get-overview
3435 wl-summary-buffer-msgdb))
3436 (mark-alist (elmo-msgdb-get-mark-alist
3437 wl-summary-buffer-msgdb))
3440 number dst thr-entity)
3443 (setq number (wl-summary-message-number))
3444 (when (and (not (wl-summary-no-auto-refile-message-p number
3447 (wl-refile-guess-by-rule
3448 (elmo-msgdb-overview-get-entity-by-number
3450 (not (equal dst spec)))
3451 (when (not (member dst checked-dsts))
3452 (wl-folder-confirm-existence dst)
3453 (setq checked-dsts (cons dst checked-dsts)))
3454 (if (wl-summary-refile dst number)
3456 (message "Marking...%d message(s)." count))
3457 (if (eq wl-summary-buffer-view 'thread)
3458 ;; process invisible children.
3459 (if (not (wl-thread-entity-get-opened
3460 (setq thr-entity (wl-thread-get-entity number))))
3464 (when (and (setq dst
3465 (wl-refile-guess-by-rule
3466 (elmo-msgdb-overview-get-entity-by-number
3468 (not (equal dst spec)))
3469 (if (wl-summary-refile dst x)
3471 (message "Marking...%d message(s)." count))))
3473 (function (lambda (x)
3474 (wl-summary-no-auto-refile-message-p
3477 (wl-thread-entity-get-descendant thr-entity)))))
3480 (message "No message was marked.")
3481 (message "Marked %d message(s)." count)))))
3483 (defun wl-summary-unmark (&optional number)
3484 "Unmark marks (temporary, refile, copy, delete)of current line.
3485 If optional argument NUMBER is specified, unmark message specified by NUMBER."
3489 (let ((inhibit-read-only t)
3490 (buffer-read-only nil)
3496 (setq visible (wl-summary-jump-to-msg number))
3498 ;; Delete mark on buffer.
3500 (looking-at "^ *\\([0-9]+\\)\\([^0-9]\\)"))
3501 (goto-char (match-end 2))
3503 (setq number (string-to-int (wl-match-buffer 1))))
3504 (setq cur-mark (wl-match-buffer 2))
3505 (if (string= cur-mark " ")
3507 (delete-region (match-beginning 2) (match-end 2))
3508 (if (setq score-mark (wl-summary-get-score-mark number))
3511 (if (or (string= cur-mark "o")
3512 (string= cur-mark "O"))
3513 (wl-summary-remove-destination))
3514 (if wl-summary-highlight
3515 (wl-highlight-summary-current-line nil nil score-mark))
3516 (set-buffer-modified-p nil))
3517 ;; Remove from temporary mark structure.
3519 (wl-summary-delete-mark number)))))
3521 (defun wl-summary-msg-marked-as-target (msg)
3522 (if (memq msg wl-summary-buffer-target-mark-list)
3525 (defun wl-summary-msg-marked-as-copied (msg)
3526 (assq msg wl-summary-buffer-copy-list))
3528 (defun wl-summary-msg-marked-as-deleted (msg)
3529 (if (memq msg wl-summary-buffer-delete-list)
3532 (defun wl-summary-msg-marked-as-refiled (msg)
3533 (assq msg wl-summary-buffer-refile-list))
3535 (defun wl-summary-target-mark (&optional number)
3536 "Put target mark '*' on current message.
3537 If optional argument NUMBER is specified, mark message specified by NUMBER."
3539 (let* ((buffer-num (wl-summary-message-number))
3540 (msg-num (or number buffer-num))
3543 (when (null msg-num)
3545 (message "No message."))
3547 (when (setq mark (wl-summary-get-mark msg-num))
3548 (when (wl-summary-reserve-temp-mark-p mark)
3550 (error "Already marked as `%s'" mark))
3552 (wl-summary-unmark msg-num))
3553 (if (or (interactive-p)
3554 (eq number buffer-num))
3555 (wl-summary-mark-line "*"))
3556 (setq wl-summary-buffer-target-mark-list
3557 (cons msg-num wl-summary-buffer-target-mark-list))
3559 (if (eq wl-summary-move-direction-downward nil)
3565 (defun wl-summary-refile-region (beg end)
3566 "Put copy mark on messages in the region specified by BEG and END."
3568 (wl-summary-refile-region-subr "refile" beg end))
3570 (defun wl-summary-copy-region (beg end)
3571 "Put copy mark on messages in the region specified by BEG and END."
3573 (wl-summary-refile-region-subr "copy" beg end))
3575 (defun wl-summary-refile-region-subr (copy-or-refile beg end)
3579 ;; guess by first msg
3580 (let* ((msgid (cdr (assq (wl-summary-message-number)
3581 (elmo-msgdb-get-number-alist
3582 wl-summary-buffer-msgdb))))
3583 (function (intern (format "wl-summary-%s" copy-or-refile)))
3584 (entity (assoc msgid (elmo-msgdb-get-overview
3585 wl-summary-buffer-msgdb)))
3588 (setq folder (wl-summary-read-folder (wl-refile-guess entity)
3591 (narrow-to-region beg end)
3592 (if (eq wl-summary-buffer-view 'thread)
3595 (let* ((number (wl-summary-message-number))
3596 (entity (wl-thread-get-entity number))
3598 (if (wl-thread-entity-get-opened entity)
3599 ;; opened...refile line.
3600 (funcall function folder number)
3605 (funcall function folder x)))
3606 (wl-thread-get-children-msgs number)))
3609 (funcall function folder (wl-summary-message-number))
3610 (forward-line 1)))))))
3612 (defun wl-summary-unmark-region (beg end)
3616 (narrow-to-region beg end)
3617 (goto-char (point-min))
3618 (if (eq wl-summary-buffer-view 'thread)
3621 (let* ((number (wl-summary-message-number))
3622 (entity (wl-thread-get-entity number)))
3623 (if (wl-thread-entity-get-opened entity)
3624 ;; opened...unmark line.
3629 (wl-thread-get-children-msgs number))))
3633 (forward-line 1))))))
3635 (defun wl-summary-mark-region-subr (function beg end)
3638 (narrow-to-region beg end)
3639 (goto-char (point-min))
3640 (if (eq wl-summary-buffer-view 'thread)
3643 (let* ((number (wl-summary-message-number))
3644 (entity (wl-thread-get-entity number))
3645 (wl-summary-move-direction-downward t))
3646 (if (wl-thread-entity-get-opened entity)
3647 ;; opened...delete line.
3648 (funcall function number)
3652 (wl-thread-get-children-msgs number)))
3655 (funcall function (wl-summary-message-number))
3656 (forward-line 1))))))
3658 (defun wl-summary-delete-region (beg end)
3660 (wl-summary-mark-region-subr 'wl-summary-delete beg end))
3662 (defun wl-summary-target-mark-region (beg end)
3664 (wl-summary-mark-region-subr 'wl-summary-target-mark beg end))
3666 (defun wl-summary-target-mark-all ()
3668 (wl-summary-target-mark-region (point-min) (point-max))
3669 (setq wl-summary-buffer-target-mark-list
3671 (elmo-msgdb-get-number-alist wl-summary-buffer-msgdb))))
3673 (defun wl-summary-delete-all-mark (mark)
3674 (goto-char (point-min))
3675 (let ((case-fold-search nil))
3676 (while (re-search-forward (format "^ *[0-9]+%s"
3677 (regexp-quote mark)) nil t)
3678 (wl-summary-unmark))
3679 (cond ((string= mark "*")
3680 (setq wl-summary-buffer-target-mark-list nil))
3682 (setq wl-summary-buffer-delete-list nil))
3684 (setq wl-summary-buffer-copy-list nil))
3686 (setq wl-summary-buffer-refile-list nil)))))
3688 (defun wl-summary-unmark-all ()
3689 "Unmark all according to what you input."
3691 (let ((unmarks (string-to-char-list (read-from-minibuffer "Unmark: ")))
3695 (setq cur-mark (char-to-string (car unmarks)))
3696 (wl-summary-delete-all-mark cur-mark)
3697 (setq unmarks (cdr unmarks))))))
3699 (defun wl-summary-target-mark-thread ()
3703 (wl-summary-goto-top-of-current-thread)
3704 (wl-thread-force-open)
3707 (wl-summary-goto-bottom-of-current-thread)
3711 (wl-summary-target-mark-region beg end)))
3713 (defun wl-summary-target-mark-msgs (msgs)
3715 (if (eq wl-summary-buffer-view 'thread)
3716 (wl-thread-jump-to-msg (car msgs))
3717 (wl-summary-jump-to-msg (car msgs)))
3718 (wl-summary-target-mark (wl-summary-message-number))
3719 (setq msgs (cdr msgs))))
3721 (defun wl-summary-pick (&optional from-list delete-marks)
3724 (let* ((completion-ignore-case t)
3725 (field (completing-read
3726 (format "Field name (%s): " wl-summary-pick-field-default)
3728 (append '("From" "Subject" "Date"
3729 "To" "Cc" "Body" "Since" "Before")
3730 elmo-msgdb-extra-fields))))
3731 (field (if (string= field "")
3732 (setq field wl-summary-pick-field-default)
3734 (value (if (string-match field "Since\\|Before")
3735 (completing-read "Value: "
3738 (list (format "%s" (car x)))))
3739 elmo-date-descriptions))
3740 (read-from-minibuffer "Value: ")))
3741 (overview (elmo-msgdb-get-overview wl-summary-buffer-msgdb))
3742 (number-alist (elmo-msgdb-get-number-alist wl-summary-buffer-msgdb))
3743 (elmo-search-mime-charset wl-search-mime-charset)
3745 result get-func sum)
3747 (let ((mlist wl-summary-buffer-target-mark-list))
3749 (when (wl-summary-jump-to-msg (car mlist))
3750 (wl-summary-unmark))
3751 (setq mlist (cdr mlist)))
3752 (setq wl-summary-buffer-target-mark-list nil)))
3753 (setq field (downcase field))
3755 ((string-match field "from")
3756 (setq get-func 'elmo-msgdb-overview-entity-get-from))
3757 ((string-match field "subject")
3758 (setq get-func 'elmo-msgdb-overview-entity-get-subject))
3759 ((string-match field "date")
3760 (setq get-func 'elmo-msgdb-overview-entity-get-date))
3761 ((string-match field "to")
3762 (setq get-func 'elmo-msgdb-overview-entity-get-to))
3763 ((string-match field "cc")
3764 (setq get-func 'elmo-msgdb-overview-entity-get-cc))
3765 ((string-match field "since")
3766 (setq server-side-search (vector 'date "since" value)))
3767 ((string-match field "before")
3768 (setq server-side-search (vector 'date "before" value)))
3769 ((string-match field "body")
3770 (setq server-side-search (vector 'match "body" value)))
3771 ((member field elmo-msgdb-extra-fields)
3774 (elmo-msgdb-overview-entity-get-extra-field entity field))))
3776 (error "Pick by %s is not supported" field)))
3778 (if server-side-search
3780 (message "Searching...")
3781 (let ((elmo-mime-charset wl-summary-buffer-mime-charset))
3782 (setq result (elmo-search wl-summary-buffer-folder-name
3783 (list server-side-search))))
3785 (setq result (elmo-list-filter from-list result)))
3786 (message "%d message(s) are picked." (length result)))
3788 (message "Searching...")
3790 (when (and (string-match value
3792 (funcall get-func (car overview))
3796 (elmo-msgdb-overview-entity-get-number
3797 (car overview)) from-list)))
3801 (elmo-msgdb-overview-entity-get-number
3803 (message "Picked %d message(s)." (setq sum (+ sum 1))))
3804 (setq overview (cdr overview)))
3805 (message "%d message(s) are picked." sum))
3807 (message "No message was picked.")
3808 (wl-summary-target-mark-msgs result))))))
3810 (defun wl-summary-unvirtual ()
3811 "Exit from current virtual folder."
3814 (elmo-folder-get-type wl-summary-buffer-folder-name))
3815 (wl-summary-goto-folder-subr (nth 2 (elmo-folder-get-spec
3816 wl-summary-buffer-folder-name))
3818 (error "This folder is not filtered")))
3820 (defun wl-summary-virtual (&optional arg)
3821 "Goto virtual folder."
3824 (wl-summary-unvirtual)
3825 (let* ((completion-ignore-case t)
3826 (field (completing-read (format "Field name (%s): "
3827 wl-summary-pick-field-default)
3829 ("Subject" . "Subject")
3834 ("Before" . "Before"))))
3835 (value (read-from-minibuffer "Value: ")))
3836 (if (string= field "")
3837 (setq field wl-summary-pick-field-default))
3838 (wl-summary-goto-folder-subr (concat "/" (downcase field) "=" value "/"
3839 wl-summary-buffer-folder-name)
3840 'update nil nil t))))
3842 (defun wl-summary-delete-all-temp-marks ()
3845 (goto-char (point-min))
3846 (message "Unmarking...")
3850 (message "Unmarking...done.")
3851 (setq wl-summary-buffer-target-mark-list nil)
3852 (setq wl-summary-buffer-delete-list nil)
3853 (setq wl-summary-buffer-refile-list nil)
3854 (setq wl-summary-buffer-copy-list nil)))
3856 (defun wl-summary-delete-mark (number)
3857 "Delete temporary mark of the message specified by NUMBER."
3859 ((memq number wl-summary-buffer-target-mark-list)
3860 (setq wl-summary-buffer-target-mark-list
3861 (delq number wl-summary-buffer-target-mark-list)))
3862 ((memq number wl-summary-buffer-delete-list)
3863 (setq wl-summary-buffer-delete-list
3864 (delq number wl-summary-buffer-delete-list)))
3868 ((setq pair (assq number wl-summary-buffer-copy-list))
3869 (setq wl-summary-buffer-copy-list
3870 (delq pair wl-summary-buffer-copy-list)))
3871 ((setq pair (assq number wl-summary-buffer-refile-list))
3872 (setq wl-summary-buffer-refile-list
3873 (delq pair wl-summary-buffer-refile-list))))))))
3875 (defun wl-summary-mark-line (mark)
3876 "Put MARK on current line. Returns message number."
3879 (let ((inhibit-read-only t)
3880 (buffer-read-only nil)
3883 (when (looking-at "^ *\\([0-9]+\\)\\([^0-9]\\)")
3884 (setq msg-num (string-to-int (wl-match-buffer 1)))
3885 (setq cur-mark (wl-match-buffer 2))
3886 (goto-char (match-end 1))
3887 (delete-region (match-beginning 2) (match-end 2))
3888 ;(wl-summary-delete-mark msg-num)
3890 (if wl-summary-highlight
3891 (wl-highlight-summary-current-line nil nil t))
3892 (set-buffer-modified-p nil)
3895 (defun wl-summary-target-mark-delete ()
3898 (goto-char (point-min))
3899 (let ((regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
3901 (while (re-search-forward regexp nil t)
3902 (let (wl-summary-buffer-disp-msg)
3903 (when (setq number (wl-summary-message-number))
3904 (wl-summary-delete number)
3905 (setq wl-summary-buffer-target-mark-list
3906 (delq number wl-summary-buffer-target-mark-list)))))
3907 (setq mlist wl-summary-buffer-target-mark-list)
3909 (wl-append wl-summary-buffer-delete-list (list (car mlist)))
3910 (setq wl-summary-buffer-target-mark-list
3911 (delq (car mlist) wl-summary-buffer-target-mark-list))
3912 (setq mlist (cdr mlist))))))
3914 (defun wl-summary-target-mark-prefetch ()
3917 (let* ((mlist (nreverse wl-summary-buffer-target-mark-list))
3918 (inhibit-read-only t)
3919 (buffer-read-only nil)
3921 (length (length mlist))
3926 (setq new-mark (wl-summary-prefetch-msg (car mlist)))
3929 (message "Prefetching... %d/%d message(s)"
3930 (setq count (+ 1 count)) length)
3931 (when (wl-summary-jump-to-msg (car mlist))
3934 (when (looking-at "^ *[0-9]+[^0-9]\\([^0-9]\\)")
3935 (delete-region (match-beginning 1) (match-end 1)))
3936 (goto-char (match-beginning 1))
3938 (if wl-summary-highlight
3939 (wl-highlight-summary-current-line))
3943 (setq skipped (cons (car mlist) skipped)))
3944 (setq mlist (cdr mlist)))
3945 (setq wl-summary-buffer-target-mark-list skipped)
3946 (message "Prefetching... %d/%d message(s)." count length)
3947 (set-buffer-modified-p nil))))
3949 (defun wl-summary-target-mark-refile-subr (copy-or-refile)
3951 (intern (format "wl-summary-buffer-%s-list" copy-or-refile)))
3953 (intern (format "wl-summary-%s" copy-or-refile)))
3954 regexp number msgid entity folder mlist)
3956 (goto-char (point-min))
3957 (setq regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
3958 ;; guess by first mark
3959 (when (re-search-forward regexp nil t)
3960 (setq msgid (cdr (assq (setq number (wl-summary-message-number))
3961 (elmo-msgdb-get-number-alist
3962 wl-summary-buffer-msgdb)))
3964 (elmo-msgdb-get-overview
3965 wl-summary-buffer-msgdb)))
3967 (error "Cannot %s" copy-or-refile))
3969 (setq folder (wl-summary-read-folder
3970 (wl-refile-guess entity)
3971 (format "for %s" copy-or-refile)))
3974 (setq wl-summary-buffer-target-mark-list
3975 (delq number wl-summary-buffer-target-mark-list)))
3976 (while (re-search-forward regexp nil t)
3977 (let (wl-summary-buffer-disp-msg)
3978 (when (setq number (wl-summary-message-number))
3979 (funcall function folder number)
3980 (setq wl-summary-buffer-target-mark-list
3981 (delq number wl-summary-buffer-target-mark-list)))))
3982 ;; process invisible messages.
3983 (setq mlist wl-summary-buffer-target-mark-list)
3986 (append (symbol-value variable)
3987 (list (cons (car mlist) folder))))
3988 (setq wl-summary-buffer-target-mark-list
3989 (delq (car mlist) wl-summary-buffer-target-mark-list))
3990 (setq mlist (cdr mlist)))))))
3992 (defun wl-summary-target-mark-copy ()
3994 (wl-summary-target-mark-refile-subr "copy"))
3996 (defun wl-summary-target-mark-refile ()
3998 (wl-summary-target-mark-refile-subr "refile"))
4000 (defun wl-summary-target-mark-mark-as-read ()
4003 (goto-char (point-min))
4004 (let ((regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
4005 (inhibit-read-only t)
4006 (buffer-read-only nil)
4008 (while (re-search-forward regexp nil t)
4009 (let (wl-summary-buffer-disp-msg)
4010 ;; delete target-mark from buffer.
4011 (delete-region (match-beginning 1) (match-end 1))
4013 (setq number (wl-summary-mark-as-read t))
4014 (if wl-summary-highlight
4015 (wl-highlight-summary-current-line))
4017 (setq wl-summary-buffer-target-mark-list
4018 (delq number wl-summary-buffer-target-mark-list)))))
4019 (setq mlist wl-summary-buffer-target-mark-list)
4021 (wl-thread-msg-mark-as-read (car mlist))
4022 (setq wl-summary-buffer-target-mark-list
4023 (delq (car mlist) wl-summary-buffer-target-mark-list))
4024 (setq mlist (cdr mlist)))
4025 (wl-summary-count-unread
4026 (elmo-msgdb-get-mark-alist wl-summary-buffer-msgdb))
4027 (wl-summary-update-modeline))))
4029 (defun wl-summary-target-mark-mark-as-unread ()
4032 (goto-char (point-min))
4033 (let ((regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
4034 (inhibit-read-only t)
4035 (buffer-read-only nil)
4037 (while (re-search-forward regexp nil t)
4038 (let (wl-summary-buffer-disp-msg)
4039 ;; delete target-mark from buffer.
4040 (delete-region (match-beginning 1) (match-end 1))
4042 (setq number (wl-summary-mark-as-unread))
4043 (if wl-summary-highlight
4044 (wl-highlight-summary-current-line))
4046 (setq wl-summary-buffer-target-mark-list
4047 (delq number wl-summary-buffer-target-mark-list)))))
4048 (setq mlist wl-summary-buffer-target-mark-list)
4050 (wl-summary-mark-as-unread (car mlist))
4051 (wl-thread-msg-mark-as-unread (car mlist))
4052 (setq wl-summary-buffer-target-mark-list
4053 (delq (car mlist) wl-summary-buffer-target-mark-list))
4054 (setq mlist (cdr mlist)))
4055 (wl-summary-count-unread
4056 (elmo-msgdb-get-mark-alist wl-summary-buffer-msgdb))
4057 (wl-summary-update-modeline))))
4059 (defun wl-summary-target-mark-mark-as-important ()
4062 (goto-char (point-min))
4063 (let ((regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
4064 (inhibit-read-only t)
4065 (buffer-read-only nil)
4067 (while (re-search-forward regexp nil t)
4068 (let (wl-summary-buffer-disp-msg)
4069 ;; delete target-mark from buffer.
4070 (delete-region (match-beginning 1) (match-end 1))
4072 (setq number (wl-summary-mark-as-important))
4073 (if wl-summary-highlight
4074 (wl-highlight-summary-current-line))
4076 (setq wl-summary-buffer-target-mark-list
4077 (delq number wl-summary-buffer-target-mark-list)))))
4078 (setq mlist wl-summary-buffer-target-mark-list)
4080 (wl-summary-mark-as-important (car mlist))
4081 (wl-thread-msg-mark-as-important (car mlist))
4082 (setq wl-summary-buffer-target-mark-list
4083 (delq (car mlist) wl-summary-buffer-target-mark-list))
4084 (setq mlist (cdr mlist)))
4085 (wl-summary-count-unread
4086 (elmo-msgdb-get-mark-alist wl-summary-buffer-msgdb))
4087 (wl-summary-update-modeline))))
4089 (defun wl-summary-target-mark-save ()
4092 (goto-char (point-min))
4094 (wl-read-directory-name "Save to directory: " wl-tmp-dir))
4095 (regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
4097 (if (null (file-exists-p wl-save-dir))
4098 (make-directory wl-save-dir))
4099 (while (re-search-forward regexp nil t)
4100 (let (wl-summary-buffer-disp-msg)
4101 (setq number (wl-summary-save t wl-save-dir))
4104 (setq wl-summary-buffer-target-mark-list
4105 (delq number wl-summary-buffer-target-mark-list))))))))
4107 (defun wl-summary-target-mark-pick ()
4109 (wl-summary-pick wl-summary-buffer-target-mark-list 'delete))
4111 (defun wl-summary-mark-as-read (&optional notcrosses
4112 leave-server-side-mark-untouched
4119 (inhibit-read-only t)
4120 (buffer-read-only nil)
4121 (folder wl-summary-buffer-folder-name)
4122 (msgdb wl-summary-buffer-msgdb)
4123 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
4124 ;;(number-alist (elmo-msgdb-get-number-alist msgdb))
4125 (case-fold-search nil)
4126 mark unread visible uncached new-mark)
4129 (setq visible (wl-summary-jump-to-msg number))
4130 (setq mark (cadr (assq number mark-alist))))
4133 (if (or (not visible)
4135 (format "^ *\\([0-9]+\\)[^0-9]\\(%s\\|%s\\|%s\\|%s\\).*$"
4136 (regexp-quote wl-summary-read-uncached-mark)
4137 (regexp-quote wl-summary-unread-uncached-mark)
4138 (regexp-quote wl-summary-unread-cached-mark)
4139 (regexp-quote wl-summary-new-mark))))
4141 (setq mark (or mark (wl-match-buffer 2)))
4144 ((string= mark wl-summary-new-mark) ; N
4145 (setq wl-summary-buffer-new-count
4146 (- wl-summary-buffer-new-count 1))
4149 ((string= mark wl-summary-unread-uncached-mark) ; U
4150 (setq wl-summary-buffer-unread-count
4151 (- wl-summary-buffer-unread-count 1))
4154 ((string= mark wl-summary-unread-cached-mark) ; !
4155 (setq wl-summary-buffer-unread-count
4156 (- wl-summary-buffer-unread-count 1))
4159 ;; no need to mark server.
4160 (setq leave-server-side-mark-untouched t)))
4161 (wl-summary-update-modeline)
4162 (wl-folder-update-unread
4164 (+ wl-summary-buffer-unread-count
4165 wl-summary-buffer-new-count)))
4166 (setq number (or number (string-to-int (wl-match-buffer 1))))
4167 ;; set server side mark...
4168 (setq new-mark (if (and uncached no-cache)
4169 wl-summary-read-uncached-mark
4171 (if (not leave-server-side-mark-untouched)
4172 (elmo-mark-as-read folder
4173 (list number) msgdb))
4175 (goto-char (match-end 2))
4176 (delete-region (match-beginning 2) (match-end 2))
4177 (insert (or new-mark " ")))
4179 (elmo-msgdb-mark-set mark-alist number new-mark))
4180 (elmo-msgdb-set-mark-alist msgdb mark-alist)
4181 (wl-summary-set-mark-modified)
4182 (if (and visible wl-summary-highlight)
4183 (wl-highlight-summary-current-line nil nil t))
4184 (if (not notcrosses)
4185 (wl-summary-set-crosspost nil (and wl-summary-buffer-disp-msg
4186 (interactive-p))))))
4187 (set-buffer-modified-p nil)
4189 (run-hooks 'wl-summary-unread-message-hook))
4190 number ;return value
4193 (defun wl-summary-mark-as-important (&optional number
4197 (if (eq (elmo-folder-get-type wl-summary-buffer-folder-name)
4199 (error "Cannot process mark in this folder"))
4202 (inhibit-read-only t)
4203 (buffer-read-only nil)
4204 (folder wl-summary-buffer-folder-name)
4205 (msgdb wl-summary-buffer-msgdb)
4206 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
4207 (number-alist (elmo-msgdb-get-number-alist msgdb))
4211 (setq visible (wl-summary-jump-to-msg number))
4212 (setq mark (or mark (cadr (assq number mark-alist)))))
4217 (re-search-backward (concat "^" wl-summary-buffer-number-regexp
4218 "..../..") nil t)) ; set cursor line
4220 (if (re-search-forward "^ *\\([0-9]+\\)[^0-9]\\([^0-9]\\)" eol t)
4222 (setq number (or number (string-to-int (wl-match-buffer 1))))
4223 (setq mark (or mark (wl-match-buffer 2)))
4224 (setq message-id (cdr (assq number number-alist)))
4225 (if (string= mark wl-summary-important-mark)
4228 (unless no-server-update
4229 (elmo-unmark-important folder (list number) msgdb)
4230 (elmo-msgdb-global-mark-delete message-id))
4232 (delete-region (match-beginning 2) (match-end 2))
4235 (elmo-msgdb-mark-set mark-alist
4239 (unless no-server-update
4240 (elmo-mark-as-important folder (list number) msgdb))
4242 (delete-region (match-beginning 2) (match-end 2))
4243 (insert wl-summary-important-mark))
4245 (elmo-msgdb-mark-set mark-alist
4246 (string-to-int (wl-match-buffer 1))
4247 wl-summary-important-mark))
4248 ;; Force cache message!!
4250 (unless (elmo-cache-exists-p message-id)
4251 (elmo-force-cache-msg folder number message-id
4252 (elmo-msgdb-get-location msgdb))))
4253 (unless no-server-update
4254 (elmo-msgdb-global-mark-set message-id
4255 wl-summary-important-mark)))
4256 (elmo-msgdb-set-mark-alist msgdb mark-alist)
4257 (wl-summary-set-mark-modified)))
4258 (if (and visible wl-summary-highlight)
4259 (wl-highlight-summary-current-line nil nil t))))
4260 (set-buffer-modified-p nil)
4263 (defsubst wl-summary-format-date (date-string)
4265 (let ((datevec (timezone-fix-time date-string nil
4266 wl-summary-fix-timezone)))
4267 (format "%02d/%02d(%s)%02d:%02d"
4270 (elmo-date-get-week (aref datevec 0)
4275 (error "??/??(??)??:??")))
4277 (defun wl-summary-overview-create-summary-line (msg
4284 temp-mark thr-entity
4286 (let ((wl-mime-charset wl-summary-buffer-mime-charset)
4287 (elmo-mime-charset wl-summary-buffer-mime-charset)
4288 no-parent before-indent
4289 from subject parent-raw-subject parent-subject
4291 (elmo-lang wl-summary-buffer-weekday-name-lang)
4292 (children-num (if children-num (int-to-string children-num)))
4295 (setq thr-str (wl-thread-make-indent-string thr-entity)))
4296 (if (string= thr-str "")
4297 (setq no-parent t)) ; no parent
4298 (if (and wl-summary-width
4299 wl-summary-indent-length-limit
4300 (< wl-summary-indent-length-limit
4301 (string-width thr-str)))
4302 (setq thr-str (wl-set-string-width
4303 wl-summary-indent-length-limit
4306 (wl-set-string-width
4308 (- wl-from-width (length children-num) 2)
4310 (elmo-delete-char ?\n
4311 (wl-summary-from-func-internal
4312 (elmo-msgdb-overview-entity-get-from entity)))))
4314 (elmo-delete-char ?\n
4315 (or (elmo-msgdb-overview-entity-get-subject
4317 wl-summary-no-subject-message)))
4318 (setq parent-raw-subject
4319 (elmo-msgdb-overview-entity-get-subject parent-entity))
4320 (setq parent-subject
4321 (if parent-raw-subject
4322 (elmo-delete-char ?\n parent-raw-subject)))
4323 (setq mark (or (cadr (assq msg mark-alist)) " "))
4329 wl-summary-buffer-number-column)
4334 (wl-summary-format-date
4335 (elmo-msgdb-overview-entity-get-date entity))
4336 (if thr-str thr-str "")))
4339 (concat "+" children-num ": " from)
4342 (null parent-subject)
4343 (not (wl-summary-subject-equal
4344 subject parent-subject)))
4345 (wl-summary-subject-func-internal subject) ""))))
4346 (if wl-summary-width (setq line
4347 (wl-set-string-width
4348 (- wl-summary-width 1) line)))
4349 (if wl-summary-highlight
4350 (wl-highlight-summary-line-string line
4356 (defsubst wl-summary-buffer-number-column-detect (update)
4359 (setq wl-summary-buffer-number-column
4362 (setq end (if (re-search-forward "^ *[0-9]+[^0-9]" nil t)
4364 (- end (progn (beginning-of-line) (point)) 1))
4365 (wl-get-assoc-list-value wl-summary-number-column-alist
4366 wl-summary-buffer-folder-name)
4367 wl-summary-default-number-column))
4368 (setq wl-summary-buffer-number-regexp
4369 (wl-repeat-string "." wl-summary-buffer-number-column)))))
4371 (defsubst wl-summary-proc-wday (wday-str year month mday)
4373 (if (string-match "\\([A-Z][a-z][a-z]\\).*" wday-str)
4374 (wl-match-string 1 wday-str)
4375 (elmo-date-get-week year month mday))))
4377 (defmacro wl-summary-cursor-move-regex ()
4378 (` (let ((mark-alist
4379 (if (elmo-folder-plugged-p wl-summary-buffer-folder-name)
4380 (cond ((eq wl-summary-move-order 'new)
4383 wl-summary-new-mark)
4385 wl-summary-unread-uncached-mark
4386 wl-summary-unread-cached-mark
4387 wl-summary-important-mark)))
4388 ((eq wl-summary-move-order 'unread)
4391 wl-summary-unread-uncached-mark
4392 wl-summary-unread-cached-mark
4393 wl-summary-new-mark)
4395 wl-summary-important-mark)))
4399 wl-summary-unread-uncached-mark
4400 wl-summary-unread-cached-mark
4402 wl-summary-important-mark))))
4403 (cond ((eq wl-summary-move-order 'unread)
4406 wl-summary-unread-cached-mark)
4408 wl-summary-important-mark)))
4412 wl-summary-unread-cached-mark
4413 wl-summary-important-mark)))))))
4417 (concat wl-summary-message-regexp
4419 (mapconcat 'regexp-quote
4423 wl-summary-message-regexp "\\*")))
4427 ;; Goto unread or important
4429 (defun wl-summary-cursor-up (&optional hereto)
4431 (if (and (not wl-summary-buffer-target-mark-list)
4432 (eq wl-summary-buffer-view 'thread))
4436 (wl-thread-jump-to-prev-unread hereto))
4439 (beginning-of-line))
4440 (let ((case-fold-search nil)
4442 (setq regex-list (wl-summary-cursor-move-regex))
4445 (when (re-search-backward
4450 (setq regex-list (cdr regex-list)))
4452 (throw 'done nil)))))
4455 ;; Goto unread or important
4456 ;; returns t if next message exists in this folder.
4457 (defun wl-summary-cursor-down (&optional hereto)
4459 (if (and (null wl-summary-buffer-target-mark-list)
4460 (eq wl-summary-buffer-view 'thread))
4461 (wl-thread-jump-to-next-unread hereto)
4465 (let ((case-fold-search nil)
4467 (setq regex-list (wl-summary-cursor-move-regex))
4470 (when (re-search-forward
4475 (setq regex-list (cdr regex-list)))
4477 (throw 'done nil)))))
4479 (defun wl-summary-save-view-cache (&optional keep-current-buffer)
4481 (let* ((dir (elmo-msgdb-expand-path wl-summary-buffer-folder-name))
4482 (cache (expand-file-name wl-summary-cache-file dir))
4483 (view (expand-file-name wl-summary-view-file dir))
4484 ;;(coding-system-for-write wl-cs-cache)
4485 ;;(output-coding-system wl-cs-cache)
4486 (save-view wl-summary-buffer-view)
4487 (tmp-buffer(get-buffer-create " *wl-summary-save-view-cache*"))
4489 (if (file-directory-p dir)
4491 (if (file-exists-p dir)
4492 (error "File %s already exists" dir)
4493 (elmo-make-directory dir)))
4494 (if (eq save-view 'thread)
4495 (wl-thread-save-entity dir))
4498 (when (file-writable-p cache)
4499 (if keep-current-buffer
4502 (set-buffer tmp-buffer)
4504 (setq charset wl-summary-buffer-mime-charset)
4505 (copy-to-buffer tmp-buffer (point-min) (point-max))
4507 (set-buffer tmp-buffer)
4509 (encode-mime-charset-region
4510 (point-min) (point-max) charset)
4511 (as-binary-output-file
4512 (write-region (point-min)
4513 (point-max) cache nil 'no-msg))))
4514 (let (buffer-read-only)
4516 (encode-mime-charset-region (point-min) (point-max)
4517 wl-summary-buffer-mime-charset)
4518 (as-binary-output-file
4519 (write-region (point-min) (point-max) cache nil 'no-msg)))))
4520 (when (file-writable-p view) ; 'thread or 'sequence
4522 (set-buffer tmp-buffer)
4524 (prin1 save-view tmp-buffer)
4525 (princ "\n" tmp-buffer)
4526 (write-region (point-min) (point-max) view nil 'no-msg))))
4528 (kill-buffer tmp-buffer)))))
4530 (defsubst wl-summary-get-sync-range (folder)
4532 (elmo-folder-plugged-p folder)
4533 (wl-get-assoc-list-value
4534 wl-folder-sync-range-alist
4536 wl-default-sync-range)))
4538 ;; redefined for wl-summary-sync-update
4539 (defun wl-summary-input-range (folder)
4540 "returns update or all or rescan."
4541 ;; for the case when parts are expanded in the bottom of the folder
4542 (let ((input-range-list '("update" "all" "rescan" "first:" "last:"
4543 "no-sync" "rescan-noscore"))
4544 (default (or (wl-get-assoc-list-value
4545 wl-folder-sync-range-alist
4547 wl-default-sync-range))
4550 (completing-read (format "Range (%s): " default)
4552 (function (lambda (x) (cons x x)))
4554 (if (string= range "")
4558 (defun wl-summary-toggle-disp-folder (&optional arg)
4560 (let (fld-buf fld-win
4561 (view-message-buffer (wl-message-get-buffer-create))
4562 (cur-buf (current-buffer))
4563 (summary-win (get-buffer-window (current-buffer))))
4566 (setq wl-summary-buffer-disp-folder t)
4567 ;; hide your folder window
4568 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
4569 (if (setq fld-win (get-buffer-window fld-buf))
4570 (delete-window fld-win))))
4572 (setq wl-summary-buffer-disp-folder nil)
4573 ;; hide your wl-message window!
4574 (wl-select-buffer view-message-buffer)
4576 (select-window (get-buffer-window cur-buf))
4577 ;; display wl-folder window!!
4578 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
4579 (if (setq fld-win (get-buffer-window fld-buf))
4580 ;; folder win is already displayed.
4581 (select-window fld-win)
4582 ;; folder win is not displayed.
4583 (switch-to-buffer fld-buf))
4586 ;; temporarily delete summary-win.
4588 (delete-window summary-win))
4589 (split-window-horizontally wl-folder-window-width)
4591 (switch-to-buffer cur-buf))
4593 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
4594 (if (setq fld-win (get-buffer-window fld-buf))
4595 (setq wl-summary-buffer-disp-folder nil)
4596 (setq wl-summary-buffer-disp-folder t)))
4597 (if (not wl-summary-buffer-disp-folder)
4598 ;; hide message window
4599 (let ((mes-win (get-buffer-window view-message-buffer))
4600 (wl-stay-folder-window t))
4601 (if mes-win (delete-window mes-win))
4602 ;; hide your folder window
4603 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
4604 (if (setq fld-win (get-buffer-window fld-buf))
4606 (delete-window (get-buffer-window cur-buf))
4607 (select-window fld-win)
4608 (switch-to-buffer cur-buf))))
4609 (run-hooks 'wl-summary-toggle-disp-folder-off-hook)
4610 ;; resume message window.
4612 (wl-select-buffer view-message-buffer)
4613 (run-hooks 'wl-summary-toggle-disp-folder-message-resumed-hook)
4614 (select-window (get-buffer-window cur-buf)))
4617 ;; hide message window
4618 (let ((mes-win (get-buffer-window view-message-buffer))
4619 (wl-stay-folder-window t))
4620 (if mes-win (delete-window mes-win))
4621 (select-window (get-buffer-window cur-buf))
4622 ;; display wl-folder window!!
4623 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
4624 (if (setq fld-win (get-buffer-window fld-buf))
4625 ;; folder win is already displayed.
4626 (select-window fld-win)
4627 ;; folder win is not displayed...occupy all.
4628 (switch-to-buffer fld-buf))
4631 (split-window-horizontally wl-folder-window-width)
4633 (switch-to-buffer cur-buf)
4634 ;; resume message window.
4635 (run-hooks 'wl-summary-toggle-disp-folder-on-hook)
4637 (wl-select-buffer view-message-buffer)
4638 (run-hooks 'wl-summary-toggle-disp-folder-message-resumed-hook)
4639 (select-window (get-buffer-window cur-buf))))
4641 (run-hooks 'wl-summary-toggle-disp-folder-hook))
4643 (defun wl-summary-toggle-disp-msg (&optional arg)
4645 (let (fld-buf fld-win
4646 (view-message-buffer (wl-message-get-buffer-create))
4647 (cur-buf (current-buffer))
4651 (setq wl-summary-buffer-disp-msg t)
4652 ;; hide your folder window
4653 (if (and (not wl-stay-folder-window)
4654 (setq fld-buf (get-buffer wl-folder-buffer-name)))
4655 (if (setq fld-win (get-buffer-window fld-buf))
4656 (delete-window fld-win))))
4658 (wl-delete-all-overlays)
4659 (setq wl-summary-buffer-disp-msg nil)
4661 (wl-select-buffer view-message-buffer)
4663 (and (get-buffer-window cur-buf)
4664 (select-window (get-buffer-window cur-buf)))
4665 (run-hooks 'wl-summary-toggle-disp-off-hook)))
4667 (if (get-buffer-window view-message-buffer) ; already displayed
4668 (setq wl-summary-buffer-disp-msg nil)
4669 (setq wl-summary-buffer-disp-msg t))
4670 (if wl-summary-buffer-disp-msg
4672 (wl-summary-redisplay)
4673 ;; hide your folder window
4674 ;; (setq fld-buf (get-buffer wl-folder-buffer-name))
4675 ;; (if (setq fld-win (get-buffer-window fld-buf))
4676 ;; (delete-window fld-win)))
4677 (run-hooks 'wl-summary-toggle-disp-on-hook))
4678 (wl-delete-all-overlays)
4680 (wl-select-buffer view-message-buffer)
4682 (select-window (get-buffer-window cur-buf))
4683 (run-hooks 'wl-summary-toggle-disp-off-hook))
4684 ;;(switch-to-buffer cur-buf)
4687 (defun wl-summary-next-line-content ()
4689 (let ((cur-buf (current-buffer)))
4690 (wl-summary-toggle-disp-msg 'on)
4691 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
4692 (set-buffer cur-buf)
4693 (wl-message-next-page 1))))
4695 (defun wl-summary-prev-line-content ()
4697 (let ((cur-buf (current-buffer)))
4698 (wl-summary-toggle-disp-msg 'on)
4699 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
4700 (set-buffer cur-buf)
4701 (wl-message-prev-page 1))))
4703 (defun wl-summary-next-page ()
4705 (wl-message-next-page))
4707 (defun wl-summary-prev-page ()
4709 (wl-message-prev-page))
4711 (defsubst wl-summary-no-mime-p (folder)
4712 (wl-string-match-member folder wl-summary-no-mime-folder-list))
4714 (defun wl-summary-set-message-buffer-or-redisplay (&optional ignore-original)
4715 ;; if current message is not displayed, display it.
4716 ;; return t if exists.
4717 (let ((folder wl-summary-buffer-folder-name)
4718 (number (wl-summary-message-number))
4719 cur-folder cur-number message-last-pos
4720 (view-message-buffer (wl-message-get-buffer-create)))
4722 (set-buffer view-message-buffer)
4723 (setq cur-folder wl-message-buffer-cur-folder)
4724 (setq cur-number wl-message-buffer-cur-number))
4725 (if (and (not ignore-original)
4727 (and (eq number (wl-message-original-buffer-number))
4728 (string= folder (wl-message-original-buffer-folder)))))
4730 (if (wl-summary-no-mime-p folder)
4731 (wl-summary-redisplay-no-mime folder number)
4732 (wl-summary-redisplay-internal folder number))
4734 (if (and (string= folder (or cur-folder ""))
4735 (eq number (or cur-number 0)))
4737 (set-buffer view-message-buffer)
4739 (if (wl-summary-no-mime-p folder)
4740 (wl-summary-redisplay-no-mime folder number)
4741 (wl-summary-redisplay-internal folder number))
4744 (defun wl-summary-target-mark-forward (&optional arg)
4746 (let ((mlist (nreverse wl-summary-buffer-target-mark-list))
4747 (summary-buf (current-buffer))
4748 (wl-draft-forward t)
4751 (wl-summary-jump-to-msg (car mlist))
4752 (wl-summary-forward t)
4753 (setq start-point (point))
4754 (setq draft-buf (current-buffer))
4755 (setq mlist (cdr mlist))
4756 (save-window-excursion
4759 (set-buffer summary-buf)
4760 (wl-summary-jump-to-msg (car mlist))
4761 (wl-summary-redisplay)
4762 (set-buffer draft-buf)
4763 (goto-char (point-max))
4764 (wl-draft-insert-message)
4765 (setq mlist (cdr mlist)))
4766 (wl-draft-body-goto-top)
4767 (wl-draft-enclose-digest-region (point) (point-max)))
4768 (goto-char start-point)
4770 (set-buffer summary-buf)
4771 (wl-summary-delete-all-temp-marks)))
4772 (run-hooks 'wl-mail-setup-hook)))
4774 (defun wl-summary-target-mark-reply-with-citation (&optional arg)
4776 (let ((mlist (nreverse wl-summary-buffer-target-mark-list))
4777 (summary-buf (current-buffer))
4778 change-major-mode-hook
4781 (wl-summary-jump-to-msg (car mlist))
4782 (wl-summary-reply arg t)
4783 (goto-char (point-max))
4784 (setq start-point (point))
4785 (setq draft-buf (current-buffer))
4786 (save-window-excursion
4788 (set-buffer summary-buf)
4789 (wl-summary-jump-to-msg (car mlist))
4790 (wl-summary-redisplay)
4791 (set-buffer draft-buf)
4792 (goto-char (point-max))
4793 (wl-draft-yank-original)
4794 (setq mlist (cdr mlist)))
4795 (goto-char start-point)
4797 (set-buffer summary-buf)
4798 (wl-summary-delete-all-temp-marks)))
4799 (run-hooks 'wl-mail-setup-hook)))
4801 (defun wl-summary-reply-with-citation (&optional arg)
4804 (wl-summary-reply arg t)
4805 (goto-char (point-max))
4806 (wl-draft-yank-original)
4807 (run-hooks 'wl-mail-setup-hook)))
4809 (defun wl-summary-jump-to-msg-by-message-id (&optional id)
4811 (let* ((original (wl-summary-message-number))
4812 (msgid (elmo-string (or id (read-from-minibuffer "Message-ID: "))))
4813 (number-alist (elmo-msgdb-get-number-alist wl-summary-buffer-msgdb))
4816 (format "No message with id \"%s\" in the folder." msgid)))
4817 (if (setq msg (car (rassoc msgid number-alist)))
4818 ;;(wl-summary-jump-to-msg-internal
4819 ;;wl-summary-buffer-folder-name msg 'no-sync)
4821 (wl-thread-jump-to-msg msg)
4824 (if (and elmo-use-database
4827 "No message with id \"%s\" in the database." msgid))
4828 (setq otherfld (elmo-database-msgid-get msgid)))
4829 (if (cdr (wl-summary-jump-to-msg-internal
4830 (car otherfld) (nth 1 otherfld) 'no-sync))
4832 ;; Back to original.
4833 (wl-summary-jump-to-msg-internal
4834 wl-summary-buffer-folder-name original 'no-sync))
4835 (cond ((eq wl-summary-search-via-nntp 'confirm)
4836 (message "Search message in nntp server \"%s\" <y/n/s(elect)>?"
4837 elmo-default-nntp-server)
4838 (setq schar (read-char))
4839 (cond ((eq schar ?y)
4840 (wl-summary-jump-to-msg-by-message-id-via-nntp msgid))
4842 (wl-summary-jump-to-msg-by-message-id-via-nntp
4844 (read-from-minibuffer "NNTP Server: ")))
4848 (wl-summary-search-via-nntp
4849 (wl-summary-jump-to-msg-by-message-id-via-nntp msgid))
4854 (defun wl-summary-jump-to-msg-by-message-id-via-nntp (&optional id server-spec)
4856 (let* ((msgid (elmo-string (or id (read-from-minibuffer "Message-ID: "))))
4857 newsgroups folder ret
4858 user server port ssl spec)
4860 (if (string-match "^-" server-spec)
4861 (setq spec (elmo-nntp-get-spec server-spec)
4866 (setq server server-spec)))
4867 (when (setq ret (elmo-nntp-get-newsgroup-by-msgid
4869 (or server elmo-default-nntp-server)
4870 (or user elmo-default-nntp-user)
4871 (or port elmo-default-nntp-port)
4872 (or ssl elmo-default-nntp-ssl)))
4873 (setq newsgroups (wl-parse-newsgroups ret))
4874 (setq folder (concat "-" (car newsgroups)
4875 (elmo-nntp-folder-postfix user server port ssl)))
4878 (if (wl-folder-entity-exists-p (car newsgroups)
4879 wl-folder-newsgroups-hashtb)
4881 (setq folder (concat "-" (car newsgroups)
4882 (elmo-nntp-folder-postfix user server port ssl)))))
4883 (setq newsgroups (cdr newsgroups)))))
4885 (wl-summary-jump-to-msg-internal folder nil 'update msgid)
4886 (message "No message id \"%s\" in nntp server \"%s\"."
4887 msgid (or server elmo-default-nntp-server))
4890 (defun wl-summary-jump-to-msg-internal (folder msg scan-type &optional msgid)
4891 (let (wl-auto-select-first entity)
4892 (if (or (string= folder wl-summary-buffer-folder-name)
4895 "Message was found in the folder \"%s\". Jump to it? "
4899 (wl-summary-goto-folder-subr
4900 folder scan-type nil nil t)
4904 (elmo-msgdb-get-number-alist
4905 wl-summary-buffer-msgdb)))))
4906 (setq entity (wl-folder-search-entity-by-name folder
4910 (wl-folder-set-current-entity-id
4911 (wl-folder-get-entity-id entity))))
4913 (message "Message was not found currently in this folder.")
4914 (setq msg (and (wl-thread-jump-to-msg msg) msg)))
4915 (cons folder msg)))))
4917 (defun wl-summary-jump-to-parent-message (arg)
4919 (let ((cur-buf (current-buffer))
4920 (regexp "\\(<[^<>]*>\\)[ \t]*$")
4922 msg-id ref-list ref irt)
4923 (wl-summary-set-message-buffer-or-redisplay)
4924 (set-buffer (wl-message-get-original-buffer))
4925 (message "Searching parent message...")
4926 (setq ref (std11-field-body "References")
4927 irt (std11-field-body "In-Reply-To"))
4929 ((and arg (not (numberp arg)) ref (not (string= ref ""))
4930 (string-match regexp ref))
4931 ;; The first message of the thread.
4932 (setq msg-id (wl-match-string 1 ref)))
4933 ;; "In-Reply-To:" has only one msg-id.
4934 ((and irt (not (string= irt ""))
4935 (string-match regexp irt))
4936 (setq msg-id (wl-match-string 1 irt)))
4937 ((and (or (null arg) (numberp arg)) ref (not (string= ref ""))
4938 (string-match regexp ref))
4939 ;; "^" searching parent, "C-u 2 ^" looking for grandparent.
4940 (while (string-match regexp ref)
4943 (wl-match-string 1 ref))
4945 (setq ref (substring ref (match-end 0)))
4948 (if (null arg) (nth 0 ref-list) ;; previous
4949 (if (<= arg i) (nth (1- arg) ref-list)
4950 (nth i ref-list))))))
4951 (set-buffer cur-buf)
4952 (cond ((null msg-id)
4953 (message "No parent message!")
4955 ((wl-summary-jump-to-msg-by-message-id msg-id)
4956 (wl-summary-redisplay)
4957 (message "Searching parent message...done.")
4960 (message "Parent message was not found.")
4963 (defun wl-summary-reply (&optional arg without-setup-hook)
4964 "Reply to current message. Default is \"wide\" reply.
4965 Reply to author if invoked with argument."
4967 (let ((folder wl-summary-buffer-folder-name)
4968 (number (wl-summary-message-number))
4969 (summary-buf (current-buffer))
4971 (wl-summary-redisplay-internal folder number)
4972 (wl-select-buffer (get-buffer (setq mes-buf (wl-current-message-buffer))))
4973 (set-buffer mes-buf)
4974 (goto-char (point-min))
4975 (or wl-draft-use-frame
4976 (split-window-vertically))
4978 (when (setq mes-buf (wl-message-get-original-buffer))
4979 (wl-draft-reply mes-buf (not arg) summary-buf)
4980 (unless without-setup-hook
4981 (run-hooks 'wl-mail-setup-hook)))))
4983 (defun wl-summary-write ()
4984 "Write a new draft from Summary."
4986 (wl-draft nil nil nil nil nil
4987 nil nil nil nil nil (current-buffer))
4988 (run-hooks 'wl-mail-setup-hook)
4989 (mail-position-on-field "To"))
4991 (defun wl-summary-write-current-newsgroup (&optional folder)
4993 (let* ((folder (or folder wl-summary-buffer-folder-name))
4994 (flist (elmo-folder-get-primitive-folder-list folder))
4996 (while (setq fld (car flist))
4998 (cond ((eq 'nntp (elmo-folder-get-type fld))
4999 (nth 1 (elmo-folder-get-spec fld)))
5000 ((eq 'localnews (elmo-folder-get-type fld))
5001 (elmo-replace-in-string
5002 (nth 1 (elmo-folder-get-spec fld)) "/" "\\."))))
5003 (setq newsgroups (cond (newsgroups
5004 (concat newsgroups "," ret))
5006 (setq flist (cdr flist)))
5009 (wl-draft nil nil nil nil nil newsgroups)
5010 (run-hooks 'wl-mail-setup-hook))
5011 (error "%s is not newsgroup" folder))))
5013 (defun wl-summary-forward (&optional without-setup-hook)
5015 (let ((folder wl-summary-buffer-folder-name)
5016 (number (wl-summary-message-number))
5017 (summary-buf (current-buffer))
5018 (wl-draft-forward t)
5020 (wl-summary-redisplay-internal folder number)
5021 (wl-select-buffer (get-buffer wl-message-buf-name))
5022 (or wl-draft-use-frame
5023 (split-window-vertically))
5025 ;; get original subject.
5028 (set-buffer summary-buf)
5029 (setq num (wl-summary-message-number))
5030 (setq entity (assoc (cdr (assq num
5031 (elmo-msgdb-get-number-alist
5032 wl-summary-buffer-msgdb)))
5033 (elmo-msgdb-get-overview
5034 wl-summary-buffer-msgdb)))
5037 (or (elmo-msgdb-overview-entity-get-subject entity)
5039 (wl-draft-forward subject summary-buf)
5040 (unless without-setup-hook
5041 (run-hooks 'wl-mail-setup-hook))))
5043 (defun wl-summary-click (e)
5048 (defun wl-summary-read ()
5050 (let ((folder wl-summary-buffer-folder-name)
5051 (number (wl-summary-message-number))
5052 cur-folder cur-number message-last-pos
5053 (view-message-buffer (get-buffer-create wl-message-buf-name))
5054 (sticky-buf-name (and (wl-summary-sticky-p) wl-message-buf-name))
5055 (summary-buf-name (buffer-name)))
5057 (set-buffer view-message-buffer)
5058 (when (and sticky-buf-name
5059 (not (wl-local-variable-p 'wl-message-buf-name
5061 (make-local-variable 'wl-message-buf-name)
5062 (setq wl-message-buf-name sticky-buf-name)
5063 (make-local-variable 'wl-message-buffer-cur-summary-buffer)
5064 (setq wl-message-buffer-cur-summary-buffer summary-buf-name))
5065 (setq cur-folder wl-message-buffer-cur-folder)
5066 (setq cur-number wl-message-buffer-cur-number))
5067 (wl-summary-toggle-disp-msg 'on)
5068 (if (and (string= folder cur-folder)
5069 (eq number cur-number))
5071 (if (wl-summary-next-page)
5072 (wl-summary-down t)))
5073 ; (wl-summary-scroll-up-content)))
5074 (if (wl-summary-no-mime-p folder)
5075 (wl-summary-redisplay-no-mime folder number)
5076 (wl-summary-redisplay-internal folder number)))))
5078 (defun wl-summary-prev (&optional interactive)
5080 (if wl-summary-move-direction-toggle
5081 (setq wl-summary-move-direction-downward nil))
5082 (let ((type (elmo-folder-get-type wl-summary-buffer-folder-name))
5083 (skip-mark-regexp (mapconcat
5085 wl-summary-skip-mark-list ""))
5086 goto-next regex-list regex next-entity finfo)
5088 (if (elmo-folder-plugged-p wl-summary-buffer-folder-name)
5089 (setq regex (format "^%s[^%s]"
5090 wl-summary-buffer-number-regexp
5092 (setq regex (format "^%s[^%s]\\(%s\\|%s\\| \\)"
5093 wl-summary-buffer-number-regexp
5095 (regexp-quote wl-summary-unread-cached-mark)
5096 (regexp-quote wl-summary-important-mark))))
5097 (unless (re-search-backward regex nil t)
5102 (if wl-summary-buffer-disp-msg
5103 (wl-summary-redisplay)))
5104 (if (or interactive (interactive-p))
5106 (when wl-auto-select-next
5107 (setq next-entity (wl-summary-get-prev-folder))
5109 (setq finfo (wl-folder-get-entity-info next-entity))))
5111 '(lambda () (wl-summary-next-folder-or-exit next-entity))
5113 "No more messages. Type SPC to go to %s."
5114 (wl-summary-entity-info-msg next-entity finfo))))))))
5116 (defun wl-summary-next (&optional interactive)
5118 (if wl-summary-move-direction-toggle
5119 (setq wl-summary-move-direction-downward t))
5120 (let ((type (elmo-folder-get-type wl-summary-buffer-folder-name))
5121 (skip-mark-regexp (mapconcat
5123 wl-summary-skip-mark-list ""))
5124 goto-next regex regex-list next-entity finfo)
5126 (if (elmo-folder-plugged-p wl-summary-buffer-folder-name)
5127 (setq regex (format "^%s[^%s]"
5128 wl-summary-buffer-number-regexp
5130 (setq regex (format "^%s[^%s]\\(%s\\|%s\\| \\)"
5131 wl-summary-buffer-number-regexp
5133 (regexp-quote wl-summary-unread-cached-mark)
5134 (regexp-quote wl-summary-important-mark))))
5135 (unless (re-search-forward regex nil t)
5140 (if wl-summary-buffer-disp-msg
5141 (wl-summary-redisplay))
5142 (if (or interactive (interactive-p))
5144 (when wl-auto-select-next
5145 (setq next-entity (wl-summary-get-next-folder))
5147 (setq finfo (wl-folder-get-entity-info next-entity))))
5149 '(lambda () (wl-summary-next-folder-or-exit next-entity))
5151 "No more messages. Type SPC to go to %s."
5152 (wl-summary-entity-info-msg next-entity finfo))))))))
5154 (defun wl-summary-up (&optional interactive skip-no-unread)
5156 (if wl-summary-move-direction-toggle
5157 (setq wl-summary-move-direction-downward nil))
5158 (if (wl-summary-cursor-up)
5159 (if wl-summary-buffer-disp-msg
5160 (wl-summary-redisplay))
5163 (let (next-entity finfo)
5164 (when wl-auto-select-next
5166 (setq next-entity (wl-summary-get-prev-unread-folder))
5168 (setq finfo (wl-folder-get-entity-info next-entity)))))
5169 (if (and skip-no-unread
5170 (eq wl-auto-select-next 'skip-no-unread))
5171 (wl-summary-next-folder-or-exit next-entity t)
5173 '(lambda () (wl-summary-next-folder-or-exit next-entity t))
5175 "No more unread messages. Type SPC to go to %s."
5176 (wl-summary-entity-info-msg next-entity finfo))))))))
5178 (defun wl-summary-get-prev-folder ()
5179 (let ((folder-buf (get-buffer wl-folder-buffer-name))
5182 (setq cur-id (save-excursion (set-buffer folder-buf)
5183 wl-folder-buffer-cur-entity-id))
5184 (wl-folder-get-prev-folder cur-id))))
5186 (defun wl-summary-get-next-folder ()
5187 (let ((folder-buf (get-buffer wl-folder-buffer-name))
5190 (setq cur-id (save-excursion (set-buffer folder-buf)
5191 wl-folder-buffer-cur-entity-id))
5192 (wl-folder-get-next-folder cur-id))))
5194 (defun wl-summary-get-next-unread-folder ()
5195 (let ((folder-buf (get-buffer wl-folder-buffer-name))
5198 (setq cur-id (save-excursion (set-buffer folder-buf)
5199 wl-folder-buffer-cur-entity-id))
5200 (wl-folder-get-next-folder cur-id 'unread))))
5202 (defun wl-summary-get-prev-unread-folder ()
5203 (let ((folder-buf (get-buffer wl-folder-buffer-name))
5206 (setq cur-id (save-excursion (set-buffer folder-buf)
5207 wl-folder-buffer-cur-entity-id))
5208 (wl-folder-get-prev-folder cur-id 'unread))))
5210 (defun wl-summary-down (&optional interactive skip-no-unread)
5212 (if wl-summary-move-direction-toggle
5213 (setq wl-summary-move-direction-downward t))
5214 (if (wl-summary-cursor-down)
5215 (if wl-summary-buffer-disp-msg
5216 (wl-summary-redisplay))
5219 (let (next-entity finfo)
5220 (when wl-auto-select-next
5221 (setq next-entity (wl-summary-get-next-unread-folder))
5223 (setq finfo (wl-folder-get-entity-info next-entity))))
5224 (if (and skip-no-unread
5225 (eq wl-auto-select-next 'skip-no-unread))
5226 (wl-summary-next-folder-or-exit next-entity)
5228 '(lambda () (wl-summary-next-folder-or-exit next-entity))
5230 "No more unread messages. Type SPC to go to %s."
5231 (wl-summary-entity-info-msg next-entity finfo))))))))
5233 (defun wl-summary-goto-last-displayed-msg ()
5235 (unless wl-summary-buffer-last-displayed-msg
5236 (setq wl-summary-buffer-last-displayed-msg
5237 wl-summary-buffer-current-msg))
5238 (if wl-summary-buffer-last-displayed-msg
5240 (wl-summary-jump-to-msg wl-summary-buffer-last-displayed-msg)
5241 (if wl-summary-buffer-disp-msg
5242 (wl-summary-redisplay)))
5243 (message "No last message.")))
5245 (defun wl-summary-redisplay (&optional arg)
5248 (wl-summary-no-mime-p wl-summary-buffer-folder-name))
5249 (wl-summary-redisplay-no-mime)
5250 (wl-summary-redisplay-internal nil nil arg)))
5252 (defsubst wl-summary-redisplay-internal (&optional folder number force-reload)
5254 (let* ((msgdb wl-summary-buffer-msgdb)
5255 (fld (or folder wl-summary-buffer-folder-name))
5256 (num (or number (wl-summary-message-number)))
5257 (wl-mime-charset wl-summary-buffer-mime-charset)
5258 (default-mime-charset wl-summary-buffer-mime-charset)
5259 (wl-message-redisplay-func
5260 wl-summary-buffer-message-redisplay-func)
5261 fld-buf fld-win thr-entity)
5262 (if (and wl-thread-open-reading-thread
5263 (eq wl-summary-buffer-view 'thread)
5264 (not (wl-thread-entity-get-opened
5265 (setq thr-entity (wl-thread-get-entity
5267 (wl-thread-entity-get-children thr-entity))
5268 (wl-thread-force-open))
5271 (setq wl-summary-buffer-disp-msg t)
5272 (setq wl-summary-buffer-last-displayed-msg
5273 wl-summary-buffer-current-msg)
5274 ;; hide folder window
5275 (if (and (not wl-stay-folder-window)
5276 (setq fld-buf (get-buffer wl-folder-buffer-name)))
5277 (if (setq fld-win (get-buffer-window fld-buf))
5278 (delete-window fld-win)))
5279 (setq wl-current-summary-buffer (current-buffer))
5280 (if (wl-message-redisplay fld num 'mime msgdb force-reload)
5281 (wl-summary-mark-as-read nil
5282 ;; cached, then change server-mark.
5283 (if wl-message-cache-used
5285 ;; plugged, then leave server-mark.
5286 (if (elmo-folder-plugged-p
5287 wl-summary-buffer-folder-name)
5291 (setq wl-summary-buffer-current-msg num)
5292 (if wl-summary-recenter
5293 (recenter (/ (- (window-height) 2) 2)))
5294 (wl-highlight-summary-displaying)
5295 (wl-cache-prefetch-next fld num (current-buffer))
5296 (run-hooks 'wl-summary-redisplay-hook))
5297 (message "No message to display."))))
5299 (defun wl-summary-redisplay-no-mime (&optional folder number)
5301 (let* ((msgdb wl-summary-buffer-msgdb)
5302 (fld (or folder wl-summary-buffer-folder-name))
5303 (num (or number (wl-summary-message-number)))
5304 (wl-mime-charset wl-summary-buffer-mime-charset)
5305 (default-mime-charset wl-summary-buffer-mime-charset)
5309 (setq wl-summary-buffer-disp-msg t)
5310 (setq wl-current-summary-buffer (current-buffer))
5311 (wl-normal-message-redisplay fld num 'no-mime msgdb)
5312 (wl-summary-mark-as-read nil nil t)
5313 (setq wl-summary-buffer-current-msg num)
5314 (if wl-summary-recenter
5315 (recenter (/ (- (window-height) 2) 2)))
5316 (wl-highlight-summary-displaying)
5317 (run-hooks 'wl-summary-redisplay-hook))
5318 (message "No message to display.")
5319 (wl-ask-folder 'wl-summary-exit
5320 "No more messages. Type SPC to go to folder mode."))))
5322 (defun wl-summary-redisplay-all-header (&optional folder number)
5324 (let* ((msgdb wl-summary-buffer-msgdb)
5325 (fld (or folder wl-summary-buffer-folder-name))
5326 (num (or number (wl-summary-message-number)))
5327 (wl-mime-charset wl-summary-buffer-mime-charset)
5328 (default-mime-charset wl-summary-buffer-mime-charset)
5329 (wl-message-redisplay-func wl-summary-buffer-message-redisplay-func))
5332 (if (wl-message-redisplay fld num 'all-header msgdb); t if displayed.
5333 (wl-summary-mark-as-read nil nil t))
5334 (run-hooks 'wl-summary-redisplay-hook))
5335 (message "No message to display."))))
5337 (defun wl-summary-jump-to-current-message ()
5339 (let (message-buf message-win)
5340 (if (setq message-buf (get-buffer wl-message-buf-name))
5341 (if (setq message-win (get-buffer-window message-buf))
5342 (select-window message-win)
5343 (wl-select-buffer (get-buffer wl-message-buf-name)))
5344 (wl-summary-redisplay)
5345 (wl-select-buffer (get-buffer wl-message-buf-name)))
5346 (goto-char (point-min))))
5348 (defun wl-summary-cancel-message ()
5349 "Cancel an article on news."
5351 (let ((summary-buf (current-buffer))
5353 (wl-summary-set-message-buffer-or-redisplay)
5354 (if (setq message-buf (wl-message-get-original-buffer))
5355 (set-buffer message-buf))
5356 (unless (wl-message-news-p)
5357 (error "This is not a news article; canceling is impossible"))
5358 (when (yes-or-no-p "Do you really want to cancel this article? ")
5359 (let (from newsgroups message-id distribution buf)
5361 (setq from (std11-field-body "from")
5362 newsgroups (std11-field-body "newsgroups")
5363 message-id (std11-field-body "message-id")
5364 distribution (std11-field-body "distribution"))
5365 ;; Make sure that this article was written by the user.
5366 (unless (wl-address-user-mail-address-p
5367 (wl-address-header-extract-address
5368 (car (wl-parse-addresses from))))
5369 (error "This article is not yours"))
5370 ;; Make control message.
5371 (setq buf (set-buffer (get-buffer-create " *message cancel*")))
5372 (setq wl-draft-buffer-cur-summary-buffer summary-buf)
5373 (buffer-disable-undo (current-buffer))
5375 (insert "Newsgroups: " newsgroups "\n"
5376 "From: " (wl-address-header-extract-address
5378 "Subject: cmsg cancel " message-id "\n"
5379 "Control: cancel " message-id "\n"
5381 (concat "Distribution: " distribution "\n")
5383 mail-header-separator "\n"
5384 wl-summary-cancel-message)
5385 (message "Canceling your message...")
5386 (wl-draft-raw-send t t) ; kill when done, force-pre-hooks.
5387 (message "Canceling your message...done"))))))
5389 (defun wl-summary-supersedes-message ()
5390 "Supersede current message."
5392 (let ((summary-buf (current-buffer))
5393 (mmelmo-force-fetch-entire-message t)
5395 (wl-summary-set-message-buffer-or-redisplay)
5396 (if (setq message-buf (wl-message-get-original-buffer))
5397 (set-buffer message-buf))
5398 (unless (wl-message-news-p)
5399 (error "This is not a news article; supersedes is impossible"))
5401 (setq from (std11-field-body "from"))
5402 ;; Make sure that this article was written by the user.
5403 (unless (wl-address-user-mail-address-p
5404 (wl-address-header-extract-address
5405 (car (wl-parse-addresses from))))
5406 (error "This article is not yours"))
5407 (let* ((message-id (std11-field-body "message-id"))
5408 (followup-to (std11-field-body "followup-to"))
5409 (mail-default-headers
5410 (concat mail-default-headers
5411 "Supersedes: " message-id "\n"
5413 (concat "Followup-To: " followup-to "\n")))))
5414 (set-buffer (wl-message-get-original-buffer))
5415 (wl-draft-edit-string (buffer-substring (point-min) (point-max)))))))
5417 (defun wl-summary-save (&optional arg wl-save-dir)
5420 (num (wl-summary-message-number))
5421 (mmelmo-force-fetch-entire-message t))
5422 (if (null wl-save-dir)
5423 (setq wl-save-dir wl-tmp-dir))
5426 (setq filename (expand-file-name
5430 (null (file-exists-p filename))))
5432 (read-file-name "Save to file: " filename)))
5434 (wl-summary-set-message-buffer-or-redisplay)
5435 (set-buffer (wl-message-get-original-buffer))
5436 (if (and (null arg) (file-exists-p filename))
5437 (if (y-or-n-p "file already exists. override it?")
5438 (write-region (point-min) (point-max) filename))
5439 (write-region (point-min) (point-max) filename)))
5440 (message "No message to save."))
5443 (defun wl-summary-save-region (beg end)
5447 (narrow-to-region beg end)
5448 (goto-char (point-min))
5450 (wl-read-directory-name "Save to directory: " wl-tmp-dir)))
5451 (if (null (file-exists-p wl-save-dir))
5452 (make-directory wl-save-dir))
5453 (if (eq wl-summary-buffer-view 'thread)
5456 (let* ((number (wl-summary-message-number))
5457 (entity (wl-thread-get-entity number)))
5458 (if (wl-thread-entity-get-opened entity)
5459 (wl-summary-save t wl-save-dir)
5461 (wl-summary-save t wl-save-dir))
5464 (wl-summary-save t wl-save-dir)
5465 (forward-line 1)))))))
5467 ;; mew-summary-pipe-message()
5468 (defun wl-summary-pipe-message (prefix command)
5469 "Send this message via pipe."
5471 (list current-prefix-arg
5472 (read-string "Shell command on message: " wl-summary-shell-command-last)))
5473 (if (y-or-n-p "Send this message to pipe? ")
5475 (wl-summary-set-message-buffer-or-redisplay)
5476 (set-buffer (wl-message-get-original-buffer))
5477 (if (string= command "")
5478 (setq command wl-summary-shell-command-last))
5479 (goto-char (point-min)) ; perhaps this line won't be necessary
5481 (search-forward "\n\n"))
5482 (shell-command-on-region (point) (point-max) command nil)
5483 (setq wl-summary-shell-command-last command))))
5485 (defun wl-summary-print-message (&optional arg)
5488 (wl-summary-set-message-buffer-or-redisplay)
5489 (if (or (not (interactive-p))
5490 (y-or-n-p "Print ok?"))
5492 (let* ((message-buffer (get-buffer wl-message-buf-name))
5493 ;; (summary-buffer (get-buffer wl-summary-buffer-name))
5494 (buffer (generate-new-buffer " *print*")))
5495 (set-buffer message-buffer)
5496 (copy-to-buffer buffer (point-min) (point-max))
5498 (funcall wl-print-buffer-func)
5499 (kill-buffer buffer)))
5502 (defun wl-summary-print-message-with-ps-print (&optional filename)
5503 (interactive (list (ps-print-preprint current-prefix-arg)))
5504 (if (or (not (interactive-p))
5505 (y-or-n-p "Print ok?"))
5506 (let ((summary-buffer (current-buffer))
5509 ;;(wl-summary-set-message-buffer-or-redisplay)
5510 (wl-summary-redisplay-internal)
5511 (let* ((message-buffer (get-buffer wl-message-buf-name))
5512 (buffer (generate-new-buffer " *print*"))
5514 (set-buffer summary-buffer)
5516 (wl-summary-message-number)
5517 (elmo-msgdb-get-number-alist
5518 wl-summary-buffer-msgdb)))
5519 (elmo-msgdb-get-overview
5520 wl-summary-buffer-msgdb))))
5523 (or (elmo-msgdb-overview-entity-get-subject entity)
5527 (or (elmo-msgdb-overview-entity-get-from entity) "")))
5530 (or (elmo-msgdb-overview-entity-get-date entity) ""))))
5531 (run-hooks 'wl-ps-preprint-hook)
5532 (set-buffer message-buffer)
5533 (copy-to-buffer buffer (point-min) (point-max))
5536 (let ((ps-left-header
5537 (list (concat "(" wl-ps-subject ")")
5538 (concat "(" wl-ps-from ")")))
5540 (list "/pagenumberstring load"
5541 (concat "(" wl-ps-date ")"))))
5542 (run-hooks 'wl-ps-print-hook)
5543 (funcall wl-ps-print-buffer-func filename))
5544 (kill-buffer buffer)))))
5547 (if (featurep 'ps-print) ; ps-print is available.
5548 (fset 'wl-summary-print-message 'wl-summary-print-message-with-ps-print))
5550 (defun wl-summary-folder-info-update ()
5551 (let ((folder (elmo-string wl-summary-buffer-folder-name))
5552 (num-db (elmo-msgdb-get-number-alist
5553 wl-summary-buffer-msgdb)))
5554 (wl-folder-set-folder-updated folder
5556 (+ wl-summary-buffer-unread-count
5557 wl-summary-buffer-new-count)
5560 (defun wl-summary-get-newsgroups ()
5561 (let ((spec-list (elmo-folder-get-primitive-spec-list
5562 (elmo-string wl-summary-buffer-folder-name)))
5565 (when (eq (caar spec-list) 'nntp)
5566 (wl-append ng-list (list (nth 1 (car spec-list)))))
5567 (setq spec-list (cdr spec-list)))
5570 (defun wl-summary-set-crosspost (&optional type redisplay)
5571 (let* ((number (wl-summary-message-number))
5572 (spec (elmo-folder-number-get-spec wl-summary-buffer-folder-name
5574 (folder (nth 1 spec))
5575 message-buf newsgroups)
5576 (when (eq (car spec) 'nntp)
5578 (wl-summary-redisplay))
5580 (if (setq message-buf (wl-message-get-original-buffer))
5581 (set-buffer message-buf))
5582 (setq newsgroups (std11-field-body "newsgroups")))
5584 (let* ((msgdb wl-summary-buffer-msgdb)
5585 (num-db (elmo-msgdb-get-number-alist msgdb))
5586 (ng-list (wl-summary-get-newsgroups)) ;; for multi folder
5588 (when (setq crosspost-folders
5589 (elmo-delete-lists ng-list
5590 (wl-parse-newsgroups newsgroups t)))
5591 (elmo-crosspost-message-set (cdr (assq number num-db)) ;;message-id
5594 (setq wl-crosspost-alist-modified t)))))))
5596 (defun wl-summary-is-crosspost-folder (spec-list fld-list)
5599 (if (and (eq (caar spec-list) 'nntp)
5600 (member (setq fld (nth 1 (car spec-list))) fld-list))
5601 (wl-append flds (list fld)))
5602 (setq spec-list (cdr spec-list)))
5605 (defun wl-summary-update-crosspost ()
5606 (let* ((msgdb wl-summary-buffer-msgdb)
5607 (number-alist (elmo-msgdb-get-number-alist msgdb))
5608 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
5609 (spec-list (elmo-folder-get-primitive-spec-list
5610 (elmo-string wl-summary-buffer-folder-name)))
5611 (alist elmo-crosspost-message-alist)
5614 (when (assq 'nntp spec-list)
5617 (wl-summary-is-crosspost-folder
5619 (nth 1 (car alist))))
5620 (when (setq num (car (rassoc (caar alist) number-alist)))
5621 (if (and (setq mark (cadr (assq num mark-alist)))
5622 (member mark (list wl-summary-new-mark
5623 wl-summary-unread-uncached-mark
5624 wl-summary-unread-cached-mark)))
5625 (setq crossed (1+ crossed)))
5626 (if (wl-summary-jump-to-msg num)
5627 (wl-summary-mark-as-read t);; opened
5628 (wl-thread-msg-mark-as-read num)));; closed
5629 ;; delete if message does't exists.
5630 (elmo-crosspost-message-delete (caar alist) ngs)
5631 (setq wl-crosspost-alist-modified t))
5632 (setq alist (cdr alist))))
5636 (defun wl-crosspost-alist-load ()
5637 (setq elmo-crosspost-message-alist (elmo-crosspost-alist-load))
5638 (setq wl-crosspost-alist-modified nil))
5640 (defun wl-crosspost-alist-save ()
5641 (when wl-crosspost-alist-modified
5642 ;; delete non-exists newsgroups
5643 (let ((alist elmo-crosspost-message-alist)
5649 (not (intern-soft x wl-folder-newsgroups-hashtb)))
5650 (nth 1 (car alist))))
5652 (setcar (cdar alist) newsgroups)
5653 (setq elmo-crosspost-message-alist
5654 (delete (car alist) elmo-crosspost-message-alist)))
5655 (setq alist (cdr alist)))
5656 (elmo-crosspost-alist-save elmo-crosspost-message-alist)
5657 (setq wl-crosspost-alist-modified nil))))
5659 (defun wl-summary-pack-number (&optional arg)
5661 (setq wl-summary-buffer-msgdb
5663 wl-summary-buffer-folder-name wl-summary-buffer-msgdb arg))
5664 (wl-summary-rescan))
5666 (defun wl-summary-target-mark-uudecode ()
5668 (let ((mlist (reverse wl-summary-buffer-target-mark-list))
5669 (summary-buf (current-buffer))
5670 (tmp-buf (get-buffer-create "*WL UUENCODE*"))
5671 orig-buf i k filename rc errmsg)
5673 (setq k (length mlist))
5674 (set-buffer tmp-buf)
5676 (save-window-excursion
5678 (set-buffer summary-buf)
5679 (wl-summary-jump-to-msg (car mlist))
5680 (wl-summary-redisplay)
5681 (set-buffer (setq orig-buf (wl-message-get-original-buffer)))
5682 (goto-char (point-min))
5683 (cond ((= i 1) ; first
5684 (setq filename (wl-message-uu-substring
5688 (wl-message-uu-substring orig-buf tmp-buf))
5690 (wl-message-uu-substring orig-buf tmp-buf nil t)))
5692 (setq mlist (cdr mlist)))
5693 (set-buffer tmp-buf)
5694 (message "Exec %s..." wl-prog-uudecode)
5696 (let ((decode-dir wl-tmp-dir))
5697 (if (not wl-prog-uudecode-no-stdout-option)
5698 (setq filename (read-file-name "Save to file: "
5700 (elmo-safe-filename filename)
5703 (wl-read-directory-name "Save to directory: "
5705 (setq filename (expand-file-name filename decode-dir)))
5706 (if (file-exists-p filename)
5707 (or (yes-or-no-p (format "File %s exists. Save anyway? "
5710 (elmo-bind-directory
5714 (apply 'call-process-region (point-min) (point-max)
5715 wl-prog-uudecode t (current-buffer) nil
5716 wl-prog-uudecode-arg))))
5717 (when (not (= 0 rc))
5718 (setq errmsg (buffer-substring (point-min)(point-max)))
5719 (error "uudecode error: %s" errmsg))
5720 (if (not wl-prog-uudecode-no-stdout-option)
5721 (let (file-name-handler-alist) ;; void jka-compr
5722 (as-binary-output-file
5723 (write-region (point-min) (point-max)
5724 filename nil 'no-msg))))
5726 (set-buffer summary-buf)
5727 (wl-summary-delete-all-temp-marks))
5728 (if (file-exists-p filename)
5729 (message "Saved as %s" filename)))
5730 (kill-buffer tmp-buf)))))
5732 (defun wl-summary-drop-unsync ()
5733 "Drop all unsync messages."
5735 (if (elmo-folder-pipe-p wl-summary-buffer-folder-name)
5736 (error "You cannot drop unsync messages in this folder"))
5737 (if (or (not (interactive-p))
5738 (y-or-n-p "Drop all unsync messages?"))
5739 (let* ((folder-list (elmo-folder-get-primitive-folder-list
5740 wl-summary-buffer-folder-name))
5741 (is-multi (elmo-multi-p wl-summary-buffer-folder-name))
5745 (message "Dropping...")
5747 (setq pair (elmo-max-of-folder (car folder-list)))
5748 (when is-multi ;; dirty hack...
5750 (setcar pair (+ (* multi-num elmo-multi-divide-number)
5752 (elmo-msgdb-set-number-alist
5753 wl-summary-buffer-msgdb
5755 (elmo-msgdb-get-number-alist wl-summary-buffer-msgdb)
5756 (list (cons (car pair) nil))))
5757 (setq sum (+ sum (cdr pair)))
5758 (setq folder-list (cdr folder-list)))
5759 (wl-summary-set-message-modified)
5760 (wl-folder-set-folder-updated wl-summary-buffer-folder-name
5762 (+ wl-summary-buffer-unread-count
5763 wl-summary-buffer-new-count)
5765 (message "Dropping...done."))))
5767 (defun wl-summary-default-get-next-msg (msg)
5769 (if (and (not wl-summary-buffer-target-mark-list)
5770 (eq wl-summary-buffer-view 'thread)
5771 (if (eq wl-summary-move-direction-downward nil)
5772 (setq next (wl-thread-get-prev-unread msg))
5773 (setq next (wl-thread-get-next-unread msg))))
5776 (wl-summary-jump-to-msg msg)
5777 (let (wl-summary-buffer-disp-msg)
5778 (if (eq wl-summary-move-direction-downward nil)
5779 (unless (wl-summary-cursor-up)
5781 (unless (wl-summary-cursor-down)
5783 (wl-summary-message-number))))))
5785 (defsubst wl-cache-prefetch-p (fld &optional num)
5786 (cond ((and num wl-cache-prefetch-folder-type-list)
5788 (elmo-folder-number-get-type fld num)
5789 wl-cache-prefetch-folder-type-list))
5790 (wl-cache-prefetch-folder-type-list
5791 (let ((list wl-cache-prefetch-folder-type-list)
5794 (while (setq type (pop list))
5795 (if (elmo-folder-contains-type fld type)
5796 (throw 'done t))))))
5797 ((consp wl-cache-prefetch-folder-list)
5798 (wl-string-match-member fld wl-cache-prefetch-folder-list))
5800 wl-cache-prefetch-folder-list)))
5802 (defconst wl-cache-prefetch-idle-time
5803 (if (featurep 'lisp-float-type) (/ (float 1) (float 10)) 1))
5805 (defun wl-cache-prefetch-next (fld msg &optional summary)
5806 (if (wl-cache-prefetch-p fld)
5807 (if (not elmo-use-buffer-cache)
5808 ;; (message "`elmo-use-buffer-cache' is nil, cache prefetch is disable.")
5810 (set-buffer (or summary (get-buffer wl-summary-buffer-name)))
5811 (let ((next (funcall wl-cache-prefetch-get-next-func msg)))
5813 (wl-cache-prefetch-p fld next))
5814 (if (not (fboundp 'run-with-idle-timer))
5815 (when (sit-for wl-cache-prefetch-idle-time)
5816 (wl-cache-prefetch-message fld next summary))
5817 (run-with-idle-timer
5818 wl-cache-prefetch-idle-time
5820 'wl-cache-prefetch-message fld next summary)
5823 (defvar wl-cache-prefetch-debug nil)
5824 (defun wl-cache-prefetch-message (folder msg summary &optional next)
5825 (when (buffer-live-p summary)
5827 (set-buffer summary)
5828 (when (string= folder wl-summary-buffer-folder-name)
5831 (let* ((msgdb wl-summary-buffer-msgdb)
5832 (message-id (cdr (assq next
5833 (elmo-msgdb-get-number-alist msgdb)))))
5834 (if (not (elmo-buffer-cache-hit (list folder next message-id)))
5835 (let* ((size (elmo-msgdb-overview-entity-get-size
5837 (elmo-msgdb-get-overview msgdb)))))
5838 (when (or (elmo-local-file-p folder next)
5839 (not (and (integerp size)
5840 wl-cache-prefetch-threshold
5841 (>= size wl-cache-prefetch-threshold)
5842 (not (elmo-cache-exists-p message-id
5844 (if wl-cache-prefetch-debug
5845 (message "Reading %d..." msg))
5846 (elmo-buffer-cache-message folder next msgdb)
5847 (if wl-cache-prefetch-debug
5848 (message "Reading %d... done" msg))))))))))
5850 (provide 'wl-summary)
5852 ;;; wl-summary.el ends here