1 ;;; wl-summary.el -- Summary mode for Wanderlust.
3 ;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
4 ;; Copyright (C) 1998,1999,2000 Masahiro MURATA <muse@ba2.so-net.ne.jp>
5 ;; Copyright (C) 1999,2000 TSUMURA Tomoaki <tsumura@kuis.kyoto-u.ac.jp>
6 ;; Copyright (C) 1999,2000 Kenichi OKADA <okada@opaopa.org>
8 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
9 ;; Masahiro MURATA <muse@ba2.so-net.ne.jp>
10 ;; TSUMURA Tomoaki <tsumura@kuis.kyoto-u.ac.jp>
11 ;; Kenichi OKADA <okada@opaopa.org>
12 ;; Keywords: mail, net news
14 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
16 ;; This program is free software; you can redistribute it and/or modify
17 ;; it under the terms of the GNU General Public License as published by
18 ;; the Free Software Foundation; either version 2, or (at your option)
21 ;; This program is distributed in the hope that it will be useful,
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;; GNU General Public License for more details.
26 ;; You should have received a copy of the GNU General Public License
27 ;; along with GNU Emacs; see the file COPYING. If not, write to the
28 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
29 ;; Boston, MA 02111-1307, USA.
42 (require 'wl-highlight)
45 (condition-case nil (require 'timezone) (error nil))
46 (condition-case nil (require 'easymenu) (error nil))
48 (condition-case nil (require 'ps-print) (error nil))
52 (condition-case () (require 'timer) (error nil))
53 (defalias-maybe 'ps-print-buffer-with-faces 'ignore)
54 (defalias-maybe 'elmo-database-msgid-put 'ignore)
55 (defalias-maybe 'elmo-database-close 'ignore)
56 (defalias-maybe 'elmo-database-msgid-get 'ignore)
57 (defalias-maybe 'run-with-idle-timer 'ignore)
58 (defalias-maybe 'ps-print-preprint 'ignore))
60 (defvar dragdrop-drop-functions)
61 (defvar scrollbar-height)
62 (defvar mail-reply-buffer)
64 (defvar wl-summary-buffer-name "Summary")
65 (defvar wl-summary-mode-map nil)
66 (defvar wl-current-summary-buffer nil)
68 (defvar wl-summary-buffer-elmo-folder nil)
70 (defmacro wl-summary-buffer-folder-name ()
71 (` (and wl-summary-buffer-elmo-folder
72 (elmo-folder-name-internal wl-summary-buffer-elmo-folder))))
74 (defmacro wl-summary-buffer-msgdb ()
75 (` (and wl-summary-buffer-elmo-folder
76 (elmo-folder-msgdb wl-summary-buffer-elmo-folder))))
78 (defvar wl-summary-buffer-folder-indicator nil)
79 (defvar wl-summary-buffer-disp-msg nil)
80 (defvar wl-summary-buffer-disp-folder nil)
81 (defvar wl-summary-buffer-refile-list nil)
82 (defvar wl-summary-buffer-delete-list nil)
83 (defvar wl-summary-buffer-last-displayed-msg nil)
84 (defvar wl-summary-buffer-current-msg nil)
85 (defvar wl-summary-buffer-unread-status " (0 new/0 unread)")
86 (defvar wl-summary-buffer-unread-count 0)
87 (defvar wl-summary-buffer-new-count 0)
88 (defvar wl-summary-buffer-mime-charset nil)
89 (defvar wl-summary-buffer-weekday-name-lang nil)
90 (defvar wl-summary-buffer-thread-indent-set-alist nil)
91 (defvar wl-summary-buffer-view 'thread)
92 (defvar wl-summary-buffer-message-modified nil)
93 (defvar wl-summary-buffer-mark-modified nil)
94 (defvar wl-summary-buffer-thread-modified nil)
95 (defvar wl-summary-buffer-number-column nil)
96 (defvar wl-summary-buffer-number-regexp nil)
97 (defvar wl-summary-buffer-persistent nil)
98 (defvar wl-summary-buffer-thread-nodes nil)
99 (defvar wl-summary-buffer-target-mark-list nil)
100 (defvar wl-summary-buffer-copy-list nil)
101 (defvar wl-summary-buffer-prev-refile-destination nil)
102 (defvar wl-summary-buffer-prev-copy-destination nil)
103 (defvar wl-summary-buffer-saved-message nil)
104 (defvar wl-summary-buffer-prev-folder-function nil)
105 (defvar wl-summary-buffer-next-folder-function nil)
106 (defvar wl-summary-buffer-exit-function nil)
107 (defvar wl-summary-buffer-next-message-function nil)
108 (defvar wl-summary-buffer-number-list nil)
109 (defvar wl-summary-buffer-msgdb nil)
110 (defvar wl-summary-buffer-folder-name nil)
112 (defvar wl-thread-indent-level-internal nil)
113 (defvar wl-thread-have-younger-brother-str-internal nil)
114 (defvar wl-thread-youngest-child-str-internal nil)
115 (defvar wl-thread-vertical-str-internal nil)
116 (defvar wl-thread-horizontal-str-internal nil)
117 (defvar wl-thread-space-str-internal nil)
118 (defvar wl-summary-last-visited-folder nil)
119 (defvar wl-read-folder-hist nil)
120 (defvar wl-summary-scored nil)
121 (defvar wl-crosspost-alist-modified nil)
122 (defvar wl-summary-alike-hashtb nil)
123 (defvar wl-summary-search-buf-name " *wl-search-subject*")
124 (defvar wl-summary-delayed-update nil)
125 (defvar wl-summary-search-buf-folder-name nil)
127 (defvar wl-summary-get-petname-function 'wl-address-get-petname-1)
129 (defvar wl-summary-message-regexp "^ *\\(-?[0-9]+\\)")
131 (defvar wl-summary-shell-command-last "")
133 (defvar wl-ps-preprint-hook nil)
134 (defvar wl-ps-print-hook nil)
136 (make-variable-buffer-local 'wl-summary-buffer-elmo-folder)
137 (make-variable-buffer-local 'wl-summary-search-buf-folder-name)
138 (make-variable-buffer-local 'wl-summary-buffer-disp-msg)
139 (make-variable-buffer-local 'wl-summary-buffer-disp-folder)
140 (make-variable-buffer-local 'wl-summary-buffer-refile-list)
141 (make-variable-buffer-local 'wl-summary-buffer-copy-list)
142 (make-variable-buffer-local 'wl-summary-buffer-target-mark-list)
143 (make-variable-buffer-local 'wl-summary-buffer-delete-list)
144 (make-variable-buffer-local 'wl-summary-buffer-folder-indicator)
145 (make-variable-buffer-local 'wl-summary-buffer-last-displayed-msg)
146 (make-variable-buffer-local 'wl-summary-buffer-unread-status)
147 (make-variable-buffer-local 'wl-summary-buffer-unread-count)
148 (make-variable-buffer-local 'wl-summary-buffer-new-count)
149 (make-variable-buffer-local 'wl-summary-buffer-mime-charset)
150 (make-variable-buffer-local 'wl-summary-buffer-weekday-name-lang)
151 (make-variable-buffer-local 'wl-summary-buffer-thread-indent-set)
152 (make-variable-buffer-local 'wl-summary-buffer-view)
153 (make-variable-buffer-local 'wl-summary-buffer-message-modified)
154 (make-variable-buffer-local 'wl-summary-buffer-mark-modified)
155 (make-variable-buffer-local 'wl-summary-buffer-thread-modified)
156 (make-variable-buffer-local 'wl-summary-buffer-number-column)
157 (make-variable-buffer-local 'wl-summary-buffer-number-regexp)
158 (make-variable-buffer-local 'wl-summary-buffer-persistent)
159 (make-variable-buffer-local 'wl-summary-buffer-thread-nodes)
160 (make-variable-buffer-local 'wl-summary-buffer-prev-refile-destination)
161 (make-variable-buffer-local 'wl-summary-buffer-saved-message)
162 (make-variable-buffer-local 'wl-summary-scored)
163 (make-variable-buffer-local 'wl-summary-default-score)
164 (make-variable-buffer-local 'wl-summary-move-direction-downward)
165 (make-variable-buffer-local 'wl-summary-important-above)
166 (make-variable-buffer-local 'wl-summary-target-above)
167 (make-variable-buffer-local 'wl-summary-mark-below)
168 (make-variable-buffer-local 'wl-summary-expunge-below)
169 (make-variable-buffer-local 'wl-thread-indent-level-internal)
170 (make-variable-buffer-local 'wl-thread-have-younger-brother-str-internal)
171 (make-variable-buffer-local 'wl-thread-youngest-child-str-internal)
172 (make-variable-buffer-local 'wl-thread-vertical-str-internal)
173 (make-variable-buffer-local 'wl-thread-horizontal-str-internal)
174 (make-variable-buffer-local 'wl-thread-space-str-internal)
175 (make-variable-buffer-local 'wl-summary-buffer-prev-folder-function)
176 (make-variable-buffer-local 'wl-summary-buffer-next-folder-function)
177 (make-variable-buffer-local 'wl-summary-buffer-exit-function)
178 (make-variable-buffer-local 'wl-summary-buffer-next-message-function)
179 (make-variable-buffer-local 'wl-summary-buffer-number-list)
180 (make-variable-buffer-local 'wl-summary-buffer-msgdb)
181 (make-variable-buffer-local 'wl-summary-buffer-folder-name)
183 ;; internal functions (dummy)
184 (unless (fboundp 'wl-summary-append-message-func-internal)
185 (defun wl-summary-append-message-func-internal (entity overview
187 &optional force-insert)))
188 (unless (fboundp 'wl-summary-from-func-internal)
189 (defun wl-summary-from-func-internal (from)
191 (unless (fboundp 'wl-summary-subject-func-internal)
192 (defun wl-summary-subject-func-internal (subject)
194 (unless (fboundp 'wl-summary-subject-filter-func-internal)
195 (defun wl-summary-subject-filter-func-internal (subject)
198 (defmacro wl-summary-sticky-buffer-name (name)
199 (` (concat wl-summary-buffer-name ":" (, name))))
201 (defun wl-summary-default-subject (subject-string)
202 (if (string-match "^[ \t]*\\[[^:]+[,: ][0-9]+\\][ \t]*" subject-string)
203 (substring subject-string (match-end 0))
206 (eval-when-compile (defvar-maybe entity nil)) ; silence byte compiler.
207 (defun wl-summary-default-from (from)
210 (and (eq major-mode 'wl-summary-mode)
211 (stringp wl-summary-showto-folder-regexp)
212 (string-match wl-summary-showto-folder-regexp
213 (wl-summary-buffer-folder-name))
214 (wl-address-user-mail-address-p from)
216 ((and (setq tos (elmo-msgdb-overview-entity-get-to entity))
217 (not (string= "" tos)))
226 (funcall wl-summary-get-petname-function to)
228 (std11-extract-address-components to))
231 (wl-parse-addresses tos)
233 ((setq ng (elmo-msgdb-overview-entity-get-extra-field
234 entity "newsgroups"))
235 (setq retval (concat "Ng:" ng)))))
237 (setq retval (or (funcall wl-summary-get-petname-function from)
238 (car (std11-extract-address-components from))
243 (defun wl-summary-simple-from (string)
245 (or (funcall wl-summary-get-petname-function string)
246 (car (std11-extract-address-components string))
250 (defvar wl-summary-mode-menu-spec
252 ["Read" wl-summary-read t]
253 ["Prev page" wl-summary-prev-page t]
254 ["Next page" wl-summary-next-page t]
255 ["Top" wl-summary-display-top t]
256 ["Bottom" wl-summary-display-bottom t]
257 ["Prev" wl-summary-prev t]
258 ["Next" wl-summary-next t]
259 ["Up" wl-summary-up t]
260 ["Down" wl-summary-down t]
261 ["Parent message" wl-summary-jump-to-parent-message t]
263 ["Sync" wl-summary-sync t]
264 ["Execute" wl-summary-exec t]
265 ["Go to other folder" wl-summary-goto-folder t]
266 ["Pick" wl-summary-pick t]
267 ["Mark as read all" wl-summary-mark-as-read-all t]
268 ["Unmark all" wl-summary-unmark-all t]
269 ["Toggle display message" wl-summary-toggle-disp-msg t]
270 ["Display folder" wl-summary-toggle-disp-folder t]
271 ["Toggle threading" wl-summary-toggle-thread t]
272 ["Stick" wl-summary-stick t]
274 ["By Number" wl-summary-sort-by-number t]
275 ["By Date" wl-summary-sort-by-date t]
276 ["By From" wl-summary-sort-by-from t]
277 ["By Subject" wl-summary-sort-by-subject t])
280 ["Mark as read" wl-summary-mark-as-read t]
281 ["Mark as important" wl-summary-mark-as-important t]
282 ["Mark as unread" wl-summary-mark-as-unread t]
283 ["Set delete mark" wl-summary-delete t]
284 ["Set refile mark" wl-summary-refile t]
285 ["Set copy mark" wl-summary-copy t]
286 ["Prefetch" wl-summary-prefetch t]
287 ["Set target mark" wl-summary-target-mark t]
288 ["Unmark" wl-summary-unmark t]
289 ["Save" wl-summary-save t]
290 ["Cancel posted news" wl-summary-cancel-message t]
291 ["Supersedes message" wl-summary-supersedes-message t]
292 ["Resend bounced mail" wl-summary-resend-bounced-mail t]
293 ["Resend message" wl-summary-resend-message t]
294 ["Enter the message" wl-summary-jump-to-current-message t]
295 ["Pipe message" wl-summary-pipe-message t]
296 ["Print message" wl-summary-print-message t])
298 ["Open or Close" wl-thread-open-close (eq wl-summary-buffer-view 'thread)]
299 ["Open all" wl-thread-open-all (eq wl-summary-buffer-view 'thread)]
300 ["Close all" wl-thread-close-all (eq wl-summary-buffer-view 'thread)]
301 ["Mark as read" wl-thread-mark-as-read (eq wl-summary-buffer-view 'thread)]
302 ["Mark as important" wl-thread-mark-as-important (eq wl-summary-buffer-view 'thread)]
303 ["Mark as unread" wl-thread-mark-as-unread (eq wl-summary-buffer-view 'thread)]
304 ["Set delete mark" wl-thread-delete (eq wl-summary-buffer-view 'thread)]
305 ["Set refile mark" wl-thread-refile (eq wl-summary-buffer-view 'thread)]
306 ["Set copy mark" wl-thread-copy (eq wl-summary-buffer-view 'thread)]
307 ["Prefetch" wl-thread-prefetch (eq wl-summary-buffer-view 'thread)]
308 ["Set target mark" wl-thread-target-mark (eq wl-summary-buffer-view 'thread)]
309 ["Unmark" wl-thread-unmark (eq wl-summary-buffer-view 'thread)]
310 ["Save" wl-thread-save (eq wl-summary-buffer-view 'thread)]
311 ["Execute" wl-thread-exec (eq wl-summary-buffer-view 'thread)])
313 ["Mark as read" wl-summary-mark-as-read-region t]
314 ["Mark as important" wl-summary-mark-as-important-region t]
315 ["Mark as unread" wl-summary-mark-as-unread-region t]
316 ["Set delete mark" wl-summary-delete-region t]
317 ["Set refile mark" wl-summary-refile-region t]
318 ["Set copy mark" wl-summary-copy-region t]
319 ["Prefetch" wl-summary-prefetch-region t]
320 ["Set target mark" wl-summary-target-mark-region t]
321 ["Unmark" wl-summary-unmark-region t]
322 ["Save" wl-summary-save-region t]
323 ["Execute" wl-summary-exec-region t])
325 ["Mark as read" wl-summary-target-mark-mark-as-read t]
326 ["Mark as important" wl-summary-target-mark-mark-as-important t]
327 ["Mark as unread" wl-summary-target-mark-mark-as-unread t]
328 ["Set delete mark" wl-summary-target-mark-delete t]
329 ["Set refile mark" wl-summary-target-mark-refile t]
330 ["Set copy mark" wl-summary-target-mark-copy t]
331 ["Prefetch" wl-summary-target-mark-prefetch t]
332 ["Save" wl-summary-target-mark-save t]
333 ["Reply with citation" wl-summary-target-mark-reply-with-citation t]
334 ["Forward" wl-summary-target-mark-forward t]
335 ["uudecode" wl-summary-target-mark-uudecode t])
337 ["Switch current score file" wl-score-change-score-file t]
338 ["Edit current score file" wl-score-edit-current-scores t]
339 ["Edit score file" wl-score-edit-file t]
340 ["Set mark below" wl-score-set-mark-below t]
341 ["Set expunge below" wl-score-set-expunge-below t]
342 ["Rescore buffer" wl-summary-rescore t]
343 ["Increase score" wl-summary-increase-score t]
344 ["Lower score" wl-summary-lower-score t])
347 ["Write a message" wl-summary-write t]
348 ["Reply" wl-summary-reply t]
349 ["Reply with citation" wl-summary-reply-with-citation t]
350 ["Forward" wl-summary-forward t])
352 ["Toggle Plug Status" wl-toggle-plugged t]
353 ["Change Plug Status" wl-plugged-change t]
355 ["Exit Current Folder" wl-summary-exit t]))
358 (defun wl-summary-setup-mouse ()
359 (define-key wl-summary-mode-map 'button4 'wl-summary-prev)
360 (define-key wl-summary-mode-map 'button5 'wl-summary-next)
361 (define-key wl-summary-mode-map [(shift button4)]
363 (define-key wl-summary-mode-map [(shift button5)]
365 (define-key wl-summary-mode-map 'button2 'wl-summary-click))
366 (defun wl-summary-setup-mouse ()
367 (define-key wl-summary-mode-map [mouse-4] 'wl-summary-prev)
368 (define-key wl-summary-mode-map [mouse-5] 'wl-summary-next)
369 (define-key wl-summary-mode-map [S-mouse-4] 'wl-summary-up)
370 (define-key wl-summary-mode-map [S-mouse-5] 'wl-summary-down)
371 (define-key wl-summary-mode-map [mouse-2] 'wl-summary-click)))
373 (if wl-summary-mode-map
375 (setq wl-summary-mode-map (make-sparse-keymap))
376 (define-key wl-summary-mode-map " " 'wl-summary-read)
377 (define-key wl-summary-mode-map "." 'wl-summary-redisplay)
378 (define-key wl-summary-mode-map "<" 'wl-summary-display-top)
379 (define-key wl-summary-mode-map ">" 'wl-summary-display-bottom)
380 (define-key wl-summary-mode-map "\177" 'wl-summary-prev-page)
381 (define-key wl-summary-mode-map [backspace] 'wl-summary-prev-page)
382 (define-key wl-summary-mode-map "\r" 'wl-summary-next-line-content)
383 (define-key wl-summary-mode-map "\C-m" 'wl-summary-next-line-content)
384 (define-key wl-summary-mode-map "/" 'wl-thread-open-close)
385 (define-key wl-summary-mode-map "[" 'wl-thread-open-all)
386 (define-key wl-summary-mode-map "]" 'wl-thread-close-all)
387 (define-key wl-summary-mode-map "-" 'wl-summary-prev-line-content)
388 (define-key wl-summary-mode-map "\e\r" 'wl-summary-prev-line-content)
389 (define-key wl-summary-mode-map "g" 'wl-summary-goto-folder)
390 (define-key wl-summary-mode-map "c" 'wl-summary-mark-as-read-all)
391 ; (define-key wl-summary-mode-map "D" 'wl-summary-drop-unsync)
393 (define-key wl-summary-mode-map "a" 'wl-summary-reply)
394 (define-key wl-summary-mode-map "A" 'wl-summary-reply-with-citation)
395 (define-key wl-summary-mode-map "C" 'wl-summary-cancel-message)
396 (define-key wl-summary-mode-map "E" 'wl-summary-reedit)
397 (define-key wl-summary-mode-map "\eE" 'wl-summary-resend-bounced-mail)
398 (define-key wl-summary-mode-map "f" 'wl-summary-forward)
399 (define-key wl-summary-mode-map "$" 'wl-summary-mark-as-important)
400 (define-key wl-summary-mode-map "@" 'wl-summary-edit-addresses)
402 (define-key wl-summary-mode-map "y" 'wl-summary-save)
403 (define-key wl-summary-mode-map "n" 'wl-summary-next)
404 (define-key wl-summary-mode-map "p" 'wl-summary-prev)
405 (define-key wl-summary-mode-map "N" 'wl-summary-down)
406 (define-key wl-summary-mode-map "P" 'wl-summary-up)
407 ;;;(define-key wl-summary-mode-map "w" 'wl-draft)
408 (define-key wl-summary-mode-map "w" 'wl-summary-write)
409 (define-key wl-summary-mode-map "W" 'wl-summary-write-current-folder)
410 ;;;(define-key wl-summary-mode-map "e" 'wl-draft-open-file)
411 (define-key wl-summary-mode-map "e" 'wl-summary-save)
412 (define-key wl-summary-mode-map "\C-c\C-o" 'wl-jump-to-draft-buffer)
413 (define-key wl-summary-mode-map "\C-c\C-a" 'wl-addrmgr)
414 (define-key wl-summary-mode-map "H" 'wl-summary-redisplay-all-header)
415 (define-key wl-summary-mode-map "M" 'wl-summary-redisplay-no-mime)
416 (define-key wl-summary-mode-map "B" 'wl-summary-burst)
417 (define-key wl-summary-mode-map "Z" 'wl-status-update)
418 (define-key wl-summary-mode-map "#" 'wl-summary-print-message)
419 (define-key wl-summary-mode-map "|" 'wl-summary-pipe-message)
420 (define-key wl-summary-mode-map "q" 'wl-summary-exit)
421 (define-key wl-summary-mode-map "Q" 'wl-summary-force-exit)
423 (define-key wl-summary-mode-map "j" 'wl-summary-jump-to-current-message)
424 (define-key wl-summary-mode-map "J" 'wl-thread-jump-to-msg)
425 (define-key wl-summary-mode-map "I" 'wl-summary-incorporate)
426 (define-key wl-summary-mode-map "\M-j" 'wl-summary-jump-to-msg-by-message-id)
427 (define-key wl-summary-mode-map "^" 'wl-summary-jump-to-parent-message)
428 (define-key wl-summary-mode-map "!" 'wl-summary-mark-as-unread)
430 (define-key wl-summary-mode-map "s" 'wl-summary-sync)
431 (define-key wl-summary-mode-map "S" 'wl-summary-sort)
432 (define-key wl-summary-mode-map "\M-s" 'wl-summary-stick)
433 (define-key wl-summary-mode-map "T" 'wl-summary-toggle-thread)
435 (define-key wl-summary-mode-map "l" 'wl-summary-toggle-disp-folder)
436 (define-key wl-summary-mode-map "v" 'wl-summary-toggle-disp-msg)
437 (define-key wl-summary-mode-map "V" 'wl-summary-virtual)
439 (define-key wl-summary-mode-map "\C-i" 'wl-summary-goto-last-displayed-msg)
440 (define-key wl-summary-mode-map "?" 'wl-summary-pick)
441 (define-key wl-summary-mode-map "\ee" 'wl-summary-expire)
444 (define-key wl-summary-mode-map "\ew" 'wl-summary-save-current-message)
445 (define-key wl-summary-mode-map "\C-y" 'wl-summary-yank-saved-message)
448 (define-key wl-summary-mode-map "R" 'wl-summary-mark-as-read)
449 (define-key wl-summary-mode-map "i" 'wl-summary-prefetch)
450 (define-key wl-summary-mode-map "x" 'wl-summary-exec)
451 (define-key wl-summary-mode-map "*" 'wl-summary-target-mark)
452 (define-key wl-summary-mode-map "o" 'wl-summary-refile)
453 (define-key wl-summary-mode-map "O" 'wl-summary-copy)
454 (define-key wl-summary-mode-map "\M-o" 'wl-summary-refile-prev-destination)
455 ; (define-key wl-summary-mode-map "\M-O" 'wl-summary-copy-prev-destination)
456 (define-key wl-summary-mode-map "\C-o" 'wl-summary-auto-refile)
457 (define-key wl-summary-mode-map "d" 'wl-summary-delete)
458 (define-key wl-summary-mode-map "u" 'wl-summary-unmark)
459 (define-key wl-summary-mode-map "U" 'wl-summary-unmark-all)
462 (define-key wl-summary-mode-map "t" (make-sparse-keymap))
463 (define-key wl-summary-mode-map "tR" 'wl-thread-mark-as-read)
464 (define-key wl-summary-mode-map "ti" 'wl-thread-prefetch)
465 (define-key wl-summary-mode-map "tx" 'wl-thread-exec)
466 (define-key wl-summary-mode-map "t*" 'wl-thread-target-mark)
467 (define-key wl-summary-mode-map "to" 'wl-thread-refile)
468 (define-key wl-summary-mode-map "tO" 'wl-thread-copy)
469 (define-key wl-summary-mode-map "td" 'wl-thread-delete)
470 (define-key wl-summary-mode-map "tu" 'wl-thread-unmark)
471 (define-key wl-summary-mode-map "t!" 'wl-thread-mark-as-unread)
472 (define-key wl-summary-mode-map "t$" 'wl-thread-mark-as-important)
473 (define-key wl-summary-mode-map "ty" 'wl-thread-save)
474 (define-key wl-summary-mode-map "ts" 'wl-thread-set-parent)
476 ;; target-mark commands
477 (define-key wl-summary-mode-map "m" (make-sparse-keymap))
478 (define-key wl-summary-mode-map "mi" 'wl-summary-target-mark-prefetch)
479 (define-key wl-summary-mode-map "mR" 'wl-summary-target-mark-mark-as-read)
480 (define-key wl-summary-mode-map "mo" 'wl-summary-target-mark-refile)
481 (define-key wl-summary-mode-map "mO" 'wl-summary-target-mark-copy)
482 (define-key wl-summary-mode-map "md" 'wl-summary-target-mark-delete)
483 (define-key wl-summary-mode-map "my" 'wl-summary-target-mark-save)
484 (define-key wl-summary-mode-map "m!" 'wl-summary-target-mark-mark-as-unread)
485 (define-key wl-summary-mode-map "m$" 'wl-summary-target-mark-mark-as-important)
486 (define-key wl-summary-mode-map "mu" 'wl-summary-delete-all-temp-marks)
487 (define-key wl-summary-mode-map "mU" 'wl-summary-target-mark-uudecode)
488 (define-key wl-summary-mode-map "ma" 'wl-summary-target-mark-all)
489 (define-key wl-summary-mode-map "mt" 'wl-summary-target-mark-thread)
490 (define-key wl-summary-mode-map "mA" 'wl-summary-target-mark-reply-with-citation)
491 (define-key wl-summary-mode-map "mf" 'wl-summary-target-mark-forward)
492 (define-key wl-summary-mode-map "m?" 'wl-summary-target-mark-pick)
495 (define-key wl-summary-mode-map "r" (make-sparse-keymap))
496 (define-key wl-summary-mode-map "rR" 'wl-summary-mark-as-read-region)
497 (define-key wl-summary-mode-map "ri" 'wl-summary-prefetch-region)
498 (define-key wl-summary-mode-map "rx" 'wl-summary-exec-region)
499 (define-key wl-summary-mode-map "mr" 'wl-summary-target-mark-region)
500 (define-key wl-summary-mode-map "r*" 'wl-summary-target-mark-region)
501 (define-key wl-summary-mode-map "ro" 'wl-summary-refile-region)
502 (define-key wl-summary-mode-map "rO" 'wl-summary-copy-region)
503 (define-key wl-summary-mode-map "rd" 'wl-summary-delete-region)
504 (define-key wl-summary-mode-map "ru" 'wl-summary-unmark-region)
505 (define-key wl-summary-mode-map "r!" 'wl-summary-mark-as-unread-region)
506 (define-key wl-summary-mode-map "r$" 'wl-summary-mark-as-important-region)
507 (define-key wl-summary-mode-map "ry" 'wl-summary-save-region)
510 (define-key wl-summary-mode-map "K" 'wl-summary-increase-score)
511 (define-key wl-summary-mode-map "L" 'wl-summary-lower-score)
512 (define-key wl-summary-mode-map "h" (make-sparse-keymap))
513 (define-key wl-summary-mode-map "hR" 'wl-summary-rescore)
514 (define-key wl-summary-mode-map "hc" 'wl-score-change-score-file)
515 (define-key wl-summary-mode-map "he" 'wl-score-edit-current-scores)
516 (define-key wl-summary-mode-map "hf" 'wl-score-edit-file)
517 (define-key wl-summary-mode-map "hF" 'wl-score-flush-cache)
518 (define-key wl-summary-mode-map "hm" 'wl-score-set-mark-below)
519 (define-key wl-summary-mode-map "hx" 'wl-score-set-expunge-below)
521 (define-key wl-summary-mode-map "\M-t" 'wl-toggle-plugged)
522 (define-key wl-summary-mode-map "\C-t" 'wl-plugged-change)
524 (wl-summary-setup-mouse)
528 "Menu used in Summary mode."
529 wl-summary-mode-menu-spec))
531 (defun wl-status-update ()
535 (defun wl-summary-display-top ()
537 (goto-char (point-min))
538 (if wl-summary-buffer-disp-msg
539 (wl-summary-redisplay)))
541 (defun wl-summary-display-bottom ()
543 (goto-char (point-max))
545 (if wl-summary-buffer-disp-msg
546 (wl-summary-redisplay)))
548 (defun wl-summary-count-unread (mark-alist)
553 (setq mark (cadr (car mark-alist)))
556 ((string= mark wl-summary-new-mark)
557 (setq new (+ 1 new)))
558 ((or (string= mark wl-summary-unread-uncached-mark)
559 (string= mark wl-summary-unread-cached-mark))
560 (setq unread (+ 1 unread)))))
561 (setq mark-alist (cdr mark-alist)))
562 (if (eq major-mode 'wl-summary-mode)
563 (setq wl-summary-buffer-new-count new
564 wl-summary-buffer-unread-count unread))
567 (defun wl-summary-reedit (&optional arg)
568 "Re-edit current message.
569 If ARG is non-nil, Supersedes message"
572 (wl-summary-supersedes-message)
573 (if (string= (wl-summary-buffer-folder-name) wl-draft-folder)
574 (if (wl-summary-message-number)
576 (wl-draft-reedit (wl-summary-message-number))
577 (if (wl-message-news-p)
578 (mail-position-on-field "Newsgroups")
579 (mail-position-on-field "To"))
580 (delete-other-windows)))
582 (let ((mmelmo-force-fetch-entire-message t))
583 (if (null (wl-summary-message-number))
584 (message "No message.")
585 (set-buffer (wl-summary-get-original-buffer))
586 (wl-draft-edit-string (buffer-substring (point-min)
589 (defun wl-summary-resend-bounced-mail ()
590 "Re-mail the current message.
591 This only makes sense if the current message is a bounce message which
592 contains some mail you have written but has been bounced back to
596 (let ((mmelmo-force-fetch-entire-message t))
597 (wl-summary-set-message-buffer-or-redisplay)
598 (set-buffer (wl-message-get-original-buffer))
599 (goto-char (point-min))
600 (let ((case-fold-search nil))
604 (concat "^\\($\\|[Cc]ontent-[Tt]ype:[ \t]+multipart/\\(report\\|mixed\\)\\)") nil t)
606 (re-search-forward "boundary=\"\\([^\"]+\\)\"" nil t))
607 (let ((boundary (buffer-substring (match-beginning 1) (match-end 1)))
610 ((and (setq start (re-search-forward
611 (concat "^--" boundary "\n"
612 "\\([Cc]ontent-[Dd]escription:.*\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 ((original (wl-summary-get-original-buffer)))
636 ;; We first set up a normal mail buffer.
637 (set-buffer (get-buffer-create " *wl-draft-resend*"))
638 (buffer-disable-undo (current-buffer))
640 (setq wl-sent-message-via nil)
641 ;; Insert our usual headers.
642 (wl-draft-insert-from-field)
643 (wl-draft-insert-date-field)
644 (insert "to: " address "\n")
645 (goto-char (point-min))
646 ;; Rename them all to "Resent-*".
647 (while (re-search-forward "^[A-Za-z]" nil t)
652 (delete-region (point) (point-max))
654 ;; Insert the message to be resent.
655 (insert-buffer-substring original)
656 (goto-char (point-min))
657 (search-forward "\n\n")
660 (narrow-to-region beg (point))
661 (wl-draft-delete-fields wl-ignored-resent-headers)
662 (goto-char (point-max)))
663 (insert mail-header-separator)
664 ;; Rename all old ("Previous-")Resent headers.
665 (while (re-search-backward "^\\(Previous-\\)*Resent-" beg t)
667 (insert "Previous-"))
668 ;; Quote any "From " lines at the beginning.
670 (when (looking-at "From ")
671 (replace-match "X-From-Line: ")))
673 (wl-draft-dispatch-message)
674 (kill-buffer (current-buffer)))
675 (message "Resending message to %s...done" address))))
677 (defun wl-summary-buffer-set-folder (folder)
679 (setq folder (wl-folder-get-elmo-folder folder)))
680 (setq wl-summary-buffer-elmo-folder folder)
681 (setq wl-summary-buffer-folder-indicator
682 (if (memq 'modeline wl-use-folder-petname)
683 (wl-folder-get-petname (elmo-folder-name-internal folder))
684 (elmo-folder-name-internal folder)))
685 (make-local-variable 'wl-message-buffer)
686 (setq wl-summary-buffer-mime-charset (or (wl-get-assoc-list-value
687 wl-folder-mime-charset-alist
688 (elmo-folder-name-internal folder))
690 (setq wl-summary-buffer-weekday-name-lang
691 (or (wl-get-assoc-list-value
692 wl-folder-weekday-name-lang-alist
693 (elmo-folder-name-internal folder))
694 wl-summary-weekday-name-lang))
695 (setq wl-summary-buffer-thread-indent-set
696 (wl-get-assoc-list-value
697 wl-folder-thread-indent-set-alist
698 (elmo-folder-name-internal folder)))
699 (setq wl-summary-buffer-persistent
700 (wl-folder-persistent-p (elmo-folder-name-internal folder)))
701 (elmo-folder-set-persistent-internal folder wl-summary-buffer-persistent)
702 ;; process duplicates.
703 (elmo-folder-set-process-duplicates-internal
704 folder (cdr (elmo-string-matched-assoc
705 (elmo-folder-name-internal folder)
706 wl-folder-process-duplicates-alist)))
708 wl-thread-indent-level-internal
709 (or (nth 0 wl-summary-buffer-thread-indent-set)
710 wl-thread-indent-level)
711 wl-thread-have-younger-brother-str-internal
712 (or (nth 1 wl-summary-buffer-thread-indent-set)
713 wl-thread-have-younger-brother-str)
714 wl-thread-youngest-child-str-internal
715 (or (nth 2 wl-summary-buffer-thread-indent-set)
716 wl-thread-youngest-child-str)
717 wl-thread-vertical-str-internal
718 (or (nth 3 wl-summary-buffer-thread-indent-set)
719 wl-thread-vertical-str)
720 wl-thread-horizontal-str-internal
721 (or (nth 4 wl-summary-buffer-thread-indent-set)
722 wl-thread-horizontal-str)
723 wl-thread-space-str-internal
724 (or (nth 5 wl-summary-buffer-thread-indent-set)
725 wl-thread-space-str))
726 (setq wl-thread-indent-regexp
728 (regexp-quote wl-thread-have-younger-brother-str-internal) "\\|"
729 (regexp-quote wl-thread-youngest-child-str-internal) "\\|"
730 (regexp-quote wl-thread-vertical-str-internal) "\\|"
731 (regexp-quote wl-thread-horizontal-str-internal) "\\|"
732 (regexp-quote wl-thread-space-str-internal)))
733 (run-hooks 'wl-summary-buffer-set-folder-hook))
735 (defun wl-summary-mode ()
736 "Major mode for reading threaded messages.
737 See Info under Wanderlust for full documentation.
740 \\{wl-summary-mode-map}
742 Entering Folder mode calls the value of `wl-summary-mode-hook'."
744 (unless (interactive-p) (kill-all-local-variables))
745 (setq major-mode 'wl-summary-mode)
746 (setq mode-name "Summary")
747 (use-local-map wl-summary-mode-map)
748 ;;;(setq default-directory (or wl-tmp-dir (expand-file-name "~/")))
749 (setq buffer-read-only t)
750 (setq truncate-lines t)
751 ;;;(make-local-variable 'tab-width)
752 ;;;(setq tab-width 1)
753 (buffer-disable-undo (current-buffer))
754 (wl-mode-line-buffer-identification '("Wanderlust: "
755 wl-summary-buffer-folder-indicator
756 wl-summary-buffer-unread-status))
757 (easy-menu-add wl-summary-mode-menu)
758 (when wl-summary-lazy-highlight
759 (make-local-variable 'window-scroll-functions)
760 (add-hook 'window-scroll-functions 'wl-highlight-summary-window))
761 ;; This hook may contain the function `wl-setup-summary' for reasons
762 ;; of system internal to accord facilities for the Emacs variants.
763 (run-hooks 'wl-summary-mode-hook))
765 (defun wl-summary-overview-entity-compare-by-date (x y)
766 "Compare entity X and Y by date."
769 (timezone-make-date-sortable
770 (elmo-msgdb-overview-entity-get-date x))
771 (timezone-make-date-sortable
772 (elmo-msgdb-overview-entity-get-date y)))
773 (error))) ;; ignore error.
775 (defun wl-summary-overview-entity-compare-by-number (x y)
776 "Compare entity X and Y by number."
778 (elmo-msgdb-overview-entity-get-number x)
779 (elmo-msgdb-overview-entity-get-number y)))
781 (defun wl-summary-overview-entity-compare-by-from (x y)
782 "Compare entity X and Y by from."
784 (wl-address-header-extract-address
785 (or (elmo-msgdb-overview-entity-get-from-no-decode x)
786 wl-summary-no-from-message))
787 (wl-address-header-extract-address
788 (or (elmo-msgdb-overview-entity-get-from-no-decode y)
789 wl-summary-no-from-message))))
791 (defun wl-summary-overview-entity-compare-by-subject (x y)
792 "Compare entity X and Y by subject."
793 (string< (elmo-msgdb-overview-entity-get-subject-no-decode x)
794 (elmo-msgdb-overview-entity-get-subject-no-decode y)))
796 (defun wl-summary-sort-by-date ()
798 (wl-summary-rescan "date"))
799 (defun wl-summary-sort-by-number ()
801 (wl-summary-rescan "number"))
802 (defun wl-summary-sort-by-subject ()
804 (wl-summary-rescan "subject"))
805 (defun wl-summary-sort-by-from ()
807 (wl-summary-rescan "from"))
809 (defun wl-summary-rescan (&optional sort-by)
810 "Rescan current folder without updating."
812 (let* ((cur-buf (current-buffer))
813 (msgdb (wl-summary-buffer-msgdb))
814 (overview (elmo-msgdb-get-overview msgdb))
815 (number-alist (elmo-msgdb-get-number-alist msgdb))
816 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
817 (elmo-mime-charset wl-summary-buffer-mime-charset)
821 (inhibit-read-only t)
822 (buffer-read-only nil)
824 (fset 'wl-summary-append-message-func-internal
825 (wl-summary-get-append-message-func))
826 (wl-summary-buffer-number-column-detect nil)
828 (message "Re-scanning...")
830 (setq num (length overview))
832 (message "Sorting by %s..." sort-by)
835 (intern (format "wl-summary-overview-entity-compare-by-%s"
837 (message "Sorting by %s...done" sort-by)
838 (elmo-msgdb-set-overview (wl-summary-buffer-msgdb)
842 (setq wl-thread-entity-hashtb (elmo-make-hash (* (length overview) 2)))
843 (setq wl-thread-entity-list nil)
844 (setq wl-thread-entities nil)
845 (setq wl-summary-buffer-number-list nil)
846 (setq wl-summary-buffer-target-mark-list nil)
847 (setq wl-summary-buffer-refile-list nil)
848 (setq wl-summary-buffer-delete-list nil)
849 (setq wl-summary-delayed-update nil)
850 (elmo-kill-buffer wl-summary-search-buf-name)
851 (message "Constructing summary structure...")
853 (setq entity (car curp))
854 (wl-summary-append-message-func-internal entity overview mark-alist
856 (setq curp (cdr curp))
857 (when (> num elmo-display-progress-threshold)
859 (if (or (zerop (% i 5)) (= i num))
860 (elmo-display-progress
861 'wl-summary-rescan "Constructing summary structure..."
862 (/ (* i 100) num)))))
863 (when wl-summary-delayed-update
864 (while wl-summary-delayed-update
865 (message "Parent (%d) of message %d is no entity"
866 (caar wl-summary-delayed-update)
867 (elmo-msgdb-overview-entity-get-number
868 (cdar wl-summary-delayed-update)))
869 (wl-summary-append-message-func-internal
870 (cdar wl-summary-delayed-update)
871 overview mark-alist nil t)
872 (setq wl-summary-delayed-update (cdr wl-summary-delayed-update))))
873 (message "Constructing summary structure...done")
875 (if (eq wl-summary-buffer-view 'thread)
877 (message "Inserting thread...")
878 (wl-thread-insert-top)
879 (message "Inserting thread...done"))
880 (wl-summary-make-number-list))
882 (setq wl-summary-scored nil)
883 (wl-summary-score-headers nil msgdb
884 (wl-summary-rescore-msgs number-alist)
886 (when (and wl-summary-scored
887 (setq expunged (wl-summary-score-update-all-lines)))
888 (message "%d message(s) are expunged by scoring." (length expunged))))
889 (wl-summary-set-message-modified)
890 (wl-summary-count-unread
891 (elmo-msgdb-get-mark-alist
892 (elmo-folder-msgdb wl-summary-buffer-elmo-folder)))
893 (wl-summary-update-modeline)
894 (goto-char (point-max))
896 (set-buffer-modified-p nil)))
898 (defun wl-summary-next-folder-or-exit (&optional next-entity upward)
902 (wl-summary-toggle-disp-msg 'off)
905 (wl-summary-goto-folder-subr next-entity
911 (wl-folder-set-current-entity-id (wl-folder-get-entity-id next-entity))
912 (if (and (eq retval 'more-next)
913 (memq wl-auto-select-next '(unread skip-no-unread))
914 (memq this-command wl-summary-next-no-unread-command))
917 t (eq wl-auto-select-next 'skip-no-unread))
918 (goto-char (point-max))
921 t (eq wl-auto-select-next 'skip-no-unread))))))
924 (defun wl-summary-entity-info-msg (entity finfo)
927 (elmo-replace-in-string
928 (if (memq 'ask-folder wl-use-folder-petname)
929 (wl-folder-get-petname entity)
932 (if (null (car finfo))
935 " (%d new/%d unread)"
941 (defun wl-summary-set-message-modified ()
942 (elmo-folder-set-message-modified-internal
943 wl-summary-buffer-elmo-folder t)
944 (setq wl-summary-buffer-message-modified t))
945 (defun wl-summary-message-modified-p ()
946 wl-summary-buffer-message-modified)
947 (defun wl-summary-set-mark-modified ()
948 (elmo-folder-set-mark-modified-internal
949 wl-summary-buffer-elmo-folder t)
950 (setq wl-summary-buffer-mark-modified t))
951 (defun wl-summary-mark-modified-p ()
952 wl-summary-buffer-mark-modified)
953 (defun wl-summary-set-thread-modified ()
954 (setq wl-summary-buffer-thread-modified t))
955 (defun wl-summary-thread-modified-p ()
956 wl-summary-buffer-thread-modified)
958 (defsubst wl-summary-cleanup-temp-marks (&optional sticky)
959 (if (or wl-summary-buffer-refile-list
960 wl-summary-buffer-copy-list
961 wl-summary-buffer-delete-list)
962 (if (y-or-n-p "Marks remain to be executed. Execute them? ")
965 (if (or wl-summary-buffer-refile-list
966 wl-summary-buffer-copy-list
967 wl-summary-buffer-delete-list)
968 (error "Some execution was failed")))
971 (wl-summary-delete-all-refile-marks)
972 (wl-summary-delete-all-copy-marks)
973 (wl-summary-delete-all-delete-marks)))
974 (if wl-summary-buffer-target-mark-list
976 (wl-summary-delete-all-target-marks)
977 (setq wl-summary-buffer-target-mark-list nil)))
978 (wl-summary-delete-all-temp-marks-on-buffer sticky)
979 (setq wl-summary-scored nil))
981 ;; a subroutine for wl-summary-exit/wl-save-status
982 ;; Note that folder is not commited here.
983 (defun wl-summary-save-view (&optional sticky)
984 ;; already in summary buffer.
985 (when wl-summary-buffer-persistent
986 ;; save the current summary buffer view.
987 (if (and wl-summary-cache-use
988 (or (wl-summary-message-modified-p)
989 (wl-summary-mark-modified-p)
990 (wl-summary-thread-modified-p)))
991 (wl-summary-save-view-cache))))
993 (defun wl-summary-force-exit ()
994 "Exit current summary. Buffer is deleted even the buffer is sticky."
996 (wl-summary-exit 'force-exit))
998 (defun wl-summary-exit (&optional force-exit)
999 "Exit current summary. if FORCE-EXIT, exits even the summary is sticky."
1001 (let ((summary-buf (current-buffer))
1002 (sticky (wl-summary-sticky-p))
1004 message-buf message-win
1005 folder-buf folder-win)
1006 (run-hooks 'wl-summary-exit-pre-hook)
1007 (if wl-summary-buffer-exit-function
1008 (funcall wl-summary-buffer-exit-function)
1009 (wl-summary-cleanup-temp-marks sticky)
1011 ;; save summary status
1015 (elmo-folder-close wl-summary-buffer-elmo-folder)
1016 (elmo-folder-commit wl-summary-buffer-elmo-folder)
1017 (elmo-folder-check wl-summary-buffer-elmo-folder))
1018 (wl-summary-save-view sticky)
1019 (if wl-use-scoring (wl-score-save)))
1020 ;; for sticky summary
1021 (wl-delete-all-overlays)
1022 (setq wl-summary-buffer-disp-msg nil)
1023 (elmo-kill-buffer wl-summary-search-buf-name)
1024 ;; delete message window if displayed.
1025 (if (and wl-message-buffer (get-buffer-window wl-message-buffer))
1026 (delete-window (get-buffer-window wl-message-buffer)))
1027 (if (and wl-summary-use-frame
1028 (> (length (visible-frame-list)) 1))
1030 (if (setq folder-buf (get-buffer wl-folder-buffer-name))
1031 (if wl-summary-use-frame
1033 (save-selected-window
1034 (dolist (frame (visible-frame-list))
1035 (select-frame frame)
1036 (if (get-buffer-window folder-buf)
1037 (setq select-frame frame))))
1039 (select-frame select-frame)
1040 (switch-to-buffer folder-buf)))
1041 (if (setq folder-win (get-buffer-window folder-buf))
1042 ;; folder win is already displayed.
1043 (select-window folder-win)
1044 ;; folder win is not displayed.
1045 (switch-to-buffer folder-buf)))
1046 ;; currently no folder buffer
1048 (and wl-folder-move-cur-folder
1049 wl-folder-buffer-cur-point
1050 (goto-char wl-folder-buffer-cur-point))
1051 (setq wl-folder-buffer-cur-path nil)
1052 (setq wl-folder-buffer-cur-entity-id nil)
1053 (wl-delete-all-overlays)
1054 (if wl-summary-exit-next-move
1055 (wl-folder-next-unsync t)
1056 (beginning-of-line))
1057 (if (setq summary-win (get-buffer-window summary-buf))
1058 (delete-window summary-win))
1062 (set-buffer summary-buf)
1063 (kill-buffer summary-buf)))
1064 (run-hooks 'wl-summary-exit-hook)))))
1066 (defun wl-summary-sync-force-update (&optional unset-cursor no-check)
1068 (wl-summary-sync-update unset-cursor nil no-check))
1070 (defsubst wl-summary-sync-all-init ()
1071 (wl-summary-cleanup-temp-marks)
1073 (wl-summary-set-message-modified)
1074 (wl-summary-set-mark-modified)
1075 (setq wl-thread-entity-hashtb (elmo-make-hash
1076 (* (length (elmo-msgdb-get-number-alist
1077 (wl-summary-buffer-msgdb))) 2)))
1078 (setq wl-thread-entity-list nil)
1079 (setq wl-thread-entities nil)
1080 (setq wl-summary-buffer-number-list nil)
1081 (setq wl-summary-buffer-target-mark-list nil)
1082 (setq wl-summary-buffer-refile-list nil)
1083 (setq wl-summary-buffer-copy-list nil)
1084 (setq wl-summary-buffer-delete-list nil)
1085 (wl-summary-buffer-number-column-detect nil))
1087 (defun wl-summary-sync (&optional unset-cursor force-range)
1089 (let* ((folder wl-summary-buffer-elmo-folder)
1090 (inhibit-read-only t)
1091 (buffer-read-only nil)
1092 (msgdb-dir (elmo-folder-msgdb-path folder))
1093 (range (or force-range (wl-summary-input-range
1094 (elmo-folder-name-internal folder)))))
1095 (cond ((string= range "rescan")
1096 (let ((msg (wl-summary-message-number)))
1098 (and msg (wl-summary-jump-to-msg msg))))
1099 ((string= range "rescan-noscore")
1100 (let ((msg (wl-summary-message-number))
1103 (and msg (wl-summary-jump-to-msg msg))))
1104 ((or (string-match "last:" range)
1105 (string-match "first:" range))
1106 (wl-summary-goto-folder-subr
1107 (wl-folder-get-elmo-folder (concat "/" range "/"
1108 (elmo-folder-name-internal
1110 'force-update nil nil t))
1112 (wl-summary-sync-update unset-cursor
1113 (cond ((string= range "all") 'all)
1114 ((string= range "all-visible")
1115 'visible-only)))))))
1117 (defvar wl-summary-edit-addresses-candidate-fields
1118 ;; First element becomes default.
1119 '("from" "to" "cc"))
1121 (defun wl-summary-edit-addresses-collect-candidate-fields (mime-charset)
1122 (let ((fields wl-summary-edit-addresses-candidate-fields)
1123 body candidates components)
1126 (mapconcat 'identity (elmo-multiple-field-body (car fields))
1128 (setq body (wl-parse-addresses body))
1129 (if body (setq candidates (append candidates body)))
1130 (setq fields (cdr fields)))
1131 (setq candidates (elmo-uniq-list candidates))
1133 (elmo-set-buffer-multibyte default-enable-multibyte-characters)
1136 (setq components (std11-extract-address-components x))
1137 (cons (nth 1 components)
1138 (and (car components)
1139 (eword-decode-string
1140 (decode-mime-charset-string
1145 (defun wl-summary-edit-addresses-subr (the-email name-in-addr)
1146 ;; returns nil if there's no change.
1147 (if (elmo-get-hash-val (downcase the-email) wl-address-petname-hash)
1149 (message (format "'%s' already exists. (e)dit/(d)elete/(c)ancel?"
1151 (while (not (or (eq (setq char (read-char)) ?\r)
1158 "Please answer `e' or `d' or `c'. (e)dit/(d)elete/(c)ancel?"))
1165 (wl-address-add-or-change
1167 (wl-address-header-extract-realname
1169 (let ((completion-ignore-case t) comp)
1171 (try-completion the-email wl-address-completion-list))
1172 (if (equal comp t) the-email comp))
1173 wl-address-completion-list))))
1177 (if (y-or-n-p (format "Delete '%s'? "
1180 (wl-address-delete the-email)
1187 (wl-address-add-or-change the-email name-in-addr)
1190 (defun wl-summary-edit-addresses (&optional addr-str)
1191 "Edit address book interactively.
1192 Optional argument ADDR-STR is used as a target address if specified."
1193 (interactive (if current-prefix-arg
1194 (list (read-from-minibuffer "Target address: "))))
1195 (if (null (wl-summary-message-number))
1196 (message "No message.")
1198 (let* ((charset wl-summary-buffer-mime-charset)
1200 (with-current-buffer (wl-summary-get-original-buffer)
1201 (wl-summary-edit-addresses-collect-candidate-fields
1203 address pair result)
1205 (setq address addr-str)
1207 (setq address (car (car candidates)))
1210 (format "Target address (%s): " address)
1212 (function (lambda (x) (cons (car x) (car x))))
1214 nil nil nil nil address))))
1216 (setq pair (assoc address candidates))
1218 (setq pair (cons address nil)))
1219 (when (setq result (wl-summary-edit-addresses-subr (car pair) (cdr pair)))
1222 (setq address (assoc (car pair) wl-address-list))
1224 (message "%s, %s, <%s> is %s."
1229 ;;; i'd like to update summary-buffer, but...
1230 ;;; (wl-summary-rescan)
1231 (run-hooks 'wl-summary-edit-addresses-hook))))))
1233 (defun wl-summary-incorporate (&optional arg)
1234 "Check and prefetch all uncached messages.
1235 If ARG is non-nil, checking is omitted."
1239 (wl-summary-sync-force-update)))
1240 (wl-summary-prefetch-region (point-min) (point-max)
1241 wl-summary-incorporate-marks))
1243 (defun wl-summary-prefetch-msg (number &optional arg)
1244 "Returns status-mark. if skipped, returns nil."
1245 ;; prefetching procedure.
1247 (let* ((msgdb (wl-summary-buffer-msgdb))
1248 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1249 (number-alist (elmo-msgdb-get-number-alist msgdb))
1250 (message-id (cdr (assq number number-alist)))
1251 (ov (elmo-msgdb-overview-get-entity message-id msgdb))
1253 (size (elmo-msgdb-overview-entity-get-size ov))
1254 (inhibit-read-only t)
1255 (buffer-read-only nil)
1256 (force-read (and size
1257 (or (null wl-prefetch-threshold)
1258 (< size wl-prefetch-threshold))))
1261 (null (elmo-file-cache-exists-p message-id)))
1264 (when (and size (not force-read) wl-prefetch-confirm)
1270 "Message from %s has %d bytes. Prefetch it? "
1274 (wl-set-string-width
1276 (wl-summary-from-func-internal
1277 (eword-decode-string
1281 (elmo-msgdb-overview-entity-get-from ov)
1284 (message "")) ; flush.
1285 (setq mark (cadr (assq number mark-alist)))
1290 (elmo-message-encache
1291 wl-summary-buffer-elmo-folder
1296 wl-summary-unread-uncached-mark)
1297 wl-summary-unread-cached-mark)
1298 ((string= mark wl-summary-new-mark)
1299 (setq wl-summary-buffer-new-count
1300 (- wl-summary-buffer-new-count 1))
1301 (setq wl-summary-buffer-unread-count
1302 (+ wl-summary-buffer-unread-count 1))
1303 wl-summary-unread-cached-mark)
1304 ((string= mark wl-summary-read-uncached-mark)
1307 (setq mark-alist (elmo-msgdb-mark-set
1308 mark-alist number new-mark))
1309 (or new-mark (setq new-mark " "))
1310 (elmo-msgdb-set-mark-alist msgdb mark-alist)
1311 (wl-summary-set-mark-modified)
1312 (wl-summary-update-modeline)
1313 (wl-folder-update-unread
1314 (wl-summary-buffer-folder-name)
1315 (+ wl-summary-buffer-unread-count
1316 wl-summary-buffer-new-count)))
1319 ;;(defvar wl-summary-message-uncached-marks
1320 ;; (list wl-summary-new-mark
1321 ;; wl-summary-unread-uncached-mark
1322 ;; wl-summary-read-uncached-mark))
1324 (defun wl-summary-prefetch-region (beg end &optional prefetch-marks)
1332 (setq start-pos (point))
1334 (narrow-to-region beg end)
1335 ;; collect prefetch targets.
1336 (message "Collecting marks...")
1337 (goto-char (point-min))
1340 (when (looking-at "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9]\\)")
1341 (setq mark (wl-match-buffer 2))
1342 (setq msg (string-to-int (wl-match-buffer 1)))
1343 (if (or (and (null prefetch-marks)
1345 (null (elmo-file-cache-exists-p
1347 (elmo-msgdb-get-number-alist
1348 (wl-summary-buffer-msgdb)))))))
1349 (member mark prefetch-marks))
1350 (setq targets (nconc targets (list msg))))
1351 (setq entity (wl-thread-get-entity msg))
1352 (if (or (not (eq wl-summary-buffer-view 'thread))
1353 (wl-thread-entity-get-opened entity))
1354 (); opened. no hidden children.
1355 ;; hidden children!!
1356 (setq targets (nconc
1358 (wl-thread-get-children-msgs-uncached
1359 msg prefetch-marks)))))
1361 (setq length (length targets))
1362 (message "Prefetching...")
1364 (setq mark (if (not (wl-thread-entity-parent-invisible-p
1365 (wl-thread-get-entity (car targets))))
1367 (wl-summary-jump-to-msg (car targets))
1368 (wl-summary-prefetch))
1369 (wl-summary-prefetch-msg (car targets))))
1370 (if (if prefetch-marks
1371 (string= mark wl-summary-unread-cached-mark)
1372 (or (string= mark wl-summary-unread-cached-mark)
1373 (string= mark " ")))
1374 (message "Prefetching... %d/%d message(s)"
1375 (setq count (+ 1 count)) length))
1379 (goto-char start-pos)
1380 (if (pos-visible-in-window-p pos)
1384 (setq targets (cdr targets)))
1385 (message "Prefetched %d/%d message(s)" count length)
1386 (cons count length)))))
1388 (defun wl-summary-prefetch (&optional arg)
1389 "Prefetch current message."
1394 (when (looking-at "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9]\\)")
1395 (goto-char (match-beginning 2))
1396 (let ((inhibit-read-only t)
1397 (buffer-read-only nil)
1398 (beg (match-beginning 2))
1401 (setq mark (wl-summary-prefetch-msg
1402 (string-to-int (wl-match-buffer 1)) arg))
1404 (delete-region beg end)
1406 (if wl-summary-highlight
1407 (wl-highlight-summary-current-line)))
1408 (set-buffer-modified-p nil)
1411 (defun wl-summary-delete-all-status-marks-on-buffer ()
1414 (goto-char (point-min))
1415 (let ((inhibit-read-only t)
1416 (buffer-read-only nil)
1417 (case-fold-search nil))
1418 (while (re-search-forward
1419 (concat "^" wl-summary-buffer-number-regexp ".\\(.\\)") nil t)
1420 (delete-region (match-beginning 1) (match-end 1))
1423 (defun wl-summary-delete-marks-on-buffer (marks)
1425 (wl-summary-unmark (pop marks))))
1427 (defun wl-summary-delete-copy-marks-on-buffer (copies)
1428 (wl-summary-delete-marks-on-buffer copies))
1430 (defun wl-summary-delete-all-refile-marks ()
1431 (let ((marks wl-summary-buffer-refile-list))
1433 (wl-summary-unmark (car (pop marks))))))
1435 (defun wl-summary-delete-all-copy-marks ()
1436 (let ((marks wl-summary-buffer-copy-list))
1438 (wl-summary-unmark (car (pop marks))))))
1440 (defun wl-summary-delete-all-delete-marks ()
1441 (wl-summary-delete-marks-on-buffer wl-summary-buffer-delete-list))
1443 (defun wl-summary-delete-all-target-marks ()
1444 (wl-summary-delete-marks-on-buffer wl-summary-buffer-target-mark-list))
1446 (defun wl-summary-delete-all-temp-marks-on-buffer (&optional sticky)
1447 ;; for summary view cache saving.
1450 (goto-char (point-min))
1451 (let ((inhibit-read-only t)
1452 (buffer-read-only nil)
1453 (case-fold-search nil)
1454 (regexp (concat "^" wl-summary-buffer-number-regexp "\\([^ ]\\)" )))
1455 (while (re-search-forward regexp nil t)
1456 (delete-region (match-beginning 1) (match-end 1))
1458 (if (and sticky wl-summary-highlight)
1459 (wl-highlight-summary-current-line))))))
1461 (defun wl-summary-delete-all-marks (mark-alist mark)
1462 "Delete all MARKs in MARK-ALIST."
1463 (let ((malist mark-alist)
1464 (ret-val mark-alist)
1467 (setq entity (car malist))
1468 (if (string= (cadr entity) mark)
1469 ;; delete this entity
1470 (setq ret-val (delete entity ret-val)))
1471 (setq malist (cdr malist)))
1474 ;; Does not work correctly...
1475 (defun wl-summary-mark-as-read-region (beg end)
1479 (narrow-to-region beg end)
1481 ;;; (save-excursion (goto-char end)
1482 ;;; (end-of-line) (point)))
1483 (goto-char (point-min))
1484 (if (eq wl-summary-buffer-view 'thread)
1487 (let* ((number (wl-summary-message-number))
1488 (entity (wl-thread-get-entity number))
1490 (if (wl-thread-entity-get-opened entity)
1491 ;; opened...mark line.
1492 ;; Crossposts are not processed
1493 (wl-summary-mark-as-read t)
1495 (wl-summary-mark-as-read t) ; mark itself.
1496 (setq children (wl-thread-get-children-msgs number))
1498 (wl-summary-mark-as-read t nil nil (car children))
1499 (setq children (cdr children))))
1502 (wl-summary-mark-as-read t)
1503 (forward-line 1)))))
1504 (wl-summary-count-unread (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
1505 (wl-summary-update-modeline))
1507 (defun wl-summary-mark-as-unread-region (beg end)
1511 (narrow-to-region beg end)
1513 ;;; (save-excursion (goto-char end)
1514 ;;; (end-of-line) (point)))
1515 (goto-char (point-min))
1516 (if (eq wl-summary-buffer-view 'thread)
1519 (let* ((number (wl-summary-message-number))
1520 (entity (wl-thread-get-entity number))
1522 (if (wl-thread-entity-get-opened entity)
1523 ;; opened...mark line.
1524 ;; Crossposts are not processed
1525 (wl-summary-mark-as-unread)
1527 (wl-summary-mark-as-unread) ; mark itself.
1529 (delq number (wl-thread-get-children-msgs number)))
1531 (wl-summary-mark-as-unread (car children))
1532 (setq children (cdr children))))
1535 (wl-summary-mark-as-unread)
1536 (forward-line 1)))))
1537 (wl-summary-count-unread (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
1538 (wl-summary-update-modeline))
1540 (defun wl-summary-mark-as-important-region (beg end)
1544 (narrow-to-region beg end);(save-excursion (goto-char end)
1545 ; (end-of-line) (point)))
1546 (goto-char (point-min))
1547 (if (eq wl-summary-buffer-view 'thread)
1550 (let* ((number (wl-summary-message-number))
1551 (entity (wl-thread-get-entity number))
1553 (if (wl-thread-entity-get-opened entity)
1554 ;; opened...mark line.
1555 ;; Crossposts are not processed
1556 (wl-summary-mark-as-important)
1558 (wl-summary-mark-as-important) ; mark itself.
1560 (delq number (wl-thread-get-children-msgs number)))
1562 (wl-thread-msg-mark-as-important (car children))
1563 (setq children (cdr children))))
1566 (wl-summary-mark-as-important)
1567 (forward-line 1)))))
1568 (wl-summary-count-unread (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
1569 (wl-summary-update-modeline))
1571 (defun wl-summary-mark-as-read-all ()
1573 (if (or (not (interactive-p))
1574 (y-or-n-p "Mark all messages as read? "))
1575 (let* ((folder wl-summary-buffer-elmo-folder)
1576 (cur-buf (current-buffer))
1577 (msgdb (wl-summary-buffer-msgdb))
1578 ;;; (number-alist (elmo-msgdb-get-number-alist msgdb))
1579 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1581 (inhibit-read-only t)
1582 (buffer-read-only nil)
1583 (case-fold-search nil)
1585 (message "Setting all msgs as read...")
1586 (elmo-folder-mark-as-read folder
1587 (elmo-folder-list-unreads
1589 (list wl-summary-unread-cached-mark
1590 wl-summary-unread-uncached-mark
1591 wl-summary-new-mark)))
1593 (goto-char (point-min))
1594 (while (re-search-forward "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9 ]\\)" nil t)
1595 (setq msg (string-to-int (wl-match-buffer 1)))
1596 (setq mark (wl-match-buffer 2))
1597 (when (and (not (string= mark wl-summary-important-mark))
1598 (not (string= mark wl-summary-read-uncached-mark)))
1599 (delete-region (match-beginning 2) (match-end 2))
1600 (if (or (not (elmo-message-use-cache-p folder msg))
1601 (string= mark wl-summary-unread-cached-mark))
1605 (elmo-msgdb-mark-set
1608 ;;; Use msg instead of (cdr (assq msg number-alist)).
1609 ;;; (cdr (assq msg number-alist))
1611 ;; New mark and unread-uncached mark
1612 (insert wl-summary-read-uncached-mark)
1614 (elmo-msgdb-mark-set mark-alist
1616 ;;; (cdr (assq msg number-alist))
1617 wl-summary-read-uncached-mark)))
1618 (if wl-summary-highlight
1619 (wl-highlight-summary-current-line nil nil t)))))
1620 (setq mark-alist (wl-summary-set-as-read-mark-alist mark-alist))
1621 (wl-summary-set-mark-modified)
1622 (set-buffer cur-buf); why is this needed???
1623 (elmo-msgdb-set-mark-alist msgdb mark-alist)
1624 (wl-folder-update-unread (wl-summary-buffer-folder-name) 0)
1625 (setq wl-summary-buffer-unread-count 0)
1626 (setq wl-summary-buffer-new-count 0)
1627 (wl-summary-update-modeline)
1628 (message "Setting all msgs as read...done")
1629 (set-buffer-modified-p nil))))
1631 (defun wl-summary-delete-cache ()
1632 "Delete cache of current message."
1635 (let* ((inhibit-read-only t)
1636 (buffer-read-only nil)
1637 (folder wl-summary-buffer-elmo-folder)
1638 (msgdb (wl-summary-buffer-msgdb))
1639 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1640 (number-alist (elmo-msgdb-get-number-alist msgdb))
1641 (case-fold-search nil)
1642 mark number unread new-mark)
1643 ;;; (re-search-backward "^ *[0-9]+..[0-9]+/[0-9]+" nil t) ; set cursor line
1645 (when (looking-at "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9]\\)")
1647 (setq mark (wl-match-buffer 2))
1649 ((or (string= mark wl-summary-new-mark)
1650 (string= mark wl-summary-unread-uncached-mark)
1651 (string= mark wl-summary-important-mark))
1654 ((string= mark wl-summary-unread-cached-mark)
1655 (setq new-mark wl-summary-unread-uncached-mark))
1657 (setq new-mark wl-summary-read-uncached-mark)))
1659 (setq number (string-to-int (wl-match-buffer 1)))
1660 (delete-region (match-beginning 2) (match-end 2))
1661 (goto-char (match-beginning 2))
1663 (elmo-file-cache-delete
1664 (elmo-file-cache-get-path
1665 (elmo-message-field wl-summary-buffer-elmo-folder
1669 (elmo-msgdb-mark-set mark-alist number new-mark))
1670 (elmo-msgdb-set-mark-alist msgdb mark-alist)
1671 (wl-summary-set-mark-modified)
1672 (if wl-summary-highlight
1673 (wl-highlight-summary-current-line nil nil t))
1674 (set-buffer-modified-p nil)))))))
1676 (defun wl-summary-resume-cache-status ()
1677 "Resume the cache status of all messages in the current folder."
1679 (let* ((folder wl-summary-buffer-elmo-folder)
1680 (cur-buf (current-buffer))
1681 (msgdb (wl-summary-buffer-msgdb))
1682 (number-alist (elmo-msgdb-get-number-alist msgdb))
1683 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1684 (inhibit-read-only t)
1685 (buffer-read-only nil)
1686 (case-fold-search nil)
1687 msg mark msgid set-mark)
1688 (message "Resuming cache status...")
1690 (goto-char (point-min))
1691 (while (re-search-forward "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9]\\)" nil t)
1692 (setq msg (string-to-int
1693 (wl-match-buffer 1)))
1694 (setq mark (wl-match-buffer 2))
1695 (setq msgid (cdr (assq msg number-alist)))
1697 (if (elmo-file-cache-exists-p msgid)
1699 (string= mark wl-summary-unread-uncached-mark) ; U -> !
1700 (string= mark wl-summary-new-mark) ; N -> !
1702 (setq set-mark wl-summary-unread-cached-mark)
1703 (if (string= mark wl-summary-read-uncached-mark) ; u -> ' '
1704 (setq set-mark " ")))
1705 (if (string= mark " ")
1706 (setq set-mark wl-summary-read-uncached-mark) ;' ' -> u
1707 (if (string= mark wl-summary-unread-cached-mark)
1708 (setq set-mark wl-summary-unread-uncached-mark) ; ! -> U
1711 (delete-region (match-beginning 2) (match-end 2))
1714 (elmo-msgdb-mark-set
1715 mark-alist msg ; msgid
1716 (if (string= set-mark " ") nil set-mark)))
1717 (if wl-summary-highlight
1718 (wl-highlight-summary-current-line))))
1719 (wl-summary-set-mark-modified)
1720 (set-buffer cur-buf); why is this needed???
1721 (elmo-msgdb-set-mark-alist msgdb mark-alist)
1722 (wl-summary-count-unread mark-alist)
1723 (wl-summary-update-modeline)
1724 (message "Resuming cache status...done")
1725 (set-buffer-modified-p nil))))
1727 (defun wl-summary-resume-marks-and-highlight ()
1728 (let* ((msgdb (wl-summary-buffer-msgdb))
1729 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1730 ;;; (number-alist (elmo-msgdb-get-number-alist msgdb))
1731 (count (count-lines (point-min)(point-max)))
1733 msg-num percent smark)
1735 (goto-char (point-min))
1736 (message "Resuming all marks...")
1738 (setq msg-num (wl-summary-message-number))
1739 (setq smark (car (cdr (assq msg-num mark-alist))))
1740 (if (looking-at (format "^ *%s \\( \\)" msg-num))
1742 (goto-char (match-end 1))
1743 (delete-region (match-beginning 1) (match-end 1))
1744 (insert (or smark " "))))
1745 (wl-highlight-summary-current-line smark)
1746 (when (> count elmo-display-progress-threshold)
1748 (setq percent (/ (* i 100) count))
1749 (elmo-display-progress
1750 'wl-summary-resume-marks-and-highlight "Resuming all marks..."
1753 (message "Resuming all marks...done")))
1755 (defun wl-summary-resume-marks ()
1756 (let* ((msgdb (wl-summary-buffer-msgdb))
1757 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1758 (number-alist (elmo-msgdb-get-number-alist msgdb))
1759 (count (length mark-alist))
1761 entity msg-num percent)
1763 (message "Resuming all marks...")
1765 (setq entity (car mark-alist))
1766 (if (setq msg-num (car (rassoc (car entity) number-alist)))
1768 ;;; (goto-char (point-min))
1769 (if (re-search-forward (format "^ *%s \\( \\)" msg-num) nil t)
1771 (delete-region (match-beginning 1) (match-end 1))
1772 (insert (or (cadr entity)
1774 (if (re-search-backward (format "^ *%s \\( \\)" msg-num) nil t)
1776 (goto-char (match-end 1))
1777 (delete-region (match-beginning 1) (match-end 1))
1778 (insert (or (cadr entity)
1780 (when (> count elmo-display-progress-threshold)
1782 (setq percent (/ (* i 100) count))
1783 (elmo-display-progress
1784 'wl-summary-resume-marks "Resuming all marks..."
1786 (setq mark-alist (cdr mark-alist)))
1787 (message "Resuming all marks...done"))))
1789 (defun wl-summary-delete-messages-on-buffer (msgs &optional deleting-info)
1792 (let ((inhibit-read-only t)
1793 (buffer-read-only nil)
1798 (elmo-kill-buffer wl-summary-search-buf-name)
1800 (if (eq wl-summary-buffer-view 'thread)
1802 ;; don't use wl-append(nconc), because list is broken. ...why?
1805 (wl-thread-delete-message (car msgs))))
1806 (setq update-list (delq (car msgs) update-list)))
1807 (goto-char (point-min))
1808 (if (re-search-forward (format "^ *%d[^0-9]\\([^0-9]\\).*$"
1811 (delete-region (match-beginning 0) (match-end 0))
1812 (delete-char 1) ; delete '\n'
1813 (setq wl-summary-buffer-number-list
1814 (delq (car msgs) wl-summary-buffer-number-list)))))
1815 (when (and deleting-info
1816 (> len elmo-display-progress-threshold))
1818 (if (or (zerop (% i 5)) (= i len))
1819 (elmo-display-progress
1820 'wl-summary-delete-messages-on-buffer deleting-info
1821 (/ (* i 100) len))))
1822 (setq msgs (cdr msgs)))
1823 (when (eq wl-summary-buffer-view 'thread)
1824 (wl-thread-update-line-msgs (elmo-uniq-list update-list)
1825 (unless deleting-info 'no-msg))
1826 (wl-thread-cleanup-symbols msgs2))
1827 (wl-summary-count-unread
1828 (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
1829 (wl-summary-update-modeline)
1830 (wl-folder-update-unread
1831 (wl-summary-buffer-folder-name)
1832 (+ wl-summary-buffer-unread-count wl-summary-buffer-new-count)))))
1834 (defun wl-summary-set-as-read-mark-alist (mark-alist)
1835 (let ((marks (list (cons wl-summary-unread-cached-mark
1837 (cons wl-summary-unread-uncached-mark
1838 wl-summary-read-uncached-mark)
1839 (cons wl-summary-new-mark
1840 wl-summary-read-uncached-mark)))
1841 (ret-val mark-alist)
1844 (setq entity (car mark-alist))
1845 (when (setq pair (assoc (cadr entity) marks))
1846 (if (elmo-message-use-cache-p wl-summary-buffer-elmo-folder
1849 (setcar (cdr entity) (cdr pair))
1850 (setq ret-val (delete entity ret-val)))
1851 (setq ret-val (delete entity ret-val))))
1852 (setq mark-alist (cdr mark-alist)))
1855 (defun wl-summary-set-status-marks (mark-alist before after)
1856 "Set the BEFORE marks to AFTER."
1857 (let ((ret-val mark-alist)
1860 (setq entity (car mark-alist))
1861 (when (string= (cadr entity) before)
1863 (setcar (cdr entity) after)
1864 (setq ret-val (delete entity ret-val))))
1865 (setq mark-alist (cdr mark-alist)))
1868 (defun wl-summary-set-status-marks-on-buffer (before after)
1869 "Set the MARKS marks on buffer."
1872 (goto-char (point-min))
1873 (let ((inhibit-read-only t)
1874 (buffer-read-only nil)
1875 (regexp (concat "^" wl-summary-buffer-number-regexp ".\\(\\%s\\)")))
1876 (while (re-search-forward
1877 (format regexp (regexp-quote before)) nil t)
1878 (delete-region (match-beginning 1) (match-end 1))
1880 (if wl-summary-highlight
1881 (wl-highlight-summary-current-line))))))
1883 (defun wl-summary-get-delete-folder (folder)
1884 (if (string= folder wl-trash-folder)
1886 (let* ((type (or (wl-get-assoc-list-value wl-delete-folder-alist folder)
1888 (cond ((stringp type)
1890 ((or (equal type 'remove) (equal type 'null))
1892 (t;; (equal type 'trash)
1893 wl-trash-folder)))))
1895 (defun wl-summary-delete-important-msgs-from-list (delete-list
1897 (let ((dlist delete-list))
1899 (if (string= wl-summary-important-mark
1900 (car (cdr (assq (car dlist) mark-alist))))
1901 (setq delete-list (delete (car dlist) delete-list)))
1902 (setq dlist (cdr dlist)))
1905 (defun wl-summary-delete-canceled-msgs-from-list (delete-list msgdb)
1906 (let ((dlist delete-list))
1908 (if (null (cdr (assq (car dlist) (cadr msgdb))))
1909 (setq delete-list (delete (car dlist) delete-list)))
1910 (setq dlist (cdr dlist)))
1913 (defun wl-summary-get-append-message-func ()
1914 (if (eq wl-summary-buffer-view 'thread)
1915 'wl-summary-insert-thread-entity
1916 ;;; 'wl-summary-insert-thread
1917 'wl-summary-insert-summary))
1919 (defun wl-summary-sort ()
1921 (let ((sort-by (let ((input-range-list '("number" "date" "subject" "from"))
1926 (format "Sort by (%s): " default)
1928 (function (lambda (x) (cons x x)))
1933 (if (not (member sort-by '("number" "date" "subject" "from")))
1934 (error "Sort by %s is not implemented" sort-by))
1935 (wl-summary-rescan sort-by)))
1937 (defun wl-summary-sync-marks ()
1938 "Update marks in summary."
1940 (let ((last-progress 0)
1942 mark-alist unread-marks importants unreads
1943 importants-in-db unreads-in-db diff diffs
1944 mes num-ma progress)
1945 ;; synchronize marks.
1946 (when (not (eq (elmo-folder-type-internal
1947 wl-summary-buffer-elmo-folder)
1949 (message "Updating marks...")
1950 (setq unread-marks (list wl-summary-unread-cached-mark
1951 wl-summary-unread-uncached-mark
1952 wl-summary-new-mark)
1953 mark-alist (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb))
1954 num-ma (length mark-alist)
1955 importants (elmo-folder-list-importants
1956 wl-summary-buffer-elmo-folder
1957 wl-summary-important-mark)
1958 unreads (elmo-folder-list-unreads
1959 wl-summary-buffer-elmo-folder
1962 (if (string= (cadr (car mark-alist))
1963 wl-summary-important-mark)
1964 (setq importants-in-db (cons (car (car mark-alist))
1966 (if (member (cadr (car mark-alist)) unread-marks)
1967 (setq unreads-in-db (cons (car (car mark-alist))
1969 (setq mark-alist (cdr mark-alist))
1970 (when (> num-ma elmo-display-progress-threshold)
1972 progress (/ (* i 100) num-ma))
1973 (if (not (eq progress last-progress))
1974 (elmo-display-progress 'wl-summary-sync-marks
1977 (setq last-progress progress)))
1978 (setq diff (elmo-list-diff importants importants-in-db))
1979 (setq diffs (cadr diff)) ; important-deletes
1980 (setq mes (format "Updated (-%d" (length diffs)))
1982 (wl-summary-mark-as-important (car diffs)
1983 wl-summary-important-mark
1985 (setq diffs (cdr diffs)))
1986 (setq diffs (car diff)) ; important-appends
1987 (setq mes (concat mes (format "/+%d) important," (length diffs))))
1989 (wl-summary-mark-as-important (car diffs) " " 'no-server)
1990 (setq diffs (cdr diffs)))
1991 (setq diff (elmo-list-diff unreads unreads-in-db))
1992 (setq diffs (cadr diff))
1993 (setq mes (concat mes (format "(-%d" (length diffs))))
1995 (wl-summary-mark-as-read t 'no-server nil (car diffs))
1996 (setq diffs (cdr diffs)))
1997 (setq diffs (car diff)) ; unread-appends
1998 (setq mes (concat mes (format "/+%d) unread mark(s)." (length diffs))))
2000 (wl-summary-mark-as-unread (car diffs) 'no-server 'no-modeline)
2001 (setq diffs (cdr diffs)))
2002 (if (interactive-p) (message mes)))))
2004 (defun wl-summary-confirm-appends (appends)
2005 (let ((len (length appends))
2007 (if (> len wl-summary-update-confirm-threshold)
2008 (if (y-or-n-p (format "Too many messages(%d). Continue? " len))
2010 (setq in wl-summary-update-confirm-threshold)
2013 (setq in (read-from-minibuffer "Update number: "
2015 in (string-to-int in))
2018 (if (y-or-n-p (format "%d messages are disappeared. OK? "
2019 (max (- len in) 0)))
2021 (nthcdr (max (- len in) 0) appends))
2024 (defun wl-summary-sync-update (&optional unset-cursor sync-all no-check)
2025 "Update the summary view to the newest folder status."
2027 (let* ((folder wl-summary-buffer-elmo-folder)
2028 (case-fold-search nil)
2029 (elmo-mime-charset wl-summary-buffer-mime-charset)
2030 (inhibit-read-only t)
2031 (buffer-read-only nil)
2032 (elmo-folder-update-threshold wl-summary-update-confirm-threshold)
2034 overview number-alist mark-alist
2035 curp num i new-msgdb
2036 append-list delete-list crossed
2037 update-thread update-top-list
2038 expunged mes sync-result)
2039 (unless wl-summary-buffer-elmo-folder
2040 (error "(Internal error) Folder is not set:%s" (buffer-name
2042 (fset 'wl-summary-append-message-func-internal
2043 (wl-summary-get-append-message-func))
2044 ;; Flush pending append operations (disconnected operation).
2046 ;;(wl-summary-flush-pending-append-operations seen-list))
2047 (goto-char (point-max))
2048 (wl-folder-confirm-existence folder 'force)
2049 (setq sync-result (elmo-folder-synchronize
2052 wl-summary-unread-uncached-mark
2053 wl-summary-unread-cached-mark
2054 wl-summary-read-uncached-mark
2055 wl-summary-important-mark
2057 (setq new-msgdb (nth 0 sync-result))
2058 (setq delete-list (nth 1 sync-result))
2059 (setq crossed (nth 2 sync-result))
2063 (if sync-all (wl-summary-sync-all-init))
2065 ; (elmo-nntp-max-number-precedes-list-active-p))
2066 ;; XXX this does not work correctly in rare case.
2068 ; (wl-summary-delete-canceled-msgs-from-list
2070 ; (wl-summary-buffer-msgdb))))
2072 (wl-summary-delete-messages-on-buffer delete-list "Deleting...")
2073 (message "Deleting...done"))
2075 (wl-summary-set-status-marks-on-buffer
2077 wl-summary-unread-uncached-mark))
2078 (setq append-list (elmo-msgdb-get-overview new-msgdb))
2079 (setq curp append-list)
2080 (setq num (length curp))
2083 ;; set these value for append-message-func
2084 (setq overview (elmo-msgdb-get-overview
2085 (elmo-folder-msgdb folder)))
2086 (setq number-alist (elmo-msgdb-get-number-alist
2087 (elmo-folder-msgdb folder)))
2088 (setq mark-alist (elmo-msgdb-get-mark-alist
2089 (elmo-folder-msgdb folder)))
2090 (setq wl-summary-delayed-update nil)
2091 (elmo-kill-buffer wl-summary-search-buf-name)
2093 (setq entity (car curp))
2094 (when (setq update-thread
2095 (wl-summary-append-message-func-internal
2096 entity overview mark-alist
2098 (wl-append update-top-list update-thread))
2099 (if elmo-use-database
2100 (elmo-database-msgid-put
2101 (car entity) (elmo-folder-name-internal folder)
2102 (elmo-msgdb-overview-entity-get-number entity)))
2103 (setq curp (cdr curp))
2104 (when (> num elmo-display-progress-threshold)
2106 (if (or (zerop (% i 5)) (= i num))
2107 (elmo-display-progress
2108 'wl-summary-sync-update "Updating thread..."
2109 (/ (* i 100) num)))))
2110 (when wl-summary-delayed-update
2111 (while wl-summary-delayed-update
2112 (message "Parent (%d) of message %d is no entity"
2113 (caar wl-summary-delayed-update)
2114 (elmo-msgdb-overview-entity-get-number
2115 (cdar wl-summary-delayed-update)))
2116 (when (setq update-thread
2117 (wl-summary-append-message-func-internal
2118 (cdar wl-summary-delayed-update)
2119 overview mark-alist (not sync-all) t))
2120 (wl-append update-top-list update-thread))
2121 (setq wl-summary-delayed-update
2122 (cdr wl-summary-delayed-update))))
2123 (when (and (eq wl-summary-buffer-view 'thread)
2125 (wl-thread-update-indent-string-thread
2126 (elmo-uniq-list update-top-list)))
2127 (message "Updating thread...done"))
2128 (unless (eq wl-summary-buffer-view 'thread)
2129 (wl-summary-make-number-list))
2130 (wl-summary-set-message-modified)
2131 (wl-summary-set-mark-modified)
2132 (when (and sync-all (eq wl-summary-buffer-view 'thread))
2133 (elmo-kill-buffer wl-summary-search-buf-name)
2134 (message "Inserting thread...")
2135 (setq wl-thread-entity-cur 0)
2136 (wl-thread-insert-top)
2137 (message "Inserting thread...done"))
2138 (if elmo-use-database
2139 (elmo-database-close))
2140 (run-hooks 'wl-summary-sync-updated-hook)
2142 (if (and (eq (length delete-list) 0)
2145 "No updates for \"%s\"" (elmo-folder-name-internal
2147 (format "Updated (-%d/+%d) message(s)"
2148 (length delete-list) num))))
2149 (setq mes "Quit updating."))
2150 ;; synchronize marks.
2151 (if (and wl-summary-auto-sync-marks sync-result)
2152 (wl-summary-sync-marks))
2154 (when wl-use-scoring
2155 (setq wl-summary-scored nil)
2156 (wl-summary-score-headers nil (wl-summary-buffer-msgdb)
2158 (wl-summary-rescore-msgs number-alist))
2160 (when (and wl-summary-scored
2161 (setq expunged (wl-summary-score-update-all-lines)))
2162 (setq mes (concat mes
2163 (format " (%d expunged)"
2164 (length expunged))))))
2165 (if (and crossed (> crossed 0))
2169 (format " (%d crosspost)" crossed))
2170 (format "%d crosspost message(s)" crossed)))
2171 (and mes (setq mes (concat mes "."))))
2172 ;; Update Folder mode
2173 (wl-folder-set-folder-updated
2174 (elmo-folder-name-internal folder)
2176 (wl-summary-count-unread
2177 (elmo-msgdb-get-mark-alist
2178 (elmo-folder-msgdb folder)))
2179 (elmo-folder-messages folder)))
2180 (wl-summary-update-modeline)
2181 (wl-summary-buffer-number-column-detect t)
2183 (unless unset-cursor
2184 (goto-char (point-min))
2185 (if (not (wl-summary-cursor-down t))
2187 (goto-char (point-max))
2189 (if (and wl-summary-highlight
2190 (not (get-text-property (point) 'face)))
2194 wl-summary-partial-highlight-above-lines
2195 wl-summary-highlight-partial-threshold)))
2196 (wl-highlight-summary (point) (point-max))))))
2197 (setq wl-summary-buffer-msgdb (elmo-folder-msgdb folder))
2198 (wl-delete-all-overlays)
2199 (set-buffer-modified-p nil)
2200 (if mes (message "%s" mes))))
2202 (defun wl-summary-set-score-mark (mark)
2205 (let ((inhibit-read-only t)
2206 (buffer-read-only nil)
2209 (when (looking-at "^ *\\(-?[0-9]+\\)\\([^0-9]\\)")
2210 (setq msg-num (string-to-int (wl-match-buffer 1)))
2211 (setq cur-mark (wl-match-buffer 2))
2212 (when (member cur-mark (list " "
2213 wl-summary-score-below-mark
2214 wl-summary-score-over-mark))
2215 (goto-char (match-end 1))
2216 (delete-region (match-beginning 2) (match-end 2))
2218 (if wl-summary-highlight
2219 (wl-highlight-summary-current-line nil nil t))
2220 (set-buffer-modified-p nil))))))
2222 (defun wl-summary-get-score-mark (msg-num)
2223 (let ((score (cdr (assq msg-num wl-summary-scored))))
2225 (cond ((< score wl-summary-default-score)
2227 ((> score wl-summary-default-score)
2230 (defun wl-summary-update-modeline ()
2231 (setq wl-summary-buffer-unread-status
2232 (format " {%s}(%d new/%d unread)"
2233 (if (eq wl-summary-buffer-view 'thread)
2235 wl-summary-buffer-new-count
2236 (+ wl-summary-buffer-new-count
2237 wl-summary-buffer-unread-count))))
2239 (defsubst wl-summary-jump-to-msg (&optional number)
2241 (let ((num (or number
2243 (read-from-minibuffer "Jump to Message(No.): ")))))
2244 (setq num (int-to-string num))
2245 (if (re-search-forward (concat "^[ \t]*" num "[^0-9]") nil t)
2249 (if (re-search-backward (concat "^[ \t]*" num "[^0-9]") nil t)
2255 (defun wl-summary-highlight-msgs (msgs)
2257 (let ((len (length msgs))
2259 (message "Hilighting...")
2262 (if (wl-summary-jump-to-msg (car msgs))
2263 (wl-highlight-summary-current-line))
2264 (setq msgs (cdr msgs))
2265 (when (> len elmo-display-progress-threshold)
2267 (if (or (zerop (% i 5)) (= i len))
2268 (elmo-display-progress
2269 'wl-summary-highlight-msgs "Highlighting..."
2270 (/ (* i 100) len)))))
2271 (message "Highlighting...done"))))
2273 (defun wl-summary-message-number ()
2276 (if (looking-at "^ *\\(-?[0-9]+\\)")
2277 (string-to-int (wl-match-buffer 1))
2280 (defun wl-summary-move (src dsts-msgs)
2281 (let* ((dsts (car dsts-msgs)) ; (+foo +bar)
2282 ;;; (msgs (cdr dsts-msgs)) ; (1 2 3)
2283 ;;; (msgdb (wl-summary-buffer-msgdb))
2287 (setq dsts (cdr dsts)))))
2289 (defun wl-summary-delete-all-msgs ()
2291 (let ((cur-buf (current-buffer))
2292 (dels (elmo-folder-list-messages wl-summary-buffer-elmo-folder)))
2293 (set-buffer cur-buf)
2295 (message "No message to delete.")
2296 (if (y-or-n-p (format "%s has %d message(s). Delete all? "
2297 (wl-summary-buffer-folder-name)
2300 (message "Deleting...")
2301 (elmo-folder-delete-messages
2302 wl-summary-buffer-elmo-folder dels)
2303 (elmo-msgdb-delete-msgs (wl-summary-buffer-msgdb)
2305 ;;; (elmo-msgdb-save (wl-summary-buffer-folder-name) nil)
2306 (wl-summary-set-message-modified)
2307 (wl-summary-set-mark-modified)
2308 (wl-folder-set-folder-updated (wl-summary-buffer-folder-name)
2311 ;;; (setq wl-thread-top-entity '(nil t nil nil))
2312 (setq wl-summary-buffer-unread-count 0)
2313 (setq wl-summary-buffer-new-count 0)
2314 (wl-summary-update-modeline)
2315 (set-buffer cur-buf)
2316 (let ((inhibit-read-only t)
2317 (buffer-read-only nil))
2319 ;;; (if wl-summary-cache-use (wl-summary-save-view-cache))
2320 (message "Deleting...done")
2324 (defun wl-summary-toggle-thread (&optional arg)
2325 "Toggle thread status (T)hread and (S)equential.
2326 If ARG, without confirm."
2329 (y-or-n-p (format "Toggle threading? (y=%s): "
2330 (if (eq wl-summary-buffer-view 'thread)
2331 "\"off\"" "\"on\""))))
2332 (if (eq wl-summary-buffer-view 'thread)
2333 (setq wl-summary-buffer-view 'sequence)
2334 (setq wl-summary-buffer-view 'thread))
2335 (wl-summary-update-modeline)
2336 (force-mode-line-update)
2337 (wl-summary-rescan)))
2339 (defun wl-summary-load-file-object (filename)
2340 "Load lisp object from dir."
2342 (let ((tmp-buffer (get-buffer-create " *wl-summary-load-file-object*"))
2343 insert-file-contents-pre-hook ; To avoid autoconv-xmas...
2344 insert-file-contents-post-hook
2346 (if (not (file-readable-p filename))
2348 (set-buffer tmp-buffer)
2349 (as-binary-input-file (insert-file-contents filename))
2352 (read (current-buffer))
2353 (error (error "Reading failed")))))
2354 (kill-buffer tmp-buffer)
2357 (defun wl-summary-goto-folder (&optional arg)
2359 (wl-summary-goto-folder-subr nil nil nil arg t))
2361 (defun wl-summary-goto-last-visited-folder ()
2364 (wl-folder-search-entity-by-name wl-summary-last-visited-folder
2367 (if entity (wl-folder-set-current-entity-id
2368 (wl-folder-get-entity-id entity))))
2369 (wl-summary-goto-folder-subr wl-summary-last-visited-folder nil nil nil t))
2371 (defun wl-summary-sticky-p (&optional folder)
2373 (get-buffer (wl-summary-sticky-buffer-name
2374 (elmo-folder-name-internal folder)))
2375 (not (string= wl-summary-buffer-name (buffer-name)))))
2377 (defun wl-summary-always-sticky-folder-p (folder)
2378 (or (eq t wl-summary-always-sticky-folder-list)
2379 (wl-string-match-member
2380 (elmo-folder-name-internal folder)
2381 wl-summary-always-sticky-folder-list)))
2383 (defun wl-summary-stick (&optional force)
2384 "Make current summary buffer sticky."
2386 (if (wl-summary-sticky-p)
2387 (message "Current summary buffer is already sticky.")
2388 (when (or force (y-or-n-p "Stick current summary buffer? "))
2389 (wl-summary-toggle-disp-msg 'off)
2390 (wl-summary-switch-to-clone-buffer
2391 (wl-summary-sticky-buffer-name
2392 (wl-summary-buffer-folder-name)))
2394 ;;; (rename-buffer (wl-summary-sticky-buffer-name
2395 ;;; (wl-summary-buffer-folder-name))))
2396 (message "Folder `%s' is now sticky." (wl-summary-buffer-folder-name)))))
2398 (defun wl-summary-switch-to-clone-buffer (buffer-name)
2399 (let ((cur-buf (current-buffer))
2400 (msg (wl-summary-message-number))
2401 (buf (get-buffer-create buffer-name))
2402 (folder wl-summary-buffer-elmo-folder)
2404 (append '(wl-summary-buffer-view
2405 wl-summary-buffer-refile-list
2406 wl-summary-buffer-delete-list
2407 wl-summary-buffer-copy-list
2408 wl-summary-buffer-target-mark-list
2409 wl-summary-buffer-elmo-folder
2410 wl-summary-buffer-number-column
2411 wl-summary-buffer-number-regexp
2412 wl-summary-buffer-message-modified
2413 wl-summary-buffer-mark-modified
2414 wl-summary-buffer-thread-modified
2415 wl-summary-buffer-number-list
2416 wl-summary-buffer-msgdb
2417 wl-summary-buffer-folder-name)
2418 (and (eq wl-summary-buffer-view 'thread)
2419 '(wl-thread-entity-hashtb
2421 wl-thread-entity-list))
2424 wl-summary-default-score
2425 wl-summary-important-above
2426 wl-summary-target-above
2427 wl-summary-mark-below
2428 wl-summary-expunge-below))
2429 (and (featurep 'wl-score)
2430 '(wl-current-score-file
2434 (wl-summary-buffer-set-folder folder)
2435 (let ((buffer-read-only nil))
2436 (insert-buffer cur-buf))
2437 (set-buffer-modified-p nil)
2438 (while copy-variables
2439 (set (car copy-variables)
2441 (set-buffer cur-buf)
2442 (symbol-value (car copy-variables))))
2443 (setq copy-variables (cdr copy-variables)))
2444 (switch-to-buffer buf)
2445 (kill-buffer cur-buf)
2446 (wl-summary-count-unread
2447 (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
2448 (wl-summary-update-modeline)
2450 (if (eq wl-summary-buffer-view 'thread)
2451 (wl-thread-jump-to-msg msg)
2452 (wl-summary-jump-to-msg msg))
2453 (goto-char (point-max))
2454 (beginning-of-line))))
2456 (defun wl-summary-get-buffer (folder)
2458 (get-buffer (wl-summary-sticky-buffer-name folder)))
2459 (get-buffer wl-summary-buffer-name)))
2461 (defun wl-summary-get-buffer-create (name &optional force-sticky)
2464 (wl-summary-sticky-buffer-name name))
2465 (or (get-buffer (wl-summary-sticky-buffer-name name))
2466 (get-buffer-create wl-summary-buffer-name))))
2468 (defun wl-summary-make-number-list ()
2469 (setq wl-summary-buffer-number-list
2471 (lambda (x) (elmo-msgdb-overview-entity-get-number x))
2472 (elmo-msgdb-get-overview (wl-summary-buffer-msgdb)))))
2474 (defun wl-summary-auto-select-msg-p (unread-msg)
2477 (cadr (assoc unread-msg
2478 (elmo-msgdb-get-mark-alist
2479 (wl-summary-buffer-msgdb))))
2480 wl-summary-important-mark))))
2482 (defsubst wl-summary-open-folder (folder)
2485 (elmo-folder-open folder 'load-msgdb)
2486 ;; For compatibility
2487 (setq wl-summary-buffer-msgdb (elmo-folder-msgdb folder))
2488 (setq wl-summary-buffer-folder-name (elmo-folder-name-internal folder))))
2490 (defun wl-summary-goto-folder-subr (&optional name scan-type other-window
2491 sticky interactive scoring)
2492 "Display target folder on summary."
2494 (let* ((keep-cursor (memq this-command
2495 wl-summary-keep-cursor-command))
2496 (name (or name (wl-summary-read-folder wl-default-folder)))
2497 (cur-fld wl-summary-buffer-elmo-folder)
2498 folder buf mes hilit reuse-buf
2500 (if (string= name "")
2501 (setq name wl-default-folder))
2502 (setq folder (wl-folder-get-elmo-folder name))
2503 (when (and (not (string=
2505 (elmo-folder-name-internal cur-fld))
2506 (elmo-folder-name-internal folder))) ; folder is moved.
2507 (eq major-mode 'wl-summary-mode)) ; called in summary.
2508 (setq wl-summary-last-visited-folder (wl-summary-buffer-folder-name))
2509 (run-hooks 'wl-summary-exit-pre-hook)
2510 (wl-summary-cleanup-temp-marks (wl-summary-sticky-p))
2511 (wl-summary-save-view 'keep) ; keep current buffer, anyway.
2512 (elmo-folder-commit wl-summary-buffer-elmo-folder))
2513 (setq buf (wl-summary-get-buffer-create (elmo-folder-name-internal folder)
2518 (string= (elmo-folder-name-internal folder)
2519 (wl-summary-buffer-folder-name))))
2523 (switch-to-buffer buf)
2526 (delete-other-windows))
2528 (unless (eq major-mode 'wl-summary-mode)
2530 (wl-summary-buffer-set-folder folder)
2531 (setq wl-summary-buffer-disp-msg nil)
2532 (setq wl-summary-buffer-last-displayed-msg nil)
2533 (setq wl-summary-buffer-current-msg nil)
2534 (let ((case-fold-search nil)
2535 (inhibit-read-only t)
2536 (buffer-read-only nil))
2538 ;; Resume summary view
2539 (if wl-summary-cache-use
2540 (let* ((dir (elmo-folder-msgdb-path folder))
2541 (cache (expand-file-name wl-summary-cache-file dir))
2542 (view (expand-file-name wl-summary-view-file dir)))
2543 (when (file-exists-p cache)
2544 (insert-file-contents-as-binary cache)
2545 (elmo-set-buffer-multibyte
2546 default-enable-multibyte-characters)
2547 (decode-mime-charset-region
2548 (point-min)(point-max)
2549 wl-summary-buffer-mime-charset))
2550 (when (file-exists-p view)
2551 (setq wl-summary-buffer-view
2552 (wl-summary-load-file-object view)))
2553 (wl-thread-resume-entity folder)
2554 (wl-summary-open-folder folder))
2555 (setq wl-summary-buffer-view
2556 (wl-summary-load-file-object
2557 (expand-file-name wl-summary-view-file
2558 (elmo-folder-msgdb-path folder))))
2559 (wl-summary-open-folder folder)
2560 (wl-summary-rescan))
2561 (wl-summary-count-unread
2562 (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
2563 (wl-summary-update-modeline)))
2564 (unless (eq wl-summary-buffer-view 'thread)
2565 (wl-summary-make-number-list))
2566 (wl-summary-buffer-number-column-detect t)
2567 (wl-summary-toggle-disp-msg (if wl-summary-buffer-disp-msg 'on 'off))
2568 (unless (and reuse-buf keep-cursor)
2569 ;(setq hilit wl-summary-highlight)
2571 (let ((wl-summary-highlight (if reuse-buf wl-summary-highlight))
2573 (if (or scoring interactive) wl-use-scoring)))
2574 (if (and (not scan-type)
2577 (setq scan-type (wl-summary-get-sync-range folder)))
2580 (wl-summary-sync 'unset-cursor))
2581 ((eq scan-type 'all)
2582 (wl-summary-sync 'unset-cursor "all"))
2583 ((eq scan-type 'no-sync))
2584 ((or (eq scan-type 'force-update)
2585 (eq scan-type 'update))
2586 (setq mes (wl-summary-sync-force-update
2587 'unset-cursor 'no-check)))))
2589 (switch-to-buffer buf)
2591 ;; stick always-sticky-folder
2592 (when (wl-summary-always-sticky-folder-p folder)
2593 (or (wl-summary-sticky-p) (wl-summary-stick t)))
2594 (run-hooks 'wl-summary-prepared-pre-hook)
2595 (set-buffer-modified-p nil)
2596 (goto-char (point-min))
2597 (if (wl-summary-cursor-down t)
2598 (let ((unreadp (wl-summary-next-message
2599 (wl-summary-message-number)
2601 (cond ((and wl-auto-select-first
2602 (wl-summary-auto-select-msg-p unreadp))
2603 ;; wl-auto-select-first is non-nil and
2604 ;; unreadp is non-nil but not important
2605 (setq retval 'disp-msg))
2606 ((not (wl-summary-auto-select-msg-p unreadp))
2607 ;; unreadp is nil or important
2608 (setq retval 'more-next))))
2609 (goto-char (point-max))
2610 (if (elmo-folder-plugged-p folder)
2613 (setq retval 'more-next))
2614 ;(setq wl-summary-highlight hilit)
2615 (if (and wl-summary-highlight
2616 (not wl-summary-lazy-highlight)
2618 (if (and wl-summary-highlight-partial-threshold
2619 (> (count-lines (point-min) (point-max))
2620 wl-summary-highlight-partial-threshold))
2625 wl-summary-partial-highlight-above-lines
2626 wl-summary-highlight-partial-threshold)))
2627 (wl-highlight-summary (point) (point-max)))
2628 (wl-highlight-summary (point-min) (point-max))))
2629 (if (eq retval 'disp-msg)
2630 (wl-summary-redisplay))
2631 (if mes (message "%s" mes))
2632 (if (and interactive wl-summary-recenter)
2633 (recenter (/ (- (window-height) 2) 2))))))
2634 ;; set current entity-id
2635 (if (and (not folder)
2637 (wl-folder-search-entity-by-name (elmo-folder-name-internal
2641 ;; entity-id is unknown.
2642 (wl-folder-set-current-entity-id
2643 (wl-folder-get-entity-id entity)))
2645 (run-hooks 'wl-summary-prepared-hook)
2646 (set-buffer-modified-p nil))
2649 (defun wl-summary-summary-line-already-exists-p (parent-number buffer)
2652 (goto-char (point-max))
2654 (when (re-search-backward (format "^ *%s..../..\(.*\)..:.. "
2655 parent-number) nil t)
2656 (goto-char (match-end 0))
2657 (while (string-match wl-thread-indent-regexp
2659 (char-after (point))))
2660 (setq depth (+ 1 depth))
2662 (/ depth wl-thread-indent-level-internal))))
2664 (defun wl-summary-goto-bottom-of-current-thread ()
2665 (if (re-search-forward (concat "^" wl-summary-buffer-number-regexp
2666 "..../..\(.*\)..:.. [[<]") nil t)
2668 (goto-char (point-max))))
2670 (defun wl-summary-goto-top-of-current-thread ()
2671 (wl-summary-jump-to-msg
2672 (wl-thread-entity-get-number
2673 (wl-thread-entity-get-top-entity (wl-thread-get-entity
2674 (wl-summary-message-number))))))
2676 (defun wl-summary-goto-bottom-of-sub-thread (&optional depth)
2678 (let ((depth (or depth
2679 (wl-thread-get-depth-of-current-line))))
2681 (while (and (not (eobp))
2682 (>= (wl-thread-get-depth-of-current-line)
2685 (beginning-of-line)))
2687 (defun wl-summary-insert-line (line)
2688 "Insert LINE in the Summary."
2689 (if wl-use-highlight-mouse-line
2690 ;; remove 'mouse-face of current line.
2692 (save-excursion (beginning-of-line)(point))
2693 (save-excursion (end-of-line)(point))
2696 (if wl-use-highlight-mouse-line
2697 ;; remove 'mouse-face of current line.
2699 (save-excursion (beginning-of-line)(point))
2700 (save-excursion (end-of-line)(point))
2702 (condition-case nil ; it's dangerous, so ignore error.
2703 (run-hooks 'wl-summary-line-inserted-hook)
2705 (message "Error in wl-summary-line-inserted-hook"))))
2707 (defun wl-summary-insert-summary (entity database mark-alist dummy &optional dummy)
2708 (let ((overview-entity entity)
2710 (setq msg (elmo-msgdb-overview-entity-get-number entity))
2711 (when (setq summary-line
2712 (wl-summary-overview-create-summary-line
2713 msg entity nil 0 mark-alist))
2714 (let ((inhibit-read-only t)
2716 (goto-char (point-max))
2717 (wl-summary-insert-line summary-line)))))
2719 (defun wl-summary-default-subject-filter (subject)
2720 (let ((case-fold-search t))
2721 (setq subject (elmo-replace-in-string subject "[ \t]*\\(re\\|was\\)[:>]" ""))
2722 (setq subject (elmo-replace-in-string subject "[ \t]" ""))
2723 (elmo-replace-in-string subject "^\\[.*\\]" "")))
2725 (defun wl-summary-subject-equal (subject1 subject2)
2726 (string= (wl-summary-subject-filter-func-internal subject1)
2727 (wl-summary-subject-filter-func-internal subject2)))
2729 (defmacro wl-summary-put-alike (alike)
2730 (` (elmo-set-hash-val (format "#%d" (wl-count-lines))
2732 wl-summary-alike-hashtb)))
2734 (defmacro wl-summary-get-alike ()
2735 (` (elmo-get-hash-val (format "#%d" (wl-count-lines))
2736 wl-summary-alike-hashtb)))
2738 (defun wl-summary-insert-headers (overview func mime-decode)
2739 (let (ov this last alike)
2740 (buffer-disable-undo (current-buffer))
2741 (make-local-variable 'wl-summary-alike-hashtb)
2742 (setq wl-summary-alike-hashtb (elmo-make-hash (* (length overview) 2)))
2744 (elmo-set-buffer-multibyte default-enable-multibyte-characters))
2745 (while (setq ov (pop overview))
2746 (setq this (funcall func ov))
2747 (and this (setq this (std11-unfold-string this)))
2748 (if (equal last this)
2749 (wl-append alike (list ov))
2751 (wl-summary-put-alike alike)
2753 (setq alike (list ov)
2756 (wl-summary-put-alike alike)
2759 (decode-mime-charset-region (point-min) (point-max)
2761 (when (eq mime-decode 'mime)
2762 (eword-decode-region (point-min) (point-max))))
2763 (run-hooks 'wl-summary-insert-headers-hook)))
2765 (defun wl-summary-search-by-subject (entity overview)
2766 (let ((summary-buf (current-buffer))
2767 (buf (get-buffer-create wl-summary-search-buf-name))
2768 (folder-name (wl-summary-buffer-folder-name))
2769 match founds found-entity)
2770 (with-current-buffer buf
2771 (let ((case-fold-search t))
2772 (when (or (not (string= wl-summary-search-buf-folder-name folder-name))
2773 (zerop (buffer-size)))
2774 (setq wl-summary-search-buf-folder-name folder-name)
2775 (wl-summary-insert-headers
2779 (wl-summary-subject-filter-func-internal
2780 (elmo-msgdb-overview-entity-get-subject-no-decode x))))
2782 (setq match (wl-summary-subject-filter-func-internal
2783 (elmo-msgdb-overview-entity-get-subject entity)))
2784 (if (string= match "")
2786 (goto-char (point-min))
2787 (while (and (not founds)
2788 (not (= (point) (point-max)))
2789 (search-forward match nil t))
2790 ;; check exactly match
2793 (match-beginning 0)))
2794 (setq found-entity (wl-summary-get-alike))
2795 (if (and found-entity
2796 ;; Is founded entity myself or children?
2798 (elmo-msgdb-overview-entity-get-id entity)
2799 (elmo-msgdb-overview-entity-get-id
2800 (car found-entity))))
2801 (with-current-buffer summary-buf
2802 (not (wl-thread-descendant-p
2803 (elmo-msgdb-overview-entity-get-number entity)
2804 (elmo-msgdb-overview-entity-get-number
2805 (car found-entity))))))
2806 ;; return matching entity
2807 (setq founds found-entity))))
2811 (defun wl-summary-insert-thread-entity (entity overview mark-alist update
2812 &optional force-insert)
2813 (let (update-list entity-stack)
2815 (let* ((this-id (elmo-msgdb-overview-entity-get-id entity))
2817 (elmo-msgdb-overview-get-parent-entity entity overview));; temp
2818 ;;; (parent-id (elmo-msgdb-overview-entity-get-id parent-entity))
2819 (parent-number (elmo-msgdb-overview-entity-get-number parent-entity))
2820 (case-fold-search t)
2821 msg overview2 cur-entity linked retval delayed-entity)
2822 (setq msg (elmo-msgdb-overview-entity-get-number entity))
2823 (if (and parent-number
2824 (not (wl-thread-get-entity parent-number))
2826 ;; parent is exists in overview, but not exists in wl-thread-entities
2828 (wl-append wl-summary-delayed-update
2829 (list (cons parent-number entity)))
2830 (setq entity nil)) ;; exit loop
2831 ;; Search parent by subject.
2832 (when (and (null parent-number)
2833 wl-summary-search-parent-by-subject-regexp
2835 wl-summary-search-parent-by-subject-regexp
2836 (elmo-msgdb-overview-entity-get-subject entity)))
2837 (let ((found (wl-summary-search-by-subject entity overview)))
2839 (not (member found wl-summary-delayed-update)))
2840 (setq parent-entity found)
2842 (elmo-msgdb-overview-entity-get-number parent-entity))
2844 ;; If subject is change, divide thread.
2845 (if (and parent-number
2846 wl-summary-divide-thread-when-subject-changed
2847 (not (wl-summary-subject-equal
2848 (or (elmo-msgdb-overview-entity-get-subject
2850 (or (elmo-msgdb-overview-entity-get-subject
2851 parent-entity) ""))))
2852 (setq parent-number nil))
2855 (wl-thread-insert-message entity overview mark-alist
2856 msg parent-number update linked))
2858 (wl-append update-list (list retval)))
2859 (setq entity nil) ; exit loop
2860 (while (setq delayed-entity (assq msg wl-summary-delayed-update))
2861 (setq wl-summary-delayed-update
2862 (delete delayed-entity wl-summary-delayed-update))
2863 ;; update delayed message
2864 (wl-append entity-stack (list (cdr delayed-entity)))))
2865 (if (and (not entity)
2867 (setq entity (pop entity-stack)))))
2870 (defun wl-summary-update-thread (entity
2876 (this-id (elmo-msgdb-overview-entity-get-id entity))
2877 (overview-entity entity)
2878 (parent-id (elmo-msgdb-overview-entity-get-id parent-entity))
2879 (parent-number (elmo-msgdb-overview-entity-get-number parent-entity))
2880 summary-line msg subject-differ)
2882 ((or (not parent-id)
2883 (string= this-id parent-id))
2884 (goto-char (point-max))
2885 (beginning-of-line))
2886 ;; parent already exists in buffer.
2887 ((setq depth (or (wl-summary-summary-line-already-exists-p
2888 parent-number (current-buffer)) -1))
2889 (setq depth (+ 1 depth))
2890 (wl-thread-goto-bottom-of-sub-thread)))
2891 (if (and (setq msg (elmo-msgdb-overview-entity-get-number entity)))
2892 (if (setq summary-line
2893 (wl-summary-overview-create-summary-line
2894 msg entity parent-entity depth mark-alist
2895 (wl-thread-maybe-get-children-num msg)
2897 (let ((inhibit-read-only t)
2898 (buffer-read-only nil))
2899 (wl-summary-insert-line summary-line))))))
2901 (defun wl-summary-mark-as-unread (&optional number
2907 (inhibit-read-only t)
2908 (buffer-read-only nil)
2909 (folder wl-summary-buffer-elmo-folder)
2910 (msgdb (wl-summary-buffer-msgdb))
2911 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
2912 ;;; (number-alist (elmo-msgdb-get-number-alist msgdb))
2913 new-mark visible mark)
2916 (setq visible (wl-summary-jump-to-msg number))
2917 (unless (setq mark (cadr (assq number mark-alist)))
2922 (if (null (wl-summary-message-number))
2923 (message "No message.")
2926 (re-search-backward (concat "^" wl-summary-buffer-number-regexp
2927 "..../..")) ; set cursor line
2928 (beginning-of-line)))
2929 (if (or (and (not visible)
2930 ;; already exists in msgdb.
2931 (assq number (elmo-msgdb-get-number-alist msgdb)))
2933 (format (concat "^ *\\("
2934 (if number (int-to-string number)
2936 "\\)[^0-9]\\(%s\\|%s\\)")
2937 wl-summary-read-uncached-mark
2940 (setq number (or number (string-to-int (wl-match-buffer 1))))
2941 (setq mark (or mark (elmo-match-buffer 2)))
2943 (setq new-mark (if (string= mark
2944 wl-summary-read-uncached-mark)
2945 wl-summary-unread-uncached-mark
2946 (if (elmo-message-use-cache-p folder number)
2947 wl-summary-unread-mark
2948 wl-summary-unread-uncached-mark))))
2950 (unless no-server-update
2952 (unless (elmo-folder-unmark-read folder (list number))
2953 (error "Setting mark failed"))))
2955 (delete-region (match-beginning 2) (match-end 2))
2958 (elmo-msgdb-mark-set mark-alist
2961 (elmo-msgdb-set-mark-alist msgdb mark-alist)
2962 (unless no-modeline-update
2963 (setq wl-summary-buffer-unread-count
2964 (+ 1 wl-summary-buffer-unread-count))
2965 (wl-summary-update-modeline)
2966 (wl-folder-update-unread
2967 (wl-summary-buffer-folder-name)
2968 (+ wl-summary-buffer-unread-count
2969 wl-summary-buffer-new-count)))
2970 (wl-summary-set-mark-modified)
2971 (if (and visible wl-summary-highlight)
2972 (wl-highlight-summary-current-line))))))
2973 (set-buffer-modified-p nil))
2975 (defun wl-summary-delete (&optional number)
2976 "Mark Delete mark 'D'.
2977 If optional argument NUMBER is specified, mark message specified by NUMBER."
2979 (let* ((buffer-num (wl-summary-message-number))
2980 (msg-num (or number buffer-num))
2983 (when (null msg-num)
2985 (message "No message."))
2987 (when (setq mark (wl-summary-get-mark msg-num))
2988 (when (wl-summary-reserve-temp-mark-p mark)
2990 (error "Already marked as `%s'" mark))
2992 (wl-summary-unmark msg-num))
2993 (if (or (interactive-p)
2994 (eq number buffer-num))
2995 (wl-summary-mark-line "D"))
2996 (setq wl-summary-buffer-delete-list
2997 (cons msg-num wl-summary-buffer-delete-list))
2999 (if (eq wl-summary-move-direction-downward nil)
3004 (defun wl-summary-remove-destination ()
3006 (let ((inhibit-read-only t)
3007 (buffer-read-only nil)
3008 (buf (current-buffer))
3014 (setq rs (next-single-property-change sol 'wl-summary-destination
3016 (setq re (next-single-property-change rs 'wl-summary-destination
3018 (put-text-property rs re 'wl-summary-destination nil)
3019 (put-text-property rs re 'invisible nil)
3021 (delete-char (- eol re)))))
3023 (defun wl-summary-check-mark (msg mark)
3024 (let ((check-func (cond ((string= mark "o")
3025 'wl-summary-msg-marked-as-refiled)
3027 'wl-summary-msg-marked-as-copied)
3029 'wl-summary-msg-marked-as-deleted)
3031 'wl-summary-msg-marked-as-target))))
3033 (funcall check-func msg))))
3035 (defun wl-summary-mark-collect (mark &optional begin end)
3039 (narrow-to-region (or begin (point-min))
3040 (or end (point-max)))
3041 (goto-char (point-min))
3043 (if (eq wl-summary-buffer-view 'thread)
3046 (let* ((number (wl-summary-message-number))
3047 (entity (wl-thread-get-entity number))
3049 ;; opened...only myself is checked.
3050 (if (wl-summary-check-mark number mark)
3051 (wl-append msglist (list number)))
3052 (unless (wl-thread-entity-get-opened entity)
3053 ;; closed...children is also checked.
3054 (if (setq result (wl-thread-get-children-msgs-with-mark
3057 (wl-append msglist result)))
3059 (elmo-uniq-list msglist))
3060 (let* ((case-fold-search nil)
3061 (re (format (concat wl-summary-message-regexp "%s")
3062 (regexp-quote mark))))
3063 (while (re-search-forward re nil t)
3064 (setq msglist (cons (wl-summary-message-number) msglist)))
3065 (nreverse msglist)))))))
3067 (defun wl-summary-exec ()
3069 (wl-summary-exec-subr (mapcar 'car wl-summary-buffer-refile-list)
3070 (reverse wl-summary-buffer-delete-list)
3071 (mapcar 'car wl-summary-buffer-copy-list)))
3073 (defun wl-summary-exec-region (beg end)
3075 (message "Collecting marks ...")
3080 (goto-char (1- end))
3083 (wl-summary-exec-subr (wl-summary-mark-collect "o" beg end)
3084 (wl-summary-mark-collect "D" beg end)
3085 (wl-summary-mark-collect "O" beg end))))
3087 (defun wl-summary-exec-subr (moves dels copies)
3088 (if (not (or moves dels copies))
3089 (message "No marks")
3091 (let ((del-fld (wl-summary-get-delete-folder
3092 (wl-summary-buffer-folder-name)))
3094 (unread-marks (list wl-summary-unread-cached-mark
3095 wl-summary-unread-uncached-mark
3096 wl-summary-new-mark))
3097 (refiles (append moves dels))
3100 (copy-len (length copies))
3102 dst-msgs ; loop counter
3104 (message "Executing ...")
3106 (when (not (assq (car dels) wl-summary-buffer-refile-list))
3107 (wl-append wl-summary-buffer-refile-list
3108 (list (cons (car dels) del-fld)))
3109 (setq wl-summary-buffer-delete-list
3110 (delete (car dels) wl-summary-buffer-delete-list)))
3111 (setq dels (cdr dels)))
3113 (setq refile-len (length refiles))
3115 (wl-inverse-alist refiles wl-summary-buffer-refile-list))
3116 (goto-char start) ; avoid moving cursor to
3118 (when (> refile-len elmo-display-progress-threshold)
3119 (elmo-progress-set 'elmo-folder-move-messages
3120 refile-len "Moving messages..."))
3124 (setq result (elmo-folder-move-messages
3125 wl-summary-buffer-elmo-folder
3126 (cdr (car dst-msgs))
3127 (if (eq 'null (car (car dst-msgs)))
3129 (wl-folder-get-elmo-folder
3130 (car (car dst-msgs))))
3131 (wl-summary-buffer-msgdb)
3132 (not (null (cdr dst-msgs)))
3138 (if result ; succeeded.
3141 (wl-summary-delete-messages-on-buffer (cdr (car dst-msgs)))
3142 ;; update refile-alist.
3143 (setq wl-summary-buffer-refile-list
3144 (wl-delete-associations (cdr (car dst-msgs))
3145 wl-summary-buffer-refile-list)))
3146 (setq refile-failures
3147 (+ refile-failures (length (cdr (car dst-msgs))))))
3148 (setq dst-msgs (cdr dst-msgs)))
3149 (elmo-progress-clear 'elmo-folder-move-messages)
3152 (setq dst-msgs (wl-inverse-alist copies wl-summary-buffer-copy-list))
3153 (when (> copy-len elmo-display-progress-threshold)
3154 (elmo-progress-set 'elmo-folder-move-messages
3155 copy-len "Copying messages..."))
3159 (setq result (elmo-folder-move-messages
3160 wl-summary-buffer-elmo-folder
3161 (cdr (car dst-msgs))
3162 (wl-folder-get-elmo-folder
3163 (car (car dst-msgs)))
3164 (wl-summary-buffer-msgdb)
3165 (not (null (cdr dst-msgs)))
3166 t ; t is no-delete (copy)
3171 (if result ; succeeded.
3174 (wl-summary-delete-copy-marks-on-buffer (cdr (car dst-msgs)))
3175 ;; update copy-alist
3176 (setq wl-summary-buffer-copy-list
3177 (wl-delete-associations (cdr (car dst-msgs))
3178 wl-summary-buffer-copy-list)))
3180 (+ copy-failures (length (cdr (car dst-msgs))))))
3181 (setq dst-msgs (cdr dst-msgs)))
3182 ;; Hide progress bar.
3183 (elmo-progress-clear 'elmo-folder-move-messages)
3185 (wl-summary-folder-info-update)
3186 (wl-summary-set-message-modified)
3187 (wl-summary-set-mark-modified)
3188 (run-hooks 'wl-summary-exec-hook)
3189 (unless (and wl-message-buffer
3190 (eq (wl-summary-message-number)
3191 (with-current-buffer wl-message-buffer
3192 wl-message-buffer-cur-number)))
3193 (wl-summary-toggle-disp-msg 'off))
3194 (set-buffer-modified-p nil)
3195 (message (concat "Executing ... done"
3196 (if (> refile-failures 0)
3197 (format " (%d refiling failed)" refile-failures)
3199 (if (> copy-failures 0)
3200 (format " (%d copying failed)" copy-failures)
3204 (defun wl-summary-read-folder (default &optional purpose ignore-error
3206 (let ((fld (completing-read
3207 (format "Folder name %s(%s): " (or purpose "")
3209 (or wl-folder-completion-function
3210 (if (memq 'read-folder wl-use-folder-petname)
3211 (wl-folder-get-entity-with-petname)
3212 wl-folder-entity-hashtb))
3213 nil nil (or init wl-default-spec)
3214 'wl-read-folder-hist)))
3215 (if (or (string= fld wl-default-spec)
3218 (setq fld (elmo-string (wl-folder-get-realname fld)))
3219 (if (string-match "\n" fld)
3220 (error "Not supported folder name: %s" fld))
3224 (wl-folder-confirm-existence
3225 (wl-folder-get-elmo-folder
3228 (wl-folder-confirm-existence (wl-folder-get-elmo-folder
3232 (defun wl-summary-print-destination (msg-num folder)
3233 "Print refile destination on line."
3234 (wl-summary-remove-destination)
3235 (let ((inhibit-read-only t)
3236 (folder (copy-sequence folder))
3237 (buffer-read-only nil)
3239 (setq len (string-width folder))
3246 (setq c (+ c (char-width (following-char)))))
3247 (and (> c len) (setq folder (concat " " folder)))
3249 (put-text-property rs re 'invisible t)
3250 (put-text-property rs re 'wl-summary-destination t)
3252 (wl-highlight-refile-destination-string folder)
3254 (set-buffer-modified-p nil))))
3256 (defsubst wl-summary-get-mark (number)
3257 "Return a temporal mark of message specified by NUMBER."
3258 (or (and (memq number wl-summary-buffer-delete-list) "D")
3259 (and (assq number wl-summary-buffer-copy-list) "O")
3260 (and (assq number wl-summary-buffer-refile-list) "o")
3261 (and (memq number wl-summary-buffer-target-mark-list) "*")))
3263 (defsubst wl-summary-reserve-temp-mark-p (mark)
3264 "Return t if temporal MARK should be reserved."
3265 (member mark wl-summary-reserve-mark-list))
3267 (defun wl-summary-refile (&optional dst number)
3268 "Put refile mark on current line message.
3269 If optional argument DST is specified, put mark without asking
3271 If optional argument NUMBER is specified, mark message specified by NUMBER.
3273 If folder is read-only, message should be copied.
3274 See `wl-refile-policy-alist' for more details."
3276 (let ((policy (wl-get-assoc-list-value wl-refile-policy-alist
3277 (wl-summary-buffer-folder-name))))
3278 (cond ((eq policy 'copy)
3280 (call-interactively 'wl-summary-copy)
3281 (wl-summary-copy dst number)))
3283 (wl-summary-refile-subr 'refile (interactive-p) dst number)))))
3285 (defun wl-summary-copy (&optional dst number)
3286 "Put copy mark on current line message.
3287 If optional argument DST is specified, put mark without asking
3289 If optional argument NUMBER is specified, mark message specified by NUMBER."
3291 (wl-summary-refile-subr 'copy (interactive-p) dst number))
3293 (defun wl-summary-refile-subr (copy-or-refile interactive &optional dst number)
3295 (let* ((buffer-num (wl-summary-message-number))
3296 (msg-num (or number buffer-num))
3298 (elmo-message-field wl-summary-buffer-elmo-folder
3299 msg-num 'message-id)))
3300 (entity (and msg-num
3301 (elmo-msgdb-overview-get-entity
3302 msg-num (wl-summary-buffer-msgdb))))
3304 (intern (format "wl-summary-buffer-%s-list" copy-or-refile)))
3305 folder mark already tmp-folder)
3310 (message "Cannot refile."))
3312 (when (null msg-num)
3314 (message "No message."))
3316 (when (setq mark (wl-summary-get-mark msg-num))
3317 (when (wl-summary-reserve-temp-mark-p mark)
3319 (error "Already marked as `%s'" mark))
3321 (setq folder (and msg-num
3322 (or dst (wl-summary-read-folder
3323 (or (wl-refile-guess entity) wl-trash-folder)
3324 (format "for %s" copy-or-refile)))))
3325 ;; Cache folder hack by okada@opaopa.org
3326 (if (and (eq (elmo-folder-type-internal
3327 (wl-folder-get-elmo-folder
3328 (wl-folder-get-realname folder))) 'cache)
3329 (not (string= folder
3332 (elmo-cache-get-path-subr
3333 (elmo-msgid-to-cache msgid)))))))
3335 (setq folder tmp-folder)
3336 (message "Force refile to %s." folder)))
3337 (if (string= folder (wl-summary-buffer-folder-name))
3338 (error "Same folder"))
3339 (if (or (string= folder wl-queue-folder)
3340 (string= folder wl-draft-folder))
3341 (error "Don't %s messages to %s" copy-or-refile folder))
3342 ;; learn for refile.
3343 (if (eq copy-or-refile 'refile)
3344 (wl-refile-learn entity folder))
3345 (wl-summary-unmark msg-num)
3346 (set variable (append
3347 (symbol-value variable)
3348 (list (cons msg-num folder))))
3349 (when (or interactive
3350 (eq number buffer-num))
3351 (wl-summary-mark-line (if (eq copy-or-refile 'refile)
3353 ;; print refile destination
3354 (wl-summary-print-destination msg-num folder))
3356 (if (eq wl-summary-move-direction-downward nil)
3359 (run-hooks (intern (format "wl-summary-%s-hook" copy-or-refile)))
3360 (setq wl-summary-buffer-prev-refile-destination folder)
3363 (defun wl-summary-refile-prev-destination ()
3364 "Refile message to previously refiled destination."
3366 (wl-summary-refile wl-summary-buffer-prev-refile-destination
3367 (wl-summary-message-number))
3368 (if (eq wl-summary-move-direction-downward nil)
3372 (defun wl-summary-copy-prev-destination ()
3373 "Refile message to previously refiled destination."
3375 (wl-summary-copy wl-summary-buffer-prev-copy-destination
3376 (wl-summary-message-number))
3377 (if (eq wl-summary-move-direction-downward nil)
3381 (defsubst wl-summary-no-auto-refile-message-p (msg mark-alist)
3382 (member (cadr (assq msg mark-alist)) wl-summary-auto-refile-skip-marks))
3384 (defun wl-summary-auto-refile (&optional open-all)
3385 "Set refile mark automatically according to 'wl-refile-guess-by-rule'."
3387 (message "Marking...")
3389 (if (and (eq wl-summary-buffer-view 'thread)
3391 (wl-thread-open-all))
3392 (let* ((spec (wl-summary-buffer-folder-name))
3393 (overview (elmo-msgdb-get-overview
3394 (wl-summary-buffer-msgdb)))
3395 (mark-alist (elmo-msgdb-get-mark-alist
3396 (wl-summary-buffer-msgdb)))
3399 number dst thr-entity)
3402 (setq number (wl-summary-message-number))
3403 (when (and (not (wl-summary-no-auto-refile-message-p number
3406 (wl-folder-get-realname
3407 (wl-refile-guess-by-rule
3408 (elmo-msgdb-overview-get-entity
3409 number (wl-summary-buffer-msgdb)))))
3410 (not (equal dst spec)))
3411 (when (not (member dst checked-dsts))
3412 (wl-folder-confirm-existence (wl-folder-get-elmo-folder dst))
3413 (setq checked-dsts (cons dst checked-dsts)))
3414 (if (wl-summary-refile dst number)
3416 (message "Marking...%d message(s)." count))
3417 (if (eq wl-summary-buffer-view 'thread)
3418 ;; process invisible children.
3419 (unless (wl-thread-entity-get-opened
3420 (setq thr-entity (wl-thread-get-entity number)))
3425 (wl-summary-no-auto-refile-message-p
3427 (wl-thread-entity-get-descendant thr-entity))))
3429 (when (and (setq dst
3430 (wl-refile-guess-by-rule
3431 (elmo-msgdb-overview-get-entity
3432 (car messages) (wl-summary-buffer-msgdb))))
3433 (not (equal dst spec)))
3434 (if (wl-summary-refile dst (car messages))
3436 (message "Marking...%d message(s)." count))
3437 (setq messages (cdr messages))))))
3440 (message "No message was marked.")
3441 (message "Marked %d message(s)." count)))))
3443 (defun wl-summary-unmark (&optional number)
3444 "Unmark marks (temporary, refile, copy, delete)of current line.
3445 If optional argument NUMBER is specified, unmark message specified by NUMBER."
3449 (let ((inhibit-read-only t)
3450 (buffer-read-only nil)
3456 (setq visible (wl-summary-jump-to-msg number))
3458 ;; Delete mark on buffer.
3460 (looking-at "^ *\\(-?[0-9]+\\)\\([^0-9]\\)"))
3461 (goto-char (match-end 2))
3463 (setq number (string-to-int (wl-match-buffer 1))))
3464 (setq cur-mark (wl-match-buffer 2))
3465 (if (string= cur-mark " ")
3467 (delete-region (match-beginning 2) (match-end 2))
3468 (if (setq score-mark (wl-summary-get-score-mark number))
3471 (if (or (string= cur-mark "o")
3472 (string= cur-mark "O"))
3473 (wl-summary-remove-destination))
3474 (if wl-summary-highlight
3475 (wl-highlight-summary-current-line nil nil score-mark))
3476 (set-buffer-modified-p nil))
3477 ;; Remove from temporary mark structure.
3479 (wl-summary-delete-mark number)))))
3481 (defun wl-summary-msg-marked-as-target (msg)
3482 (if (memq msg wl-summary-buffer-target-mark-list)
3485 (defun wl-summary-msg-marked-as-copied (msg)
3486 (assq msg wl-summary-buffer-copy-list))
3488 (defun wl-summary-msg-marked-as-deleted (msg)
3489 (if (memq msg wl-summary-buffer-delete-list)
3492 (defun wl-summary-msg-marked-as-refiled (msg)
3493 (assq msg wl-summary-buffer-refile-list))
3495 (defun wl-summary-target-mark (&optional number)
3496 "Put target mark '*' on current message.
3497 If optional argument NUMBER is specified, mark message specified by NUMBER."
3499 (let* ((buffer-num (wl-summary-message-number))
3500 (msg-num (or number buffer-num))
3503 (when (null msg-num)
3505 (message "No message."))
3507 (when (setq mark (wl-summary-get-mark msg-num))
3508 (when (wl-summary-reserve-temp-mark-p mark)
3510 (error "Already marked as `%s'" mark))
3512 (wl-summary-unmark msg-num))
3513 (if (or (interactive-p)
3514 (eq number buffer-num))
3515 (wl-summary-mark-line "*"))
3516 (setq wl-summary-buffer-target-mark-list
3517 (cons msg-num wl-summary-buffer-target-mark-list))
3519 (if (eq wl-summary-move-direction-downward nil)
3525 (defun wl-summary-refile-region (beg end)
3526 "Put copy mark on messages in the region specified by BEG and END."
3528 (wl-summary-refile-region-subr "refile" beg end))
3530 (defun wl-summary-copy-region (beg end)
3531 "Put copy mark on messages in the region specified by BEG and END."
3533 (wl-summary-refile-region-subr "copy" beg end))
3535 (defun wl-summary-refile-region-subr (copy-or-refile beg end)
3539 ;; guess by first msg
3540 (let* ((msgid (cdr (assq (wl-summary-message-number)
3541 (elmo-msgdb-get-number-alist
3542 (wl-summary-buffer-msgdb)))))
3543 (function (intern (format "wl-summary-%s" copy-or-refile)))
3544 (entity (assoc msgid (elmo-msgdb-get-overview
3545 (wl-summary-buffer-msgdb))))
3548 (setq folder (wl-summary-read-folder (wl-refile-guess entity)
3551 (narrow-to-region beg end)
3552 (if (eq wl-summary-buffer-view 'thread)
3555 (let* ((number (wl-summary-message-number))
3556 (entity (wl-thread-get-entity number))
3558 (if (wl-thread-entity-get-opened entity)
3559 ;; opened...refile line.
3560 (funcall function folder number)
3562 (setq children (wl-thread-get-children-msgs number))
3564 (funcall function folder (pop children))))
3567 (funcall function folder (wl-summary-message-number))
3568 (forward-line 1)))))))
3570 (defun wl-summary-unmark-region (beg end)
3574 (narrow-to-region beg end)
3575 (goto-char (point-min))
3576 (if (eq wl-summary-buffer-view 'thread)
3579 (let* ((number (wl-summary-message-number))
3580 (entity (wl-thread-get-entity number)))
3581 (if (wl-thread-entity-get-opened entity)
3582 ;; opened...unmark line.
3585 (wl-summary-delete-marks-on-buffer
3586 (wl-thread-get-children-msgs number))))
3590 (forward-line 1))))))
3592 (defun wl-summary-mark-region-subr (function beg end)
3595 (narrow-to-region beg end)
3596 (goto-char (point-min))
3597 (if (eq wl-summary-buffer-view 'thread)
3600 (let* ((number (wl-summary-message-number))
3601 (entity (wl-thread-get-entity number))
3602 (wl-summary-move-direction-downward t)
3604 (if (wl-thread-entity-get-opened entity)
3605 ;; opened...delete line.
3606 (funcall function number)
3608 (setq children (wl-thread-get-children-msgs number))
3610 (funcall function (pop children))))
3613 (funcall function (wl-summary-message-number))
3614 (forward-line 1))))))
3616 (defun wl-summary-delete-region (beg end)
3618 (wl-summary-mark-region-subr 'wl-summary-delete beg end))
3620 (defun wl-summary-target-mark-region (beg end)
3622 (wl-summary-mark-region-subr 'wl-summary-target-mark beg end))
3624 (defun wl-summary-target-mark-all ()
3626 (wl-summary-target-mark-region (point-min) (point-max))
3627 (setq wl-summary-buffer-target-mark-list
3629 (elmo-msgdb-get-number-alist (wl-summary-buffer-msgdb)))))
3631 (defun wl-summary-delete-all-mark (mark)
3632 (goto-char (point-min))
3633 (let ((case-fold-search nil))
3634 (while (re-search-forward (format "^ *-?[0-9]+%s"
3635 (regexp-quote mark)) nil t)
3636 (wl-summary-unmark))
3637 (cond ((string= mark "*")
3638 (setq wl-summary-buffer-target-mark-list nil))
3640 (setq wl-summary-buffer-delete-list nil))
3642 (setq wl-summary-buffer-copy-list nil))
3644 (setq wl-summary-buffer-refile-list nil)))))
3646 (defun wl-summary-unmark-all ()
3647 "Unmark all according to what you input."
3649 (let ((unmarks (string-to-char-list (read-from-minibuffer "Unmark: ")))
3653 (setq cur-mark (char-to-string (car unmarks)))
3654 (wl-summary-delete-all-mark cur-mark)
3655 (setq unmarks (cdr unmarks))))))
3657 (defun wl-summary-target-mark-thread ()
3661 (wl-summary-goto-top-of-current-thread)
3662 (wl-thread-force-open)
3665 (wl-summary-goto-bottom-of-current-thread)
3666 ;;; (forward-line -1)
3669 (wl-summary-target-mark-region beg end)))
3671 (defun wl-summary-target-mark-msgs (msgs)
3673 (if (eq wl-summary-buffer-view 'thread)
3674 (wl-thread-jump-to-msg (car msgs))
3675 (wl-summary-jump-to-msg (car msgs)))
3676 (wl-summary-target-mark (wl-summary-message-number))
3677 (setq msgs (cdr msgs))))
3679 (defun wl-summary-pick (&optional from-list delete-marks)
3681 (let ((result (elmo-msgdb-search
3682 wl-summary-buffer-elmo-folder
3683 (elmo-read-search-condition wl-summary-pick-field-default)
3684 (wl-summary-buffer-msgdb))))
3686 (let ((mlist wl-summary-buffer-target-mark-list))
3688 (when (wl-summary-jump-to-msg (car mlist))
3689 (wl-summary-unmark))
3690 (setq mlist (cdr mlist)))
3691 (setq wl-summary-buffer-target-mark-list nil)))
3693 (setq result (elmo-list-filter from-list result)))
3694 (message "%d message(s) are picked." (length result))
3696 (message "No message was picked.")
3697 (wl-summary-target-mark-msgs result))))
3699 (defun wl-summary-unvirtual ()
3700 "Exit from current virtual folder."
3703 (elmo-folder-type-internal wl-summary-buffer-elmo-folder))
3704 (wl-summary-goto-folder-subr
3705 (elmo-folder-name-internal
3706 (elmo-filter-folder-target-internal
3707 wl-summary-buffer-elmo-folder))
3709 (error "This folder is not filtered")))
3711 (defun wl-summary-virtual (&optional arg)
3712 "Goto virtual folder.
3713 If ARG, exit virtual folder."
3716 (wl-summary-unvirtual)
3717 (wl-summary-goto-folder-subr (concat "/"
3718 (elmo-read-search-condition
3719 wl-summary-pick-field-default)
3721 (wl-summary-buffer-folder-name))
3722 'update nil nil t)))
3724 (defun wl-summary-delete-all-temp-marks ()
3727 (goto-char (point-min))
3728 (message "Unmarking...")
3732 (message "Unmarking...done")
3733 (setq wl-summary-buffer-target-mark-list nil)
3734 (setq wl-summary-buffer-delete-list nil)
3735 (setq wl-summary-buffer-refile-list nil)
3736 (setq wl-summary-buffer-copy-list nil)))
3738 (defun wl-summary-delete-mark (number)
3739 "Delete temporary mark of the message specified by NUMBER."
3741 ((memq number wl-summary-buffer-target-mark-list)
3742 (setq wl-summary-buffer-target-mark-list
3743 (delq number wl-summary-buffer-target-mark-list)))
3744 ((memq number wl-summary-buffer-delete-list)
3745 (setq wl-summary-buffer-delete-list
3746 (delq number wl-summary-buffer-delete-list)))
3750 ((setq pair (assq number wl-summary-buffer-copy-list))
3751 (setq wl-summary-buffer-copy-list
3752 (delq pair wl-summary-buffer-copy-list)))
3753 ((setq pair (assq number wl-summary-buffer-refile-list))
3754 (setq wl-summary-buffer-refile-list
3755 (delq pair wl-summary-buffer-refile-list))))))))
3757 (defun wl-summary-mark-line (mark)
3758 "Put MARK on current line. Return message number."
3761 (let ((inhibit-read-only t)
3762 (buffer-read-only nil)
3765 (when (looking-at "^ *\\(-?[0-9]+\\)\\([^0-9]\\)")
3766 (setq msg-num (string-to-int (wl-match-buffer 1)))
3767 (setq cur-mark (wl-match-buffer 2))
3768 (goto-char (match-end 1))
3769 (delete-region (match-beginning 2) (match-end 2))
3770 ;;; (wl-summary-delete-mark msg-num)
3772 (if wl-summary-highlight
3773 (wl-highlight-summary-current-line nil nil t))
3774 (set-buffer-modified-p nil)
3777 (defun wl-summary-target-mark-delete ()
3780 (goto-char (point-min))
3781 (let ((regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
3783 (while (re-search-forward regexp nil t)
3784 (let (wl-summary-buffer-disp-msg)
3785 (when (setq number (wl-summary-message-number))
3786 (wl-summary-delete number)
3787 (setq wl-summary-buffer-target-mark-list
3788 (delq number wl-summary-buffer-target-mark-list)))))
3789 (setq mlist wl-summary-buffer-target-mark-list)
3791 (wl-append wl-summary-buffer-delete-list (list (car mlist)))
3792 (setq wl-summary-buffer-target-mark-list
3793 (delq (car mlist) wl-summary-buffer-target-mark-list))
3794 (setq mlist (cdr mlist))))))
3796 (defun wl-summary-target-mark-prefetch ()
3799 (let* ((mlist (nreverse wl-summary-buffer-target-mark-list))
3800 (inhibit-read-only t)
3801 (buffer-read-only nil)
3803 (length (length mlist))
3808 (setq new-mark (wl-summary-prefetch-msg (car mlist)))
3811 (message "Prefetching... %d/%d message(s)"
3812 (setq count (+ 1 count)) length)
3813 (when (wl-summary-jump-to-msg (car mlist))
3816 (when (looking-at "^ *-?[0-9]+[^0-9]\\([^0-9]\\)")
3817 (delete-region (match-beginning 1) (match-end 1)))
3818 (goto-char (match-beginning 1))
3820 (if wl-summary-highlight
3821 (wl-highlight-summary-current-line))
3825 (setq skipped (cons (car mlist) skipped)))
3826 (setq mlist (cdr mlist)))
3827 (setq wl-summary-buffer-target-mark-list skipped)
3828 (message "Prefetching... %d/%d message(s)." count length)
3829 (set-buffer-modified-p nil))))
3831 (defun wl-summary-target-mark-refile-subr (copy-or-refile)
3833 (intern (format "wl-summary-buffer-%s-list" copy-or-refile)))
3835 (intern (format "wl-summary-%s" copy-or-refile)))
3836 regexp number msgid entity folder mlist)
3838 (goto-char (point-min))
3839 (setq regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
3840 ;; guess by first mark
3841 (when (re-search-forward regexp nil t)
3842 (setq msgid (cdr (assq (setq number (wl-summary-message-number))
3843 (elmo-msgdb-get-number-alist
3844 (wl-summary-buffer-msgdb))))
3846 (elmo-msgdb-get-overview
3847 (wl-summary-buffer-msgdb))))
3849 (error "Cannot %s" copy-or-refile))
3851 (setq folder (wl-summary-read-folder
3852 (wl-refile-guess entity)
3853 (format "for %s" copy-or-refile)))
3856 (setq wl-summary-buffer-target-mark-list
3857 (delq number wl-summary-buffer-target-mark-list)))
3858 (while (re-search-forward regexp nil t)
3859 (let (wl-summary-buffer-disp-msg)
3860 (when (setq number (wl-summary-message-number))
3861 (funcall function folder number)
3862 (setq wl-summary-buffer-target-mark-list
3863 (delq number wl-summary-buffer-target-mark-list)))))
3864 ;; process invisible messages.
3865 (setq mlist wl-summary-buffer-target-mark-list)
3868 (append (symbol-value variable)
3869 (list (cons (car mlist) folder))))
3870 (setq wl-summary-buffer-target-mark-list
3871 (delq (car mlist) wl-summary-buffer-target-mark-list))
3872 (setq mlist (cdr mlist)))))))
3874 (defun wl-summary-target-mark-copy ()
3876 (wl-summary-target-mark-refile-subr "copy"))
3878 (defun wl-summary-target-mark-refile ()
3880 (wl-summary-target-mark-refile-subr "refile"))
3882 (defun wl-summary-target-mark-mark-as-read ()
3885 (goto-char (point-min))
3886 (let ((regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
3887 (inhibit-read-only t)
3888 (buffer-read-only nil)
3890 (while (re-search-forward regexp nil t)
3891 (let (wl-summary-buffer-disp-msg)
3892 ;; delete target-mark from buffer.
3893 (delete-region (match-beginning 1) (match-end 1))
3895 (setq number (wl-summary-mark-as-read t))
3896 (if wl-summary-highlight
3897 (wl-highlight-summary-current-line))
3899 (setq wl-summary-buffer-target-mark-list
3900 (delq number wl-summary-buffer-target-mark-list)))))
3901 (setq mlist wl-summary-buffer-target-mark-list)
3903 (wl-summary-mark-as-read t nil nil (car mlist))
3904 (setq wl-summary-buffer-target-mark-list
3905 (delq (car mlist) wl-summary-buffer-target-mark-list))
3906 (setq mlist (cdr mlist)))
3907 (wl-summary-count-unread
3908 (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
3909 (wl-summary-update-modeline))))
3911 (defun wl-summary-target-mark-mark-as-unread ()
3914 (goto-char (point-min))
3915 (let ((regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
3916 (inhibit-read-only t)
3917 (buffer-read-only nil)
3919 (while (re-search-forward regexp nil t)
3920 (let (wl-summary-buffer-disp-msg)
3921 ;; delete target-mark from buffer.
3922 (delete-region (match-beginning 1) (match-end 1))
3924 (setq number (wl-summary-mark-as-unread))
3925 (if wl-summary-highlight
3926 (wl-highlight-summary-current-line))
3928 (setq wl-summary-buffer-target-mark-list
3929 (delq number wl-summary-buffer-target-mark-list)))))
3930 (setq mlist wl-summary-buffer-target-mark-list)
3932 (wl-summary-mark-as-unread (car mlist))
3933 ;;; (wl-thread-msg-mark-as-unread (car mlist))
3934 (setq wl-summary-buffer-target-mark-list
3935 (delq (car mlist) wl-summary-buffer-target-mark-list))
3936 (setq mlist (cdr mlist)))
3937 (wl-summary-count-unread
3938 (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
3939 (wl-summary-update-modeline))))
3941 (defun wl-summary-target-mark-mark-as-important ()
3944 (goto-char (point-min))
3945 (let ((regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
3946 (inhibit-read-only t)
3947 (buffer-read-only nil)
3949 (while (re-search-forward regexp nil t)
3950 (let (wl-summary-buffer-disp-msg)
3951 ;; delete target-mark from buffer.
3952 (delete-region (match-beginning 1) (match-end 1))
3954 (setq number (wl-summary-mark-as-important))
3955 (if wl-summary-highlight
3956 (wl-highlight-summary-current-line))
3958 (setq wl-summary-buffer-target-mark-list
3959 (delq number wl-summary-buffer-target-mark-list)))))
3960 (setq mlist wl-summary-buffer-target-mark-list)
3962 (wl-summary-mark-as-important (car mlist))
3963 (wl-thread-msg-mark-as-important (car mlist))
3964 (setq wl-summary-buffer-target-mark-list
3965 (delq (car mlist) wl-summary-buffer-target-mark-list))
3966 (setq mlist (cdr mlist)))
3967 (wl-summary-count-unread
3968 (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
3969 (wl-summary-update-modeline))))
3971 (defun wl-summary-target-mark-save ()
3974 (goto-char (point-min))
3976 (wl-read-directory-name "Save to directory: " wl-tmp-dir))
3977 (regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
3979 (if (null (file-exists-p wl-save-dir))
3980 (make-directory wl-save-dir))
3981 (while (re-search-forward regexp nil t)
3982 (let (wl-summary-buffer-disp-msg)
3983 (setq number (wl-summary-save t wl-save-dir))
3986 (setq wl-summary-buffer-target-mark-list
3987 (delq number wl-summary-buffer-target-mark-list))))))))
3989 (defun wl-summary-target-mark-pick ()
3991 (wl-summary-pick wl-summary-buffer-target-mark-list 'delete))
3993 (defun wl-summary-mark-as-read (&optional notcrosses
3994 leave-server-side-mark-untouched
4001 (inhibit-read-only t)
4002 (buffer-read-only nil)
4003 (folder wl-summary-buffer-elmo-folder)
4004 (msgdb (wl-summary-buffer-msgdb))
4005 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
4006 ;;; (number-alist (elmo-msgdb-get-number-alist msgdb))
4007 (case-fold-search nil)
4008 mark stat visible uncached new-mark marked)
4011 (setq visible (wl-summary-jump-to-msg number))
4012 (setq mark (cadr (assq number mark-alist))))
4016 (if (or (not visible)
4018 (format "^ *\\(-?[0-9]+\\)[^0-9]\\(%s\\|%s\\|%s\\|%s\\).*$"
4019 (regexp-quote wl-summary-read-uncached-mark)
4020 (regexp-quote wl-summary-unread-uncached-mark)
4021 (regexp-quote wl-summary-unread-cached-mark)
4022 (regexp-quote wl-summary-new-mark))))
4024 (setq mark (or mark (wl-match-buffer 2)))
4027 ((string= mark wl-summary-new-mark) ; N
4030 ((string= mark wl-summary-unread-uncached-mark) ; U
4033 ((string= mark wl-summary-unread-cached-mark) ; !
4034 (setq stat 'unread))
4036 ;; no need to mark server.
4037 (setq leave-server-side-mark-untouched t))))
4038 (setq number (or number (string-to-int (wl-match-buffer 1))))
4039 ;; set server side mark...
4040 (setq new-mark (if (and uncached
4041 (if (elmo-message-use-cache-p folder number)
4042 (not (elmo-folder-local-p folder)))
4044 wl-summary-read-uncached-mark
4046 (if (not leave-server-side-mark-untouched)
4048 (setq marked (elmo-folder-mark-as-read
4051 (if (or leave-server-side-mark-untouched
4054 (cond ((eq stat 'unread)
4055 (setq wl-summary-buffer-unread-count
4056 (1- wl-summary-buffer-unread-count)))
4058 (setq wl-summary-buffer-new-count
4059 (1- wl-summary-buffer-new-count))))
4060 (wl-summary-update-modeline)
4061 (wl-folder-update-unread
4062 (wl-summary-buffer-folder-name)
4063 (+ wl-summary-buffer-unread-count
4064 wl-summary-buffer-new-count))
4065 (when (or stat cached)
4067 (goto-char (match-end 2))
4068 (delete-region (match-beginning 2) (match-end 2))
4069 (insert (or new-mark " ")))
4071 (elmo-msgdb-mark-set mark-alist number new-mark))
4072 (elmo-msgdb-set-mark-alist msgdb mark-alist)
4073 (wl-summary-set-mark-modified))
4074 (if (and visible wl-summary-highlight)
4075 (wl-highlight-summary-current-line nil nil t)))
4076 (if mark (message "Warning: Changing mark failed.")))))
4077 (set-buffer-modified-p nil)
4079 (run-hooks 'wl-summary-unread-message-hook))
4080 number ;return value
4083 (defun wl-summary-mark-as-important (&optional number
4087 (if (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
4089 (error "Cannot process mark in this folder"))
4092 (inhibit-read-only t)
4093 (buffer-read-only nil)
4094 (folder wl-summary-buffer-elmo-folder)
4095 (msgdb (wl-summary-buffer-msgdb))
4096 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
4097 (number-alist (elmo-msgdb-get-number-alist msgdb))
4101 (setq visible (wl-summary-jump-to-msg number))
4102 (setq mark (or mark (cadr (assq number mark-alist)))))
4105 (if (null (setq number (wl-summary-message-number)))
4107 (message "No message.")
4111 (re-search-backward (concat "^" wl-summary-buffer-number-regexp
4112 "..../..") nil t)) ; set cursor line
4113 (beginning-of-line))
4114 (if (or (and (not visible)
4115 (assq number (elmo-msgdb-get-number-alist msgdb)))
4116 (re-search-forward "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9]\\)" eol t))
4118 (setq number (or number (string-to-int (wl-match-buffer 1))))
4119 (setq mark (or mark (wl-match-buffer 2)))
4120 (setq message-id (elmo-message-field
4121 wl-summary-buffer-elmo-folder
4124 (if (string= mark wl-summary-important-mark)
4128 (unless no-server-update
4129 (elmo-folder-unmark-important folder (list number))
4130 (elmo-msgdb-global-mark-delete message-id))
4131 ;; Remove cache if local folder.
4132 (if (and (elmo-folder-local-p folder)
4134 (elmo-folder-type-internal folder))))
4135 (elmo-file-cache-delete
4136 (elmo-file-cache-get-path message-id))))
4138 (delete-region (match-beginning 2) (match-end 2))
4141 (elmo-msgdb-mark-set mark-alist
4146 (unless no-server-update
4147 (elmo-folder-mark-as-important folder (list number))))
4149 (delete-region (match-beginning 2) (match-end 2))
4150 (insert wl-summary-important-mark))
4152 (elmo-msgdb-mark-set mark-alist
4154 wl-summary-important-mark))
4155 (if (elmo-file-cache-exists-p message-id)
4156 (elmo-folder-mark-as-read folder (list number))
4157 ;; Force cache message.
4158 (elmo-message-encache folder number 'read))
4159 (unless no-server-update
4160 (elmo-msgdb-global-mark-set message-id
4161 wl-summary-important-mark)))
4162 (elmo-msgdb-set-mark-alist msgdb mark-alist)
4163 (wl-summary-set-mark-modified)))
4164 (if (and visible wl-summary-highlight)
4165 (wl-highlight-summary-current-line nil nil t))))
4166 (set-buffer-modified-p nil)
4169 (defsubst wl-summary-format-date (date-string)
4171 (let ((datevec (timezone-fix-time date-string nil
4172 wl-summary-fix-timezone)))
4173 (format "%02d/%02d(%s)%02d:%02d"
4176 (elmo-date-get-week (aref datevec 0)
4181 (error "??/??(??)??:??")))
4183 (defun wl-summary-overview-create-summary-line (msg
4190 temp-mark thr-entity
4192 (let ((wl-mime-charset wl-summary-buffer-mime-charset)
4193 (elmo-mime-charset wl-summary-buffer-mime-charset)
4194 no-parent before-indent
4195 from subject parent-raw-subject parent-subject
4197 (elmo-lang wl-summary-buffer-weekday-name-lang)
4198 (children-num (if children-num (int-to-string children-num)))
4202 (setq thr-str (wl-thread-make-indent-string thr-entity))
4203 (setq linked (wl-thread-entity-get-linked thr-entity)))
4204 (if (string= thr-str "")
4205 (setq no-parent t)) ; no parent
4206 (if (and wl-summary-width
4207 wl-summary-indent-length-limit
4208 (< wl-summary-indent-length-limit
4209 (string-width thr-str)))
4210 (setq thr-str (wl-set-string-width
4211 wl-summary-indent-length-limit
4214 (wl-set-string-width
4216 (- wl-from-width (length children-num) 2)
4218 (elmo-delete-char ?\n
4219 (wl-summary-from-func-internal
4220 (elmo-msgdb-overview-entity-get-from entity)))))
4222 (elmo-delete-char ?\n
4223 (or (elmo-msgdb-overview-entity-get-subject
4225 wl-summary-no-subject-message)))
4226 (setq parent-raw-subject
4227 (elmo-msgdb-overview-entity-get-subject parent-entity))
4228 (setq parent-subject
4229 (if parent-raw-subject
4230 (elmo-delete-char ?\n parent-raw-subject)))
4231 (setq mark (or (cadr (assq msg mark-alist)) " "))
4237 wl-summary-buffer-number-column)
4242 (wl-summary-format-date
4243 (elmo-msgdb-overview-entity-get-date entity))
4244 (if thr-str thr-str "")))
4249 (concat "+" children-num ": " from)
4254 (null parent-subject)
4255 (not (wl-summary-subject-equal
4256 subject parent-subject)))
4257 (wl-summary-subject-func-internal subject) ""))
4258 (if (and (not wl-summary-width)
4259 wl-subject-length-limit)
4260 (truncate-string subject wl-subject-length-limit)
4262 (if wl-summary-width (setq line
4263 (wl-set-string-width
4264 (- wl-summary-width 1) line)))
4265 (if wl-summary-highlight
4266 (wl-highlight-summary-line-string line
4272 (defsubst wl-summary-buffer-number-column-detect (update)
4275 (goto-char (point-min))
4276 (setq wl-summary-buffer-number-column
4279 (setq end (if (re-search-forward
4280 "^ *-?[0-9]+[^0-9]" nil t)
4282 (- end (progn (beginning-of-line) (point)) 1))
4283 (wl-get-assoc-list-value wl-summary-number-column-alist
4284 (wl-summary-buffer-folder-name))
4285 wl-summary-default-number-column))
4286 (setq wl-summary-buffer-number-regexp
4287 (wl-repeat-string "." wl-summary-buffer-number-column)))))
4289 (defsubst wl-summary-proc-wday (wday-str year month mday)
4291 (if (string-match "\\([A-Z][a-z][a-z]\\).*" wday-str)
4292 (wl-match-string 1 wday-str)
4293 (elmo-date-get-week year month mday))))
4295 (defvar wl-summary-move-spec-plugged-alist
4296 (` ((new . ((t . nil)
4297 (p . (, wl-summary-new-mark))
4298 (p . (, (wl-regexp-opt
4299 (list wl-summary-unread-uncached-mark
4300 wl-summary-unread-cached-mark))))
4301 (p . (, (regexp-quote wl-summary-important-mark)))))
4302 (unread . ((t . nil)
4303 (p . (, (wl-regexp-opt
4304 (list wl-summary-new-mark
4305 wl-summary-unread-uncached-mark
4306 wl-summary-unread-cached-mark))))
4307 (p . (, (regexp-quote wl-summary-important-mark))))))))
4309 (defvar wl-summary-move-spec-unplugged-alist
4310 (` ((new . ((t . nil)
4311 (p . (, wl-summary-unread-cached-mark))
4312 (p . (, (regexp-quote wl-summary-important-mark)))))
4313 (unread . ((t . nil)
4314 (p . (, wl-summary-unread-cached-mark))
4315 (p . (, (regexp-quote wl-summary-important-mark))))))))
4317 (defsubst wl-summary-next-message (num direction hereto)
4318 (if wl-summary-buffer-next-message-function
4319 (funcall wl-summary-buffer-next-message-function num direction hereto)
4320 (let ((cur-spec (cdr (assq wl-summary-move-order
4321 (if (elmo-folder-plugged-p
4322 wl-summary-buffer-elmo-folder)
4323 wl-summary-move-spec-plugged-alist
4324 wl-summary-move-spec-unplugged-alist))))
4325 (nums (memq num (if (eq direction 'up)
4326 (reverse wl-summary-buffer-number-list)
4327 wl-summary-buffer-number-list)))
4329 (unless hereto (setq nums (cdr nums)))
4335 (cond ((eq (car (car cur-spec)) 'p)
4336 (if (setq marked-list
4337 (elmo-folder-list-messages-mark-match
4338 wl-summary-buffer-elmo-folder
4339 (cdr (car cur-spec))))
4341 (if (memq (car nums) marked-list)
4342 (throw 'done (car nums)))
4343 (setq nums (cdr nums)))))
4344 ((eq (car (car cur-spec)) 't)
4345 (if wl-summary-buffer-target-mark-list
4347 (if (memq (car nums)
4348 wl-summary-buffer-target-mark-list)
4349 (throw 'done (car nums)))
4350 (setq nums (cdr nums))))))
4351 (setq cur-spec (cdr cur-spec))))
4354 (defsubst wl-summary-cursor-move (direction hereto)
4355 (when (and (eq direction 'up)
4360 (when (setq num (wl-summary-next-message (wl-summary-message-number)
4363 (wl-thread-jump-to-msg num))
4366 ;; Goto unread or important
4367 ;; returns t if next message exists in this folder.
4368 (defun wl-summary-cursor-down (&optional hereto)
4370 (wl-summary-cursor-move 'down hereto))
4372 (defun wl-summary-cursor-up (&optional hereto)
4374 (wl-summary-cursor-move 'up hereto))
4376 (defun wl-summary-save-view-cache ()
4378 (let* ((dir (elmo-folder-msgdb-path wl-summary-buffer-elmo-folder))
4379 (cache (expand-file-name wl-summary-cache-file dir))
4380 (view (expand-file-name wl-summary-view-file dir))
4381 (save-view wl-summary-buffer-view)
4382 (tmp-buffer (get-buffer-create " *wl-summary-save-view-cache*"))
4383 (charset wl-summary-buffer-mime-charset))
4384 (if (file-directory-p dir)
4386 (if (file-exists-p dir)
4387 (error "File %s already exists" dir)
4388 (elmo-make-directory dir)))
4389 (if (eq save-view 'thread)
4390 (wl-thread-save-entity dir))
4393 (when (file-writable-p cache)
4394 (copy-to-buffer tmp-buffer (point-min) (point-max))
4395 (with-current-buffer tmp-buffer
4397 (encode-mime-charset-region
4398 (point-min) (point-max) charset)
4399 (write-region-as-binary (point-min)(point-max)
4400 cache nil 'no-msg)))
4401 (when (file-writable-p view) ; 'thread or 'sequence
4403 (set-buffer tmp-buffer)
4405 (prin1 save-view tmp-buffer)
4406 (princ "\n" tmp-buffer)
4407 (write-region (point-min) (point-max) view nil 'no-msg))))
4409 (kill-buffer tmp-buffer)))))
4411 (defsubst wl-summary-get-sync-range (folder)
4413 (elmo-folder-plugged-p folder)
4414 (wl-get-assoc-list-value
4415 wl-folder-sync-range-alist
4416 (elmo-folder-name-internal folder)))
4417 wl-default-sync-range)))
4419 ;; redefined for wl-summary-sync-update
4420 (defun wl-summary-input-range (folder)
4421 "returns update or all or rescan."
4422 ;; for the case when parts are expanded in the bottom of the folder
4423 (let ((input-range-list '("update" "all" "rescan" "first:" "last:"
4424 "no-sync" "rescan-noscore" "all-visible"))
4425 (default (or (wl-get-assoc-list-value
4426 wl-folder-sync-range-alist
4428 wl-default-sync-range))
4431 (completing-read (format "Range (%s): " default)
4433 (function (lambda (x) (cons x x)))
4435 (if (string= range "")
4439 (defun wl-summary-toggle-disp-folder (&optional arg)
4441 (let ((cur-buf (current-buffer))
4442 (summary-win (get-buffer-window (current-buffer)))
4446 (setq wl-summary-buffer-disp-folder t)
4447 ;; hide your folder window
4448 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
4449 (if (setq fld-win (get-buffer-window fld-buf))
4450 (delete-window fld-win))))
4452 (setq wl-summary-buffer-disp-folder nil)
4453 ;; hide your wl-message window!
4454 (when (buffer-live-p wl-message-buffer)
4455 (wl-message-select-buffer wl-message-buffer)
4457 (select-window (get-buffer-window cur-buf))
4458 ;; display wl-folder window!!
4459 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
4460 (if (setq fld-win (get-buffer-window fld-buf))
4461 ;; folder win is already displayed.
4462 (select-window fld-win)
4463 ;; folder win is not displayed.
4464 (switch-to-buffer fld-buf))
4467 ;; temporarily delete summary-win.
4469 (delete-window summary-win))
4470 (split-window-horizontally wl-folder-window-width)
4472 (switch-to-buffer cur-buf))
4474 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
4475 (if (setq fld-win (get-buffer-window fld-buf))
4476 (setq wl-summary-buffer-disp-folder nil)
4477 (setq wl-summary-buffer-disp-folder t)))
4478 (if (not wl-summary-buffer-disp-folder)
4479 ;; hide message window
4480 (let ((mes-win (and wl-message-buffer
4481 (get-buffer-window wl-message-buffer)))
4482 (wl-stay-folder-window t))
4483 (if mes-win (delete-window mes-win))
4484 ;; hide your folder window
4485 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
4486 (if (setq fld-win (get-buffer-window fld-buf))
4488 (delete-window (get-buffer-window cur-buf))
4489 (select-window fld-win)
4490 (switch-to-buffer cur-buf))))
4491 (run-hooks 'wl-summary-toggle-disp-folder-off-hook)
4492 ;; resume message window.
4494 (wl-message-select-buffer wl-message-buffer)
4495 (run-hooks 'wl-summary-toggle-disp-folder-message-resumed-hook)
4496 (select-window (get-buffer-window cur-buf)))
4498 ;; hide message window
4499 (let ((wl-stay-folder-window t)
4500 (mes-win (and wl-message-buffer
4501 (get-buffer-window wl-message-buffer))))
4502 (if mes-win (delete-window mes-win))
4503 (select-window (get-buffer-window cur-buf))
4504 ;; display wl-folder window!!
4505 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
4506 (if (setq fld-win (get-buffer-window fld-buf))
4507 ;; folder win is already displayed.
4508 (select-window fld-win)
4509 ;; folder win is not displayed...occupy all.
4510 (switch-to-buffer fld-buf))
4513 (split-window-horizontally wl-folder-window-width)
4515 (switch-to-buffer cur-buf)
4516 ;; resume message window.
4517 (run-hooks 'wl-summary-toggle-disp-folder-on-hook)
4519 (wl-message-select-buffer wl-message-buffer)
4520 (run-hooks 'wl-summary-toggle-disp-folder-message-resumed-hook)
4521 (select-window (get-buffer-window cur-buf))))
4523 (run-hooks 'wl-summary-toggle-disp-folder-hook))
4525 (defun wl-summary-toggle-disp-msg (&optional arg)
4527 (let ((cur-buf (current-buffer))
4532 (setq wl-summary-buffer-disp-msg t)
4534 ;; hide your folder window
4535 (if (and (not wl-stay-folder-window)
4536 (setq fld-buf (get-buffer wl-folder-buffer-name)))
4537 (if (setq fld-win (get-buffer-window fld-buf))
4538 (unless (one-window-p fld-win)
4539 (delete-window fld-win))))))
4541 (wl-delete-all-overlays)
4542 (setq wl-summary-buffer-disp-msg nil)
4544 (when (buffer-live-p wl-message-buffer)
4545 (wl-message-select-buffer wl-message-buffer)
4547 (and (get-buffer-window cur-buf)
4548 (select-window (get-buffer-window cur-buf))))
4549 (run-hooks 'wl-summary-toggle-disp-off-hook)))
4551 (if (and wl-message-buffer
4552 (get-buffer-window wl-message-buffer)) ; already displayed
4553 (setq wl-summary-buffer-disp-msg nil)
4554 (setq wl-summary-buffer-disp-msg t))
4555 (if wl-summary-buffer-disp-msg
4557 (wl-summary-redisplay)
4558 ;;; hide your folder window
4559 ;;; (setq fld-buf (get-buffer wl-folder-buffer-name))
4560 ;;; (if (setq fld-win (get-buffer-window fld-buf))
4561 ;;; (delete-window fld-win)))
4562 (run-hooks 'wl-summary-toggle-disp-on-hook))
4563 (wl-delete-all-overlays)
4565 (wl-message-select-buffer wl-message-buffer)
4567 (select-window (get-buffer-window cur-buf))
4568 (run-hooks 'wl-summary-toggle-disp-off-hook))
4569 ;;; (switch-to-buffer cur-buf)
4572 (defun wl-summary-next-line-content ()
4573 "Show next line of the message."
4575 (let ((cur-buf (current-buffer)))
4576 (wl-summary-toggle-disp-msg 'on)
4577 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
4578 (set-buffer cur-buf)
4579 (wl-message-next-page 1))))
4581 (defun wl-summary-prev-line-content ()
4583 (let ((cur-buf (current-buffer)))
4584 (wl-summary-toggle-disp-msg 'on)
4585 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
4586 (set-buffer cur-buf)
4587 (wl-message-prev-page 1))))
4589 (defun wl-summary-next-page ()
4591 (wl-message-next-page))
4593 (defun wl-summary-prev-page ()
4595 (wl-message-prev-page))
4597 (defsubst wl-summary-no-mime-p (folder)
4598 (wl-string-match-member (elmo-folder-name-internal folder)
4599 wl-summary-no-mime-folder-list))
4601 (defun wl-summary-set-message-buffer-or-redisplay (&rest args)
4602 "Set message buffer.
4603 If message is not displayed yet, display it.
4604 Return t if message exists."
4605 (let ((folder wl-summary-buffer-elmo-folder)
4606 (number (wl-summary-message-number))
4607 cur-folder cur-number message-last-pos)
4608 (when (buffer-live-p wl-message-buffer)
4609 (save-window-excursion
4610 (wl-message-select-buffer wl-message-buffer)
4611 (setq cur-folder wl-message-buffer-cur-folder)
4612 (setq cur-number wl-message-buffer-cur-number)))
4613 (if (and (string= (elmo-folder-name-internal folder) (or cur-folder ""))
4614 (eq number (or cur-number 0)))
4616 (set-buffer wl-message-buffer)
4618 (if (wl-summary-no-mime-p folder)
4619 (wl-summary-redisplay-no-mime folder number)
4620 (wl-summary-redisplay-internal folder number))
4621 (when (buffer-live-p wl-message-buffer)
4622 (set-buffer wl-message-buffer))
4625 (defun wl-summary-target-mark-forward (&optional arg)
4627 (let ((mlist (nreverse wl-summary-buffer-target-mark-list))
4628 (summary-buf (current-buffer))
4629 (wl-draft-forward t)
4632 (wl-summary-jump-to-msg (car mlist))
4633 (wl-summary-forward t)
4634 (setq start-point (point))
4635 (setq draft-buf (current-buffer))
4636 (setq mlist (cdr mlist))
4637 (save-window-excursion
4640 (set-buffer summary-buf)
4641 (wl-summary-jump-to-msg (car mlist))
4642 (wl-summary-redisplay)
4643 (set-buffer draft-buf)
4644 (goto-char (point-max))
4645 (wl-draft-insert-message)
4646 (setq mlist (cdr mlist)))
4647 (wl-draft-body-goto-top)
4648 (wl-draft-enclose-digest-region (point) (point-max)))
4649 (goto-char start-point)
4651 (set-buffer summary-buf)
4652 (wl-summary-delete-all-temp-marks)))
4653 (run-hooks 'wl-mail-setup-hook)))
4655 (defun wl-summary-target-mark-reply-with-citation (&optional arg)
4657 (let ((mlist (nreverse wl-summary-buffer-target-mark-list))
4658 (summary-buf (current-buffer))
4659 change-major-mode-hook
4662 (wl-summary-jump-to-msg (car mlist))
4663 (wl-summary-reply arg t)
4664 (goto-char (point-max))
4665 (setq start-point (point-marker))
4666 (setq draft-buf (current-buffer))
4667 (save-window-excursion
4669 (set-buffer summary-buf)
4670 (delete-other-windows)
4671 (wl-summary-jump-to-msg (car mlist))
4672 (wl-summary-redisplay)
4673 (set-buffer draft-buf)
4674 (goto-char (point-max))
4675 (wl-draft-yank-original)
4676 (setq mlist (cdr mlist)))
4677 (goto-char start-point)
4679 (set-buffer summary-buf)
4680 (wl-summary-delete-all-temp-marks)))
4681 (run-hooks 'wl-mail-setup-hook)))
4683 (defun wl-summary-reply-with-citation (&optional arg)
4685 (when (wl-summary-reply arg t)
4686 (goto-char (point-max))
4687 (wl-draft-yank-original)
4688 (run-hooks 'wl-mail-setup-hook)))
4690 (defun wl-summary-jump-to-msg-by-message-id (&optional id)
4692 (let* ((original (wl-summary-message-number))
4693 (msgid (elmo-string (or id (read-from-minibuffer "Message-ID: "))))
4694 (number-alist (elmo-msgdb-get-number-alist (wl-summary-buffer-msgdb)))
4697 (format "No message with id \"%s\" in the folder." msgid)))
4698 (if (setq msg (car (rassoc msgid number-alist)))
4699 ;;; (wl-summary-jump-to-msg-internal
4700 ;;; (wl-summary-buffer-folder-name) msg 'no-sync)
4702 (wl-thread-jump-to-msg msg)
4705 (if (and elmo-use-database
4708 "No message with id \"%s\" in the database." msgid))
4709 (setq otherfld (elmo-database-msgid-get msgid)))
4710 (if (cdr (wl-summary-jump-to-msg-internal
4711 (car otherfld) (nth 1 otherfld) 'no-sync))
4713 ;; Back to original.
4714 (wl-summary-jump-to-msg-internal
4715 (wl-summary-buffer-folder-name) original 'no-sync))
4716 (cond ((eq wl-summary-search-via-nntp 'confirm)
4717 (require 'elmo-nntp)
4718 (message "Search message in nntp server \"%s\" <y/n/s(elect)>?"
4719 elmo-nntp-default-server)
4720 (setq schar (read-char))
4721 (cond ((eq schar ?y)
4722 (wl-summary-jump-to-msg-by-message-id-via-nntp msgid))
4724 (wl-summary-jump-to-msg-by-message-id-via-nntp
4726 (read-from-minibuffer "NNTP Server: ")))
4730 (wl-summary-search-via-nntp
4731 (wl-summary-jump-to-msg-by-message-id-via-nntp msgid))
4736 (defun wl-summary-jump-to-msg-by-message-id-via-nntp (&optional id server-spec)
4738 (let* ((msgid (elmo-string (or id (read-from-minibuffer "Message-ID: "))))
4739 newsgroups folder ret
4740 user server port type spec)
4742 (if (string-match "^-" server-spec)
4743 (setq spec (wl-folder-get-elmo-folder server-spec)
4744 user (elmo-net-folder-user-internal spec)
4745 server (elmo-net-folder-server-internal spec)
4746 port (elmo-net-folder-port-internal spec)
4747 type (elmo-net-folder-stream-type-internal spec))
4748 (setq server server-spec)))
4749 (when (setq ret (elmo-nntp-get-newsgroup-by-msgid
4751 (or server elmo-nntp-default-server)
4752 (or user elmo-nntp-default-user)
4753 (or port elmo-nntp-default-port)
4754 (or type elmo-nntp-default-stream-type)))
4755 (setq newsgroups (elmo-nntp-parse-newsgroups ret))
4756 (setq folder (concat "-" (car newsgroups)
4757 (elmo-nntp-folder-postfix user server port type)))
4760 (if (wl-folder-entity-exists-p (car newsgroups)
4761 wl-folder-newsgroups-hashtb)
4763 (setq folder (concat "-" (car newsgroups)
4764 (elmo-nntp-folder-postfix
4765 user server port type)))))
4766 (setq newsgroups (cdr newsgroups)))))
4768 (wl-summary-jump-to-msg-internal folder nil 'update msgid)
4769 (message "No message id \"%s\" in nntp server \"%s\"."
4770 msgid (or server elmo-nntp-default-server))
4773 (defun wl-summary-jump-to-msg-internal (folder msg scan-type &optional msgid)
4774 (let (wl-auto-select-first entity)
4775 (if (or (string= folder (wl-summary-buffer-folder-name))
4778 "Message was found in the folder \"%s\". Jump to it? "
4782 (wl-summary-goto-folder-subr
4783 folder scan-type nil nil t)
4787 (elmo-msgdb-get-number-alist
4788 (wl-summary-buffer-msgdb))))))
4789 (setq entity (wl-folder-search-entity-by-name folder
4793 (wl-folder-set-current-entity-id
4794 (wl-folder-get-entity-id entity))))
4796 (message "Message was not found currently in this folder.")
4797 (setq msg (and (wl-thread-jump-to-msg msg) msg)))
4798 (cons folder msg)))))
4800 (defun wl-summary-jump-to-parent-message (arg)
4802 (let ((cur-buf (current-buffer))
4803 (number (wl-summary-message-number))
4804 (regexp "\\(<[^<>]*>\\)[ \t]*$")
4806 msg-id msg-num ref-list ref irt)
4808 (message "No message.")
4809 (when (eq wl-summary-buffer-view 'thread)
4810 (cond ((and arg (not (numberp arg)))
4812 (wl-thread-entity-get-number
4813 (wl-thread-entity-get-top-entity
4814 (wl-thread-get-entity number)))))
4815 ((and arg (numberp arg))
4817 (setq msg-num number)
4820 (wl-thread-entity-get-number
4821 (wl-thread-entity-get-parent-entity
4822 (wl-thread-get-entity msg-num))))
4825 (wl-thread-entity-get-number
4826 (wl-thread-entity-get-parent-entity
4827 (wl-thread-get-entity number)))))))
4828 (when (null msg-num)
4829 (wl-summary-set-message-buffer-or-redisplay)
4830 (set-buffer (wl-message-get-original-buffer))
4831 (message "Searching parent message...")
4832 (setq ref (std11-field-body "References")
4833 irt (std11-field-body "In-Reply-To"))
4835 ((and arg (not (numberp arg)) ref (not (string= ref ""))
4836 (string-match regexp ref))
4837 ;; The first message of the thread.
4838 (setq msg-id (wl-match-string 1 ref)))
4839 ;; "In-Reply-To:" has only one msg-id.
4840 ((and (null arg) irt (not (string= irt ""))
4841 (string-match regexp irt))
4842 (setq msg-id (wl-match-string 1 irt)))
4843 ((and (or (null arg) (numberp arg)) ref (not (string= ref ""))
4844 (string-match regexp ref))
4845 ;; "^" searching parent, "C-u 2 ^" looking for grandparent.
4846 (while (string-match regexp ref)
4849 (wl-match-string 1 ref))
4851 (setq ref (substring ref (match-end 0)))
4854 (if (null arg) (nth 0 ref-list) ;; previous
4855 (if (<= arg i) (nth (1- arg) ref-list)
4856 (nth i ref-list)))))))
4857 (set-buffer cur-buf)
4858 (cond ((and (null msg-id) (null msg-num))
4859 (message "No parent message!")
4861 ((and msg-id (wl-summary-jump-to-msg-by-message-id msg-id))
4862 (wl-summary-redisplay)
4863 (message "Searching parent message...done")
4865 ((and msg-num (wl-summary-jump-to-msg msg-num))
4866 (wl-summary-redisplay)
4867 (message "Searching parent message...done")
4870 (message "Parent message was not found.")
4873 (defun wl-summary-reply (&optional arg without-setup-hook)
4874 "Reply to current message. Default is \"wide\" reply.
4875 Reply to author if invoked with ARG."
4877 (let ((folder wl-summary-buffer-elmo-folder)
4878 (number (wl-summary-message-number))
4879 (summary-buf (current-buffer))
4883 (wl-summary-redisplay-internal folder number))
4884 (setq mes-buf wl-message-buffer)
4885 (wl-message-select-buffer wl-message-buffer)
4886 (set-buffer mes-buf)
4887 (goto-char (point-min))
4888 (unless wl-draft-use-frame
4889 (split-window-vertically)
4891 (when (setq mes-buf (wl-message-get-original-buffer))
4892 (wl-draft-reply mes-buf arg summary-buf)
4893 (unless without-setup-hook
4894 (run-hooks 'wl-mail-setup-hook)))
4897 (defun wl-summary-write ()
4898 "Write a new draft from Summary."
4900 (wl-draft nil nil nil nil nil
4901 nil nil nil nil nil nil (current-buffer))
4902 (run-hooks 'wl-mail-setup-hook)
4903 (mail-position-on-field "To"))
4905 (defvar wl-summary-write-current-folder-functions
4906 '(wl-folder-get-newsgroups
4907 wl-folder-guess-mailing-list-by-refile-rule
4908 wl-folder-guess-mailing-list-by-folder-name)
4909 "Newsgroups or Mailing List address guess functions list.
4910 Call from `wl-summary-write-current-folder'")
4912 (defun wl-summary-write-current-folder (&optional folder)
4913 "Write message to current FOLDER's newsgroup or mailing-list.
4914 Use function list is `wl-summary-write-current-folder-functions'."
4916 (let (newsgroups to cc)
4917 ;; default FOLDER is current buffer folder
4918 (setq folder (or folder (wl-summary-buffer-folder-name)))
4919 (let ((flist wl-summary-write-current-folder-functions)
4922 (setq guess-list (funcall (car flist) folder))
4923 (if (or (nth 0 guess-list) ; To:
4924 ;;; (nth 1 guess-list) ; Cc:
4925 (nth 2 guess-list)) ; Newsgroups:
4927 (setq flist (cdr flist))))
4928 (when (null guess-list)
4929 (error "Can't guess by folder %s" folder))
4930 (wl-draft (nth 0 guess-list) nil nil ; To:
4931 (nth 1 guess-list) nil ; Cc:
4932 (nth 2 guess-list)) ; Newsgroups:
4933 (run-hooks 'wl-mail-setup-hook)
4934 (mail-position-on-field "Subject"))))
4936 (defun wl-summary-forward (&optional without-setup-hook)
4939 (let ((folder wl-summary-buffer-elmo-folder)
4940 (number (wl-summary-message-number))
4941 (summary-buf (current-buffer))
4942 (wl-draft-forward t)
4946 (message "No message.")
4947 (if (and (elmo-message-use-cache-p folder number)
4948 (eq (elmo-file-cache-status
4949 (elmo-file-cache-get
4950 (elmo-message-field folder number 'message-id)))
4953 (wl-summary-redisplay-internal nil nil 'force-reload)
4954 (wl-summary-redisplay-internal folder number))
4955 (setq mes-buf wl-message-buffer)
4956 (wl-message-select-buffer mes-buf)
4957 (unless wl-draft-use-frame
4958 (split-window-vertically)
4960 ;; get original subject.
4963 (set-buffer summary-buf)
4965 (or (elmo-message-field folder number 'subject) ""))))
4966 (set-buffer mes-buf)
4967 (wl-draft-forward subject summary-buf)
4968 (unless without-setup-hook
4969 (run-hooks 'wl-mail-setup-hook)))))
4971 (defun wl-summary-click (e)
4976 (defun wl-summary-read ()
4977 "Proceed reading message in the summary buffer."
4979 (let ((cur-buf (current-buffer)))
4980 (wl-summary-toggle-disp-msg 'on)
4981 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
4982 (set-buffer cur-buf)
4983 (if (wl-message-next-page)
4984 (wl-summary-down t)))))
4986 (defun wl-summary-prev (&optional interactive)
4989 (if wl-summary-move-direction-toggle
4990 (setq wl-summary-move-direction-downward nil))
4991 (let ((skip-mark-regexp (mapconcat
4993 wl-summary-skip-mark-list ""))
4994 goto-next regex-list regex next-entity finfo)
4996 (if (elmo-folder-plugged-p wl-summary-buffer-elmo-folder)
4997 (setq regex (format "^%s[^%s]"
4998 wl-summary-buffer-number-regexp
5000 (setq regex (format "^%s[^%s]\\(%s\\|%s\\| \\)"
5001 wl-summary-buffer-number-regexp
5003 (regexp-quote wl-summary-unread-cached-mark)
5004 (regexp-quote wl-summary-important-mark))))
5005 (unless (re-search-backward regex nil t)
5010 (if wl-summary-buffer-disp-msg
5011 (wl-summary-redisplay)))
5012 (if (or interactive (interactive-p))
5013 (if wl-summary-buffer-prev-folder-function
5014 (funcall wl-summary-buffer-prev-folder-function)
5015 (when wl-auto-select-next
5016 (setq next-entity (wl-summary-get-prev-folder))
5018 (setq finfo (wl-folder-get-entity-info next-entity))))
5020 '(lambda () (wl-summary-next-folder-or-exit next-entity))
5022 "No more messages. Type SPC to go to %s."
5023 (wl-summary-entity-info-msg next-entity finfo))))))))
5025 (defun wl-summary-next (&optional interactive)
5028 (if wl-summary-move-direction-toggle
5029 (setq wl-summary-move-direction-downward t))
5030 (let ((skip-mark-regexp (mapconcat
5032 wl-summary-skip-mark-list ""))
5033 goto-next regex regex-list next-entity finfo)
5035 (if (elmo-folder-plugged-p wl-summary-buffer-elmo-folder)
5036 (setq regex (format "^%s[^%s]"
5037 wl-summary-buffer-number-regexp
5039 (setq regex (format "^%s[^%s]\\(%s\\|%s\\| \\)"
5040 wl-summary-buffer-number-regexp
5042 (regexp-quote wl-summary-unread-cached-mark)
5043 (regexp-quote wl-summary-important-mark))))
5044 (unless (re-search-forward regex nil t)
5049 (if wl-summary-buffer-disp-msg
5050 (wl-summary-redisplay))
5051 (if (or interactive (interactive-p))
5052 (if wl-summary-buffer-next-folder-function
5053 (funcall wl-summary-buffer-next-folder-function)
5054 (when wl-auto-select-next
5055 (setq next-entity (wl-summary-get-next-folder))
5057 (setq finfo (wl-folder-get-entity-info next-entity))))
5059 '(lambda () (wl-summary-next-folder-or-exit next-entity))
5061 "No more messages. Type SPC to go to %s."
5062 (wl-summary-entity-info-msg next-entity finfo))))))))
5064 (defun wl-summary-up (&optional interactive skip-no-unread)
5067 (if wl-summary-move-direction-toggle
5068 (setq wl-summary-move-direction-downward nil))
5069 (if (wl-summary-cursor-up)
5070 (if wl-summary-buffer-disp-msg
5071 (wl-summary-redisplay))
5074 (if wl-summary-buffer-prev-folder-function
5075 (funcall wl-summary-buffer-prev-folder-function)
5076 (let (next-entity finfo)
5077 (when wl-auto-select-next
5079 (setq next-entity (wl-summary-get-prev-unread-folder))
5081 (setq finfo (wl-folder-get-entity-info next-entity)))))
5082 (if (and skip-no-unread
5083 (eq wl-auto-select-next 'skip-no-unread))
5084 (wl-summary-next-folder-or-exit next-entity t)
5086 '(lambda () (wl-summary-next-folder-or-exit next-entity t))
5088 "No more unread messages. Type SPC to go to %s."
5089 (wl-summary-entity-info-msg next-entity finfo)))))))))
5091 (defun wl-summary-get-prev-folder ()
5092 (let ((folder-buf (get-buffer wl-folder-buffer-name))
5095 (setq cur-id (save-excursion (set-buffer folder-buf)
5096 wl-folder-buffer-cur-entity-id))
5097 (wl-folder-get-prev-folder cur-id))))
5099 (defun wl-summary-get-next-folder ()
5100 (let ((folder-buf (get-buffer wl-folder-buffer-name))
5103 (setq cur-id (save-excursion (set-buffer folder-buf)
5104 wl-folder-buffer-cur-entity-id))
5105 (wl-folder-get-next-folder cur-id))))
5107 (defun wl-summary-get-next-unread-folder ()
5108 (let ((folder-buf (get-buffer wl-folder-buffer-name))
5111 (setq cur-id (save-excursion (set-buffer folder-buf)
5112 wl-folder-buffer-cur-entity-id))
5113 (wl-folder-get-next-folder cur-id 'unread))))
5115 (defun wl-summary-get-prev-unread-folder ()
5116 (let ((folder-buf (get-buffer wl-folder-buffer-name))
5119 (setq cur-id (save-excursion (set-buffer folder-buf)
5120 wl-folder-buffer-cur-entity-id))
5121 (wl-folder-get-prev-folder cur-id 'unread))))
5123 (defun wl-summary-down (&optional interactive skip-no-unread)
5125 (if wl-summary-move-direction-toggle
5126 (setq wl-summary-move-direction-downward t))
5127 (if (wl-summary-cursor-down)
5128 (if wl-summary-buffer-disp-msg
5129 (wl-summary-redisplay))
5132 (if wl-summary-buffer-next-folder-function
5133 (funcall wl-summary-buffer-next-folder-function)
5134 (let (next-entity finfo)
5135 (when wl-auto-select-next
5136 (setq next-entity (wl-summary-get-next-unread-folder)))
5138 (setq finfo (wl-folder-get-entity-info next-entity)))
5139 (if (and skip-no-unread
5140 (eq wl-auto-select-next 'skip-no-unread))
5141 (wl-summary-next-folder-or-exit next-entity)
5143 '(lambda () (wl-summary-next-folder-or-exit next-entity))
5145 "No more unread messages. Type SPC to go to %s."
5146 (wl-summary-entity-info-msg next-entity finfo)))))))))
5148 (defun wl-summary-goto-last-displayed-msg ()
5150 (unless wl-summary-buffer-last-displayed-msg
5151 (setq wl-summary-buffer-last-displayed-msg
5152 wl-summary-buffer-current-msg))
5153 (if wl-summary-buffer-last-displayed-msg
5155 (wl-summary-jump-to-msg wl-summary-buffer-last-displayed-msg)
5156 (if wl-summary-buffer-disp-msg
5157 (wl-summary-redisplay)))
5158 (message "No last message.")))
5160 (defun wl-summary-redisplay (&optional arg)
5163 (wl-summary-no-mime-p wl-summary-buffer-elmo-folder))
5164 (wl-summary-redisplay-no-mime)
5165 (wl-summary-redisplay-internal nil nil arg)))
5167 (defsubst wl-summary-redisplay-internal (&optional folder number force-reload)
5169 (let* ((msgdb (wl-summary-buffer-msgdb))
5170 (folder (or folder wl-summary-buffer-elmo-folder))
5171 (num (or number (wl-summary-message-number)))
5172 (wl-mime-charset wl-summary-buffer-mime-charset)
5173 (default-mime-charset wl-summary-buffer-mime-charset)
5174 fld-buf fld-win thr-entity)
5175 (if (and wl-thread-open-reading-thread
5176 (eq wl-summary-buffer-view 'thread)
5177 (not (wl-thread-entity-get-opened
5178 (setq thr-entity (wl-thread-get-entity
5180 (wl-thread-entity-get-children thr-entity))
5181 (wl-thread-force-open))
5184 (setq wl-summary-buffer-disp-msg t)
5185 (setq wl-summary-buffer-last-displayed-msg
5186 wl-summary-buffer-current-msg)
5187 ;; hide folder window
5188 (if (and (not wl-stay-folder-window)
5189 (setq fld-buf (get-buffer wl-folder-buffer-name)))
5190 (if (setq fld-win (get-buffer-window fld-buf))
5191 (delete-window fld-win)))
5192 (setq wl-current-summary-buffer (current-buffer))
5193 (wl-summary-mark-as-read
5195 ;; not fetched, then change server-mark.
5196 (if (wl-message-redisplay folder num 'mime
5198 (string= (elmo-folder-name-internal
5202 ;; plugged, then leave server-mark.
5205 (elmo-folder-local-p
5206 wl-summary-buffer-elmo-folder))
5207 (elmo-folder-plugged-p
5208 wl-summary-buffer-elmo-folder))
5212 'cached ; cached by reading.
5214 (setq wl-summary-buffer-current-msg num)
5215 (when wl-summary-recenter
5216 (recenter (/ (- (window-height) 2) 2))
5217 (if (not wl-summary-width)
5218 (wl-horizontal-recenter)))
5219 (wl-highlight-summary-displaying)
5220 (wl-message-buffer-prefetch-next folder num (current-buffer)
5221 wl-summary-buffer-mime-charset)
5222 (run-hooks 'wl-summary-redisplay-hook))
5223 (message "No message to display."))))
5225 (defun wl-summary-redisplay-no-mime (&optional folder number)
5227 (let* ((fld (or folder wl-summary-buffer-elmo-folder))
5228 (num (or number (wl-summary-message-number)))
5232 (setq wl-summary-buffer-disp-msg t)
5233 (setq wl-summary-buffer-last-displayed-msg
5234 wl-summary-buffer-current-msg)
5235 (setq wl-current-summary-buffer (current-buffer))
5236 (wl-message-redisplay fld num 'as-is
5237 (string= (elmo-folder-name-internal fld)
5239 (wl-summary-mark-as-read nil nil t)
5240 (setq wl-summary-buffer-current-msg num)
5241 (when wl-summary-recenter
5242 (recenter (/ (- (window-height) 2) 2))
5243 (if (not wl-summary-width)
5244 (wl-horizontal-recenter)))
5245 (wl-highlight-summary-displaying)
5246 (run-hooks 'wl-summary-redisplay-hook))
5247 (message "No message to display.")
5248 (wl-ask-folder 'wl-summary-exit
5249 "No more messages. Type SPC to go to folder mode."))))
5251 (defun wl-summary-redisplay-all-header (&optional folder number)
5253 (let* ((fld (or folder wl-summary-buffer-elmo-folder))
5254 (num (or number (wl-summary-message-number)))
5255 (wl-mime-charset wl-summary-buffer-mime-charset)
5256 (default-mime-charset wl-summary-buffer-mime-charset))
5259 (setq wl-summary-buffer-disp-msg t)
5260 (setq wl-summary-buffer-last-displayed-msg
5261 wl-summary-buffer-current-msg)
5262 (setq wl-current-summary-buffer (current-buffer))
5263 (if (wl-message-redisplay fld num 'all-header
5264 (string= (elmo-folder-name-internal fld)
5266 (wl-summary-mark-as-read nil nil t))
5267 (setq wl-summary-buffer-current-msg num)
5268 (when wl-summary-recenter
5269 (recenter (/ (- (window-height) 2) 2))
5270 (if (not wl-summary-width)
5271 (wl-horizontal-recenter)))
5272 (wl-highlight-summary-displaying)
5273 (run-hooks 'wl-summary-redisplay-hook))
5274 (message "No message to display."))))
5276 (defun wl-summary-jump-to-current-message ()
5278 (let (message-buf message-win)
5279 (if (setq message-buf wl-message-buffer)
5280 (if (setq message-win (get-buffer-window message-buf))
5281 (select-window message-win)
5282 (wl-message-select-buffer wl-message-buffer))
5283 (wl-summary-redisplay)
5284 (wl-message-select-buffer wl-message-buffer))))
5286 (defun wl-summary-cancel-message ()
5287 "Cancel an article on news."
5289 (if (null (wl-summary-message-number))
5290 (message "No message.")
5291 (let ((summary-buf (current-buffer))
5293 (wl-summary-set-message-buffer-or-redisplay)
5294 (if (setq message-buf (wl-message-get-original-buffer))
5295 (set-buffer message-buf))
5296 (unless (wl-message-news-p)
5297 (set-buffer summary-buf)
5298 (if (and (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
5300 (y-or-n-p "Cannot get Newsgroups. Fetch again? "))
5302 (wl-summary-redisplay t)
5303 (wl-summary-supersedes-message))
5304 (error "This is not a news article; supersedes is impossible")))
5305 (when (yes-or-no-p "Do you really want to cancel this article? ")
5306 (let (from newsgroups message-id distribution buf)
5308 (setq from (std11-field-body "from")
5309 newsgroups (std11-field-body "newsgroups")
5310 message-id (std11-field-body "message-id")
5311 distribution (std11-field-body "distribution"))
5312 ;; Make sure that this article was written by the user.
5313 (unless (wl-address-user-mail-address-p
5314 (wl-address-header-extract-address
5315 (car (wl-parse-addresses from))))
5316 (error "This article is not yours"))
5317 ;; Make control message.
5318 (setq buf (set-buffer (get-buffer-create " *message cancel*")))
5319 (setq wl-draft-buffer-cur-summary-buffer summary-buf)
5320 (buffer-disable-undo (current-buffer))
5322 (insert "Newsgroups: " newsgroups "\n"
5323 "From: " (wl-address-header-extract-address
5325 "Subject: cmsg cancel " message-id "\n"
5326 "Control: cancel " message-id "\n"
5328 (concat "Distribution: " distribution "\n")
5330 mail-header-separator "\n"
5331 wl-summary-cancel-message)
5332 (message "Canceling your message...")
5333 (wl-draft-raw-send t t) ; kill when done, force-pre-hooks.
5334 (message "Canceling your message...done")))))))
5336 (defun wl-summary-supersedes-message ()
5337 "Supersede current message."
5339 (let ((summary-buf (current-buffer))
5340 (mmelmo-force-fetch-entire-message t)
5342 (wl-summary-set-message-buffer-or-redisplay)
5343 (if (setq message-buf (wl-message-get-original-buffer))
5344 (set-buffer message-buf))
5345 (unless (wl-message-news-p)
5346 (set-buffer summary-buf)
5347 (if (and (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
5349 (y-or-n-p "Cannot get Newsgroups. Fetch again? "))
5351 (wl-summary-redisplay t)
5352 (wl-summary-supersedes-message))
5353 (error "This is not a news article; supersedes is impossible")))
5355 (setq from (std11-field-body "from"))
5356 ;; Make sure that this article was written by the user.
5357 (unless (wl-address-user-mail-address-p
5358 (wl-address-header-extract-address
5359 (car (wl-parse-addresses from))))
5360 (error "This article is not yours"))
5361 (let* ((message-id (std11-field-body "message-id"))
5362 (followup-to (std11-field-body "followup-to"))
5363 (mail-default-headers
5364 (concat mail-default-headers
5365 "Supersedes: " message-id "\n"
5367 (concat "Followup-To: " followup-to "\n")))))
5368 (if message-buf (set-buffer message-buf))
5369 (wl-draft-edit-string (buffer-substring (point-min) (point-max)))))))
5371 (defun wl-summary-save (&optional arg wl-save-dir)
5374 (num (wl-summary-message-number))
5375 (mmelmo-force-fetch-entire-message t))
5376 (if (null wl-save-dir)
5377 (setq wl-save-dir wl-tmp-dir))
5380 (setq filename (expand-file-name
5384 (null (file-exists-p filename))))
5386 (read-file-name "Save to file: " filename)))
5388 (wl-summary-set-message-buffer-or-redisplay)
5389 (set-buffer (wl-message-get-original-buffer))
5390 (if (and (null arg) (file-exists-p filename))
5391 (if (y-or-n-p "File already exists. override it? ")
5392 (write-region (point-min) (point-max) filename))
5393 (write-region (point-min) (point-max) filename)))
5394 (message "No message to save."))
5397 (defun wl-summary-save-region (beg end)
5401 (narrow-to-region beg end)
5402 (goto-char (point-min))
5404 (wl-read-directory-name "Save to directory: " wl-tmp-dir)))
5405 (if (null (file-exists-p wl-save-dir))
5406 (make-directory wl-save-dir))
5407 (if (eq wl-summary-buffer-view 'thread)
5410 (let* ((number (wl-summary-message-number))
5411 (entity (wl-thread-get-entity number)))
5412 (if (wl-thread-entity-get-opened entity)
5413 (wl-summary-save t wl-save-dir)
5415 (wl-summary-save t wl-save-dir))
5418 (wl-summary-save t wl-save-dir)
5419 (forward-line 1)))))))
5421 ;; mew-summary-pipe-message()
5422 (defun wl-summary-pipe-message (prefix command)
5423 "Send this message via pipe."
5424 (interactive (list current-prefix-arg nil))
5425 (if (null (wl-summary-message-number))
5426 (message "No message.")
5427 (setq command (read-string "Shell command on message: "
5428 wl-summary-shell-command-last))
5429 (if (y-or-n-p "Send this message to pipe? ")
5431 (wl-summary-set-message-buffer-or-redisplay)
5432 (set-buffer (wl-message-get-original-buffer))
5433 (if (string= command "")
5434 (setq command wl-summary-shell-command-last))
5435 (goto-char (point-min)) ; perhaps this line won't be necessary
5437 (search-forward "\n\n"))
5438 (shell-command-on-region (point) (point-max) command nil)
5439 (setq wl-summary-shell-command-last command)))))
5441 (defun wl-summary-print-message (&optional arg)
5443 (if (null (wl-summary-message-number))
5444 (message "No message.")
5446 (wl-summary-set-message-buffer-or-redisplay)
5447 (if (or (not (interactive-p))
5448 (y-or-n-p "Print ok? "))
5450 (let ((buffer (generate-new-buffer " *print*")))
5451 (copy-to-buffer buffer (point-min) (point-max))
5453 (funcall wl-print-buffer-function)
5454 (kill-buffer buffer)))
5457 (defun wl-summary-print-message-with-ps-print (&optional filename)
5459 (if (null (wl-summary-message-number))
5460 (message "No message.")
5461 (setq filename (ps-print-preprint current-prefix-arg))
5462 (if (or (not (interactive-p))
5463 (y-or-n-p "Print ok? "))
5464 (let ((summary-buffer (current-buffer))
5467 (wl-summary-set-message-buffer-or-redisplay)
5468 ;; (wl-summary-redisplay-internal)
5469 (let* ((buffer (generate-new-buffer " *print*"))
5471 (set-buffer summary-buffer)
5473 (wl-summary-message-number)
5474 (elmo-msgdb-get-number-alist
5475 (wl-summary-buffer-msgdb))))
5476 (elmo-msgdb-get-overview
5477 (wl-summary-buffer-msgdb)))))
5480 (or (elmo-msgdb-overview-entity-get-subject entity)
5484 (or (elmo-msgdb-overview-entity-get-from entity) "")))
5487 (or (elmo-msgdb-overview-entity-get-date entity) ""))))
5488 (run-hooks 'wl-ps-preprint-hook)
5489 (set-buffer wl-message-buffer)
5490 (copy-to-buffer buffer (point-min) (point-max))
5493 (let ((ps-left-header
5494 (list (concat "(" wl-ps-subject ")")
5495 (concat "(" wl-ps-from ")")))
5497 (list "/pagenumberstring load"
5498 (concat "(" wl-ps-date ")"))))
5499 (run-hooks 'wl-ps-print-hook)
5500 (funcall wl-ps-print-buffer-function filename))
5501 (kill-buffer buffer)))))
5504 (if (featurep 'ps-print) ; ps-print is available.
5505 (fset 'wl-summary-print-message 'wl-summary-print-message-with-ps-print))
5507 (defun wl-summary-folder-info-update ()
5508 (let ((folder (elmo-string (wl-summary-buffer-folder-name)))
5509 (num-db (elmo-msgdb-get-number-alist
5510 (wl-summary-buffer-msgdb))))
5511 (wl-folder-set-folder-updated folder
5513 (+ wl-summary-buffer-unread-count
5514 wl-summary-buffer-new-count)
5517 (defun wl-summary-get-original-buffer ()
5518 "Get original buffer for the current summary."
5520 (wl-summary-set-message-buffer-or-redisplay)
5521 (wl-message-get-original-buffer)))
5523 (defun wl-summary-pack-number (&optional arg)
5525 (elmo-folder-pack-numbers wl-summary-buffer-elmo-folder)
5526 (let (wl-use-scoring)
5527 (wl-summary-rescan)))
5529 (defun wl-summary-target-mark-uudecode ()
5531 (let ((mlist (reverse wl-summary-buffer-target-mark-list))
5532 (summary-buf (current-buffer))
5533 (tmp-buf (get-buffer-create "*WL UUENCODE*"))
5534 orig-buf i k filename rc errmsg)
5536 (setq k (length mlist))
5537 (set-buffer tmp-buf)
5539 (save-window-excursion
5541 (set-buffer summary-buf)
5542 (wl-summary-jump-to-msg (car mlist))
5543 (wl-summary-redisplay)
5544 (set-buffer (setq orig-buf (wl-summary-get-original-buffer)))
5545 (goto-char (point-min))
5546 (cond ((= i 1) ; first
5547 (if (setq filename (wl-message-uu-substring
5551 (error "Can't find begin line")))
5553 (wl-message-uu-substring orig-buf tmp-buf))
5555 (wl-message-uu-substring orig-buf tmp-buf nil t)))
5557 (setq mlist (cdr mlist)))
5558 (set-buffer tmp-buf)
5559 (message "Exec %s..." wl-prog-uudecode)
5561 (let ((decode-dir wl-tmp-dir))
5562 (if (not wl-prog-uudecode-no-stdout-option)
5563 (setq filename (read-file-name "Save to file: "
5565 (elmo-safe-filename filename)
5568 (wl-read-directory-name "Save to directory: "
5570 (setq filename (expand-file-name filename decode-dir)))
5571 (if (file-exists-p filename)
5572 (or (yes-or-no-p (format "File %s exists. Save anyway? "
5575 (elmo-bind-directory
5579 (apply 'call-process-region (point-min) (point-max)
5580 wl-prog-uudecode t (current-buffer) nil
5581 wl-prog-uudecode-arg))))
5582 (when (not (= 0 rc))
5583 (setq errmsg (buffer-substring (point-min)(point-max)))
5584 (error "Uudecode error: %s" errmsg))
5585 (if (not wl-prog-uudecode-no-stdout-option)
5586 (let (file-name-handler-alist) ;; void jka-compr
5587 (as-binary-output-file
5588 (write-region (point-min) (point-max)
5589 filename nil 'no-msg))))
5591 (set-buffer summary-buf)
5592 (wl-summary-delete-all-temp-marks))
5593 (if (file-exists-p filename)
5594 (message "Saved as %s" filename)))
5595 (kill-buffer tmp-buf)))))
5598 ;; (defun wl-summary-drop-unsync ()
5599 ;; "Drop all unsync messages."
5601 ;; (if (elmo-folder-pipe-p (wl-summary-buffer-folder-name))
5602 ;; (error "You cannot drop unsync messages in this folder"))
5603 ;; (if (or (not (interactive-p))
5604 ;; (y-or-n-p "Drop all unsync messages? "))
5605 ;; (let* ((folder-list (elmo-folder-get-primitive-folder-list
5606 ;; (wl-summary-buffer-folder-name)))
5607 ;; (is-multi (elmo-multi-p (wl-summary-buffer-folder-name)))
5611 ;; (message "Dropping...")
5612 ;; (while folder-list
5613 ;; (setq pair (elmo-folder-message-numbers (car folder-list)))
5614 ;; (when is-multi ;; dirty hack...
5616 ;; (setcar pair (+ (* multi-num elmo-multi-divide-number)
5618 ;; (elmo-msgdb-set-number-alist
5619 ;; (wl-summary-buffer-msgdb)
5621 ;; (elmo-msgdb-get-number-alist (wl-summary-buffer-msgdb))
5622 ;; (list (cons (car pair) nil))))
5623 ;; (setq sum (+ sum (cdr pair)))
5624 ;; (setq folder-list (cdr folder-list)))
5625 ;; (wl-summary-set-message-modified)
5626 ;; (wl-folder-set-folder-updated (wl-summary-buffer-folder-name)
5628 ;; (+ wl-summary-buffer-unread-count
5629 ;; wl-summary-buffer-new-count)
5631 ;; (message "Dropping...done"))))
5633 (defun wl-summary-default-get-next-msg (msg)
5634 (or (wl-summary-next-message msg
5635 (if wl-summary-move-direction-downward 'down
5638 (cadr (memq msg (if wl-summary-move-direction-downward
5639 wl-summary-buffer-number-list
5640 (reverse wl-summary-buffer-number-list))))))
5642 (defun wl-summary-save-current-message ()
5643 "Save current message for `wl-summary-yank-saved-message'."
5645 (let ((number (wl-summary-message-number)))
5646 (setq wl-summary-buffer-saved-message number)
5647 (and number (message "No: %s is saved." number))))
5649 (defun wl-summary-yank-saved-message ()
5650 "Set current message as a parent of the saved message."
5652 (if wl-summary-buffer-saved-message
5653 (let ((number (wl-summary-message-number)))
5654 (if (eq wl-summary-buffer-saved-message number)
5655 (message "Cannot set itself as a parent.")
5657 (wl-thread-jump-to-msg wl-summary-buffer-saved-message)
5658 (wl-thread-set-parent number)
5659 (wl-summary-set-thread-modified))
5660 (setq wl-summary-buffer-saved-message nil)))
5661 (message "There's no saved message.")))
5664 (product-provide (provide 'wl-summary) (require 'wl-version))
5666 ;;; wl-summary.el ends here