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-message-string (&optional use-cache)
568 "Return full body string of current message.
569 If optional USE-CACHE is non-nil, use cache if exists."
570 (let ((number (wl-summary-message-number))
571 (folder wl-summary-buffer-elmo-folder))
573 (message "No message.")
575 (elmo-message-fetch folder
577 (elmo-make-fetch-strategy
579 use-cache ; use cache
580 nil ; save cache (should `t'?)
583 (elmo-file-cache-get-path
584 (elmo-message-field folder number 'message-id))))
590 (defun wl-summary-reedit (&optional arg)
591 "Re-edit current message.
592 If ARG is non-nil, Supersedes message"
595 (wl-summary-supersedes-message)
596 (if (string= (wl-summary-buffer-folder-name) wl-draft-folder)
597 (if (wl-summary-message-number)
599 (wl-draft-reedit (wl-summary-message-number))
600 (if (wl-message-news-p)
601 (mail-position-on-field "Newsgroups")
602 (mail-position-on-field "To"))
603 (delete-other-windows)))
604 (wl-draft-edit-string (wl-summary-message-string)))))
606 (defun wl-summary-resend-bounced-mail ()
607 "Re-mail the current message.
608 This only makes sense if the current message is a bounce message which
609 contains some mail you have written but has been bounced back to
613 (wl-summary-set-message-buffer-or-redisplay)
614 (set-buffer (wl-message-get-original-buffer))
615 (goto-char (point-min))
616 (let ((case-fold-search nil))
620 (concat "^\\($\\|[Cc]ontent-[Tt]ype:[ \t]+multipart/\\(report\\|mixed\\)\\)") nil t)
622 (re-search-forward "boundary=\"\\([^\"]+\\)\"" nil t))
623 (let ((boundary (buffer-substring (match-beginning 1) (match-end 1)))
626 ((and (setq start (re-search-forward
627 (concat "^--" boundary "\n"
628 "\\([Cc]ontent-[Dd]escription:.*\n\\)?"
629 "[Cc]ontent-[Tt]ype:[ \t]+"
630 "\\(message/rfc822\\|text/rfc822-headers\\)\n"
631 "\\(.+\n\\)*\n") nil t))
633 (concat "\n\\(--" boundary "\\)--\n") nil t))
634 (wl-draft-edit-string (buffer-substring start (match-beginning 1))))
636 (message "Seems no message/rfc822 part.")))))
637 ((let ((case-fold-search t))
638 (re-search-forward wl-rejected-letter-start nil t))
639 (skip-chars-forward " \t\n")
640 (wl-draft-edit-string (buffer-substring (point) (point-max))))
642 (message "Does not appear to be a rejected letter."))))))
644 (defun wl-summary-resend-message (address)
645 "Resend the current message to ADDRESS."
646 (interactive "sResend message to: ")
647 (if (or (null address) (string-match "^[ \t]*$" address))
648 (message "No address specified.")
649 (message "Resending message to %s..." address)
651 (let ((original (wl-summary-get-original-buffer)))
652 ;; We first set up a normal mail buffer.
653 (set-buffer (get-buffer-create " *wl-draft-resend*"))
654 (buffer-disable-undo (current-buffer))
656 (setq wl-sent-message-via nil)
657 ;; Insert our usual headers.
658 (wl-draft-insert-from-field)
659 (wl-draft-insert-date-field)
660 (insert "to: " address "\n")
661 (goto-char (point-min))
662 ;; Rename them all to "Resent-*".
663 (while (re-search-forward "^[A-Za-z]" nil t)
668 (delete-region (point) (point-max))
670 ;; Insert the message to be resent.
671 (insert-buffer-substring original)
672 (goto-char (point-min))
673 (search-forward "\n\n")
676 (narrow-to-region beg (point))
677 (wl-draft-delete-fields wl-ignored-resent-headers)
678 (goto-char (point-max)))
679 (insert mail-header-separator)
680 ;; Rename all old ("Previous-")Resent headers.
681 (while (re-search-backward "^\\(Previous-\\)*Resent-" beg t)
683 (insert "Previous-"))
684 ;; Quote any "From " lines at the beginning.
686 (when (looking-at "From ")
687 (replace-match "X-From-Line: ")))
689 (wl-draft-dispatch-message)
690 (kill-buffer (current-buffer)))
691 (message "Resending message to %s...done" address))))
693 (defun wl-summary-buffer-set-folder (folder)
695 (setq folder (wl-folder-get-elmo-folder folder)))
696 (setq wl-summary-buffer-elmo-folder folder)
697 (setq wl-summary-buffer-folder-indicator
698 (if (memq 'modeline wl-use-folder-petname)
699 (wl-folder-get-petname (elmo-folder-name-internal folder))
700 (elmo-folder-name-internal folder)))
701 (make-local-variable 'wl-message-buffer)
702 (setq wl-summary-buffer-mime-charset (or (wl-get-assoc-list-value
703 wl-folder-mime-charset-alist
704 (elmo-folder-name-internal folder))
706 (setq wl-summary-buffer-weekday-name-lang
707 (or (wl-get-assoc-list-value
708 wl-folder-weekday-name-lang-alist
709 (elmo-folder-name-internal folder))
710 wl-summary-weekday-name-lang))
711 (setq wl-summary-buffer-thread-indent-set
712 (wl-get-assoc-list-value
713 wl-folder-thread-indent-set-alist
714 (elmo-folder-name-internal folder)))
715 (setq wl-summary-buffer-persistent
716 (wl-folder-persistent-p (elmo-folder-name-internal folder)))
717 (elmo-folder-set-persistent-internal folder wl-summary-buffer-persistent)
718 ;; process duplicates.
719 (elmo-folder-set-process-duplicates-internal
720 folder (cdr (elmo-string-matched-assoc
721 (elmo-folder-name-internal folder)
722 wl-folder-process-duplicates-alist)))
724 wl-thread-indent-level-internal
725 (or (nth 0 wl-summary-buffer-thread-indent-set)
726 wl-thread-indent-level)
727 wl-thread-have-younger-brother-str-internal
728 (or (nth 1 wl-summary-buffer-thread-indent-set)
729 wl-thread-have-younger-brother-str)
730 wl-thread-youngest-child-str-internal
731 (or (nth 2 wl-summary-buffer-thread-indent-set)
732 wl-thread-youngest-child-str)
733 wl-thread-vertical-str-internal
734 (or (nth 3 wl-summary-buffer-thread-indent-set)
735 wl-thread-vertical-str)
736 wl-thread-horizontal-str-internal
737 (or (nth 4 wl-summary-buffer-thread-indent-set)
738 wl-thread-horizontal-str)
739 wl-thread-space-str-internal
740 (or (nth 5 wl-summary-buffer-thread-indent-set)
741 wl-thread-space-str))
742 (setq wl-thread-indent-regexp
744 (regexp-quote wl-thread-have-younger-brother-str-internal) "\\|"
745 (regexp-quote wl-thread-youngest-child-str-internal) "\\|"
746 (regexp-quote wl-thread-vertical-str-internal) "\\|"
747 (regexp-quote wl-thread-horizontal-str-internal) "\\|"
748 (regexp-quote wl-thread-space-str-internal)))
749 (run-hooks 'wl-summary-buffer-set-folder-hook))
751 (defun wl-summary-mode ()
752 "Major mode for reading threaded messages.
753 See Info under Wanderlust for full documentation.
756 \\{wl-summary-mode-map}
758 Entering Folder mode calls the value of `wl-summary-mode-hook'."
760 (unless (interactive-p) (kill-all-local-variables))
761 (setq major-mode 'wl-summary-mode)
762 (setq mode-name "Summary")
763 (use-local-map wl-summary-mode-map)
764 ;;;(setq default-directory (or wl-tmp-dir (expand-file-name "~/")))
765 (setq buffer-read-only t)
766 (setq truncate-lines t)
767 ;;;(make-local-variable 'tab-width)
768 ;;;(setq tab-width 1)
769 (buffer-disable-undo (current-buffer))
770 (wl-mode-line-buffer-identification '("Wanderlust: "
771 wl-summary-buffer-folder-indicator
772 wl-summary-buffer-unread-status))
773 (easy-menu-add wl-summary-mode-menu)
774 (when wl-summary-lazy-highlight
775 (make-local-variable 'window-scroll-functions)
776 (add-hook 'window-scroll-functions 'wl-highlight-summary-window))
777 ;; This hook may contain the function `wl-setup-summary' for reasons
778 ;; of system internal to accord facilities for the Emacs variants.
779 (run-hooks 'wl-summary-mode-hook))
781 (defun wl-summary-overview-entity-compare-by-date (x y)
782 "Compare entity X and Y by date."
785 (timezone-make-date-sortable
786 (elmo-msgdb-overview-entity-get-date x))
787 (timezone-make-date-sortable
788 (elmo-msgdb-overview-entity-get-date y)))
789 (error))) ;; ignore error.
791 (defun wl-summary-overview-entity-compare-by-number (x y)
792 "Compare entity X and Y by number."
794 (elmo-msgdb-overview-entity-get-number x)
795 (elmo-msgdb-overview-entity-get-number y)))
797 (defun wl-summary-overview-entity-compare-by-from (x y)
798 "Compare entity X and Y by from."
800 (wl-address-header-extract-address
801 (or (elmo-msgdb-overview-entity-get-from-no-decode x)
802 wl-summary-no-from-message))
803 (wl-address-header-extract-address
804 (or (elmo-msgdb-overview-entity-get-from-no-decode y)
805 wl-summary-no-from-message))))
807 (defun wl-summary-overview-entity-compare-by-subject (x y)
808 "Compare entity X and Y by subject."
809 (string< (elmo-msgdb-overview-entity-get-subject-no-decode x)
810 (elmo-msgdb-overview-entity-get-subject-no-decode y)))
812 (defun wl-summary-sort-by-date ()
814 (wl-summary-rescan "date"))
815 (defun wl-summary-sort-by-number ()
817 (wl-summary-rescan "number"))
818 (defun wl-summary-sort-by-subject ()
820 (wl-summary-rescan "subject"))
821 (defun wl-summary-sort-by-from ()
823 (wl-summary-rescan "from"))
825 (defun wl-summary-rescan (&optional sort-by)
826 "Rescan current folder without updating."
828 (let* ((cur-buf (current-buffer))
829 (msgdb (wl-summary-buffer-msgdb))
830 (overview (elmo-msgdb-get-overview msgdb))
831 (number-alist (elmo-msgdb-get-number-alist msgdb))
832 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
833 (elmo-mime-charset wl-summary-buffer-mime-charset)
837 (inhibit-read-only t)
838 (buffer-read-only nil)
840 (fset 'wl-summary-append-message-func-internal
841 (wl-summary-get-append-message-func))
842 (wl-summary-buffer-number-column-detect nil)
844 (message "Re-scanning...")
846 (setq num (length overview))
848 (message "Sorting by %s..." sort-by)
851 (intern (format "wl-summary-overview-entity-compare-by-%s"
853 (message "Sorting by %s...done" sort-by)
854 (elmo-msgdb-set-overview (wl-summary-buffer-msgdb)
858 (setq wl-thread-entity-hashtb (elmo-make-hash (* (length overview) 2)))
859 (setq wl-thread-entity-list nil)
860 (setq wl-thread-entities nil)
861 (setq wl-summary-buffer-number-list nil)
862 (setq wl-summary-buffer-target-mark-list nil)
863 (setq wl-summary-buffer-refile-list nil)
864 (setq wl-summary-buffer-delete-list nil)
865 (setq wl-summary-delayed-update nil)
866 (elmo-kill-buffer wl-summary-search-buf-name)
867 (message "Constructing summary structure...")
869 (setq entity (car curp))
870 (wl-summary-append-message-func-internal entity overview mark-alist
872 (setq curp (cdr curp))
873 (when (> num elmo-display-progress-threshold)
875 (if (or (zerop (% i 5)) (= i num))
876 (elmo-display-progress
877 'wl-summary-rescan "Constructing summary structure..."
878 (/ (* i 100) num)))))
879 (when wl-summary-delayed-update
880 (while wl-summary-delayed-update
881 (message "Parent (%d) of message %d is no entity"
882 (caar wl-summary-delayed-update)
883 (elmo-msgdb-overview-entity-get-number
884 (cdar wl-summary-delayed-update)))
885 (wl-summary-append-message-func-internal
886 (cdar wl-summary-delayed-update)
887 overview mark-alist nil t)
888 (setq wl-summary-delayed-update (cdr wl-summary-delayed-update))))
889 (message "Constructing summary structure...done")
891 (if (eq wl-summary-buffer-view 'thread)
893 (message "Inserting thread...")
894 (wl-thread-insert-top)
895 (message "Inserting thread...done"))
896 (wl-summary-make-number-list))
898 (setq wl-summary-scored nil)
899 (wl-summary-score-headers nil msgdb
900 (wl-summary-rescore-msgs number-alist)
902 (when (and wl-summary-scored
903 (setq expunged (wl-summary-score-update-all-lines)))
904 (message "%d message(s) are expunged by scoring." (length expunged))))
905 (wl-summary-set-message-modified)
906 (wl-summary-count-unread
907 (elmo-msgdb-get-mark-alist
908 (elmo-folder-msgdb wl-summary-buffer-elmo-folder)))
909 (wl-summary-update-modeline)
910 (goto-char (point-max))
912 (set-buffer-modified-p nil)))
914 (defun wl-summary-next-folder-or-exit (&optional next-entity upward)
918 (wl-summary-toggle-disp-msg 'off)
921 (wl-summary-goto-folder-subr next-entity
927 (wl-folder-set-current-entity-id (wl-folder-get-entity-id next-entity))
928 (if (and (eq retval 'more-next)
929 (memq wl-auto-select-next '(unread skip-no-unread))
930 (memq this-command wl-summary-next-no-unread-command))
933 t (eq wl-auto-select-next 'skip-no-unread))
934 (goto-char (point-max))
937 t (eq wl-auto-select-next 'skip-no-unread))))))
940 (defun wl-summary-entity-info-msg (entity finfo)
943 (elmo-replace-in-string
944 (if (memq 'ask-folder wl-use-folder-petname)
945 (wl-folder-get-petname entity)
948 (if (null (car finfo))
951 " (%d new/%d unread)"
957 (defun wl-summary-set-message-modified ()
958 (elmo-folder-set-message-modified-internal
959 wl-summary-buffer-elmo-folder t)
960 (setq wl-summary-buffer-message-modified t))
961 (defun wl-summary-message-modified-p ()
962 wl-summary-buffer-message-modified)
963 (defun wl-summary-set-mark-modified ()
964 (elmo-folder-set-mark-modified-internal
965 wl-summary-buffer-elmo-folder t)
966 (setq wl-summary-buffer-mark-modified t))
967 (defun wl-summary-mark-modified-p ()
968 wl-summary-buffer-mark-modified)
969 (defun wl-summary-set-thread-modified ()
970 (setq wl-summary-buffer-thread-modified t))
971 (defun wl-summary-thread-modified-p ()
972 wl-summary-buffer-thread-modified)
974 (defsubst wl-summary-cleanup-temp-marks (&optional sticky)
975 (if (or wl-summary-buffer-refile-list
976 wl-summary-buffer-copy-list
977 wl-summary-buffer-delete-list)
978 (if (y-or-n-p "Marks remain to be executed. Execute them? ")
981 (if (or wl-summary-buffer-refile-list
982 wl-summary-buffer-copy-list
983 wl-summary-buffer-delete-list)
984 (error "Some execution was failed")))
987 (wl-summary-delete-all-refile-marks)
988 (wl-summary-delete-all-copy-marks)
989 (wl-summary-delete-all-delete-marks)))
990 (if wl-summary-buffer-target-mark-list
992 (wl-summary-delete-all-target-marks)
993 (setq wl-summary-buffer-target-mark-list nil)))
994 (wl-summary-delete-all-temp-marks-on-buffer sticky)
995 (setq wl-summary-scored nil))
997 ;; a subroutine for wl-summary-exit/wl-save-status
998 ;; Note that folder is not commited here.
999 (defun wl-summary-save-view ()
1000 ;; already in summary buffer.
1001 (when wl-summary-buffer-persistent
1002 ;; save the current summary buffer view.
1003 (if (and wl-summary-cache-use
1004 (or (wl-summary-message-modified-p)
1005 (wl-summary-mark-modified-p)
1006 (wl-summary-thread-modified-p)))
1007 (wl-summary-save-view-cache))))
1009 (defun wl-summary-force-exit ()
1010 "Exit current summary. Buffer is deleted even the buffer is sticky."
1012 (wl-summary-exit 'force-exit))
1014 (defun wl-summary-exit (&optional force-exit)
1015 "Exit current summary. if FORCE-EXIT, exits even the summary is sticky."
1017 (let ((summary-buf (current-buffer))
1018 (sticky (wl-summary-sticky-p))
1020 message-buf message-win
1021 folder-buf folder-win)
1022 (run-hooks 'wl-summary-exit-pre-hook)
1023 (if wl-summary-buffer-exit-function
1024 (funcall wl-summary-buffer-exit-function)
1025 (wl-summary-cleanup-temp-marks sticky)
1027 ;; save summary status
1029 (wl-summary-save-view)
1030 (if (or force-exit (not sticky))
1031 (elmo-folder-close wl-summary-buffer-elmo-folder)
1032 (elmo-folder-commit wl-summary-buffer-elmo-folder)
1033 (elmo-folder-check wl-summary-buffer-elmo-folder))
1034 (if wl-use-scoring (wl-score-save)))
1035 ;; for sticky summary
1036 (wl-delete-all-overlays)
1037 (setq wl-summary-buffer-disp-msg nil)
1038 (elmo-kill-buffer wl-summary-search-buf-name)
1039 ;; delete message window if displayed.
1040 (if (and wl-message-buffer (get-buffer-window wl-message-buffer))
1041 (delete-window (get-buffer-window wl-message-buffer)))
1042 (if (and wl-summary-use-frame
1043 (> (length (visible-frame-list)) 1))
1045 (if (setq folder-buf (get-buffer wl-folder-buffer-name))
1046 (if wl-summary-use-frame
1048 (save-selected-window
1049 (dolist (frame (visible-frame-list))
1050 (select-frame frame)
1051 (if (get-buffer-window folder-buf)
1052 (setq select-frame frame))))
1054 (select-frame select-frame)
1055 (switch-to-buffer folder-buf)))
1056 (if (setq folder-win (get-buffer-window folder-buf))
1057 ;; folder win is already displayed.
1058 (select-window folder-win)
1059 ;; folder win is not displayed.
1060 (switch-to-buffer folder-buf)))
1061 ;; currently no folder buffer
1063 (and wl-folder-move-cur-folder
1064 wl-folder-buffer-cur-point
1065 (goto-char wl-folder-buffer-cur-point))
1066 (setq wl-folder-buffer-cur-path nil)
1067 (setq wl-folder-buffer-cur-entity-id nil)
1068 (wl-delete-all-overlays)
1069 (if wl-summary-exit-next-move
1070 (wl-folder-next-unsync t)
1071 (beginning-of-line))
1072 (if (setq summary-win (get-buffer-window summary-buf))
1073 (delete-window summary-win))
1077 (set-buffer summary-buf)
1078 (kill-buffer summary-buf)))
1079 (run-hooks 'wl-summary-exit-hook)))))
1081 (defun wl-summary-sync-force-update (&optional unset-cursor no-check)
1083 (wl-summary-sync-update unset-cursor nil no-check))
1085 (defsubst wl-summary-sync-all-init ()
1086 (wl-summary-cleanup-temp-marks)
1088 (wl-summary-set-message-modified)
1089 (wl-summary-set-mark-modified)
1090 (setq wl-thread-entity-hashtb (elmo-make-hash
1091 (* (length (elmo-msgdb-get-number-alist
1092 (wl-summary-buffer-msgdb))) 2)))
1093 (setq wl-thread-entity-list nil)
1094 (setq wl-thread-entities nil)
1095 (setq wl-summary-buffer-number-list nil)
1096 (setq wl-summary-buffer-target-mark-list nil)
1097 (setq wl-summary-buffer-refile-list nil)
1098 (setq wl-summary-buffer-copy-list nil)
1099 (setq wl-summary-buffer-delete-list nil)
1100 (wl-summary-buffer-number-column-detect nil))
1102 (defun wl-summary-sync (&optional unset-cursor force-range)
1104 (let* ((folder wl-summary-buffer-elmo-folder)
1105 (inhibit-read-only t)
1106 (buffer-read-only nil)
1107 (msgdb-dir (elmo-folder-msgdb-path folder))
1108 (range (or force-range (wl-summary-input-range
1109 (elmo-folder-name-internal folder)))))
1110 (cond ((string= range "rescan")
1111 (let ((msg (wl-summary-message-number)))
1113 (and msg (wl-summary-jump-to-msg msg))))
1114 ((string= range "rescan-noscore")
1115 (let ((msg (wl-summary-message-number))
1118 (and msg (wl-summary-jump-to-msg msg))))
1119 ((or (string-match "last:" range)
1120 (string-match "first:" range))
1121 (wl-summary-goto-folder-subr
1122 (wl-folder-get-elmo-folder (concat "/" range "/"
1123 (elmo-folder-name-internal
1125 'force-update nil nil t))
1127 (wl-summary-sync-update unset-cursor
1128 (cond ((string= range "all") 'all)
1129 ((string= range "all-visible")
1130 'visible-only)))))))
1132 (defvar wl-summary-edit-addresses-candidate-fields
1133 ;; First element becomes default.
1134 '("from" "to" "cc"))
1136 (defun wl-summary-edit-addresses-collect-candidate-fields (mime-charset)
1137 (let ((fields wl-summary-edit-addresses-candidate-fields)
1138 body candidates components)
1141 (mapconcat 'identity (elmo-multiple-field-body (car fields))
1143 (setq body (wl-parse-addresses body))
1144 (if body (setq candidates (append candidates body)))
1145 (setq fields (cdr fields)))
1146 (setq candidates (elmo-uniq-list candidates))
1148 (elmo-set-buffer-multibyte default-enable-multibyte-characters)
1151 (setq components (std11-extract-address-components x))
1152 (cons (nth 1 components)
1153 (and (car components)
1154 (eword-decode-string
1155 (decode-mime-charset-string
1160 (defun wl-summary-edit-addresses-subr (the-email name-in-addr)
1161 ;; returns nil if there's no change.
1162 (if (elmo-get-hash-val (downcase the-email) wl-address-petname-hash)
1164 (message (format "'%s' already exists. (e)dit/(d)elete/(c)ancel?"
1166 (while (not (or (eq (setq char (read-char)) ?\r)
1173 "Please answer `e' or `d' or `c'. (e)dit/(d)elete/(c)ancel?"))
1180 (wl-address-add-or-change
1182 (wl-address-header-extract-realname
1184 (let ((completion-ignore-case t) comp)
1186 (try-completion the-email wl-address-completion-list))
1187 (if (equal comp t) the-email comp))
1188 wl-address-completion-list))))
1192 (if (y-or-n-p (format "Delete '%s'? "
1195 (wl-address-delete the-email)
1202 (wl-address-add-or-change the-email name-in-addr)
1205 (defun wl-summary-edit-addresses (&optional addr-str)
1206 "Edit address book interactively.
1207 Optional argument ADDR-STR is used as a target address if specified."
1208 (interactive (if current-prefix-arg
1209 (list (read-from-minibuffer "Target address: "))))
1210 (if (null (wl-summary-message-number))
1211 (message "No message.")
1213 (let* ((charset wl-summary-buffer-mime-charset)
1215 (with-current-buffer (wl-summary-get-original-buffer)
1216 (wl-summary-edit-addresses-collect-candidate-fields
1218 address pair result)
1220 (setq address addr-str)
1222 (setq address (car (car candidates)))
1225 (format "Target address (%s): " address)
1227 (function (lambda (x) (cons (car x) (car x))))
1229 nil nil nil nil address))))
1231 (setq pair (assoc address candidates))
1233 (setq pair (cons address nil)))
1234 (when (setq result (wl-summary-edit-addresses-subr (car pair) (cdr pair)))
1237 (setq address (assoc (car pair) wl-address-list))
1239 (message "%s, %s, <%s> is %s."
1244 ;;; i'd like to update summary-buffer, but...
1245 ;;; (wl-summary-rescan)
1246 (run-hooks 'wl-summary-edit-addresses-hook))))))
1248 (defun wl-summary-incorporate (&optional arg)
1249 "Check and prefetch all uncached messages.
1250 If ARG is non-nil, checking is omitted."
1254 (wl-summary-sync-force-update)))
1255 (wl-summary-prefetch-region (point-min) (point-max)
1256 wl-summary-incorporate-marks))
1258 (defun wl-summary-prefetch-msg (number &optional arg)
1259 "Returns status-mark. if skipped, returns nil."
1260 ;; prefetching procedure.
1262 (let* ((msgdb (wl-summary-buffer-msgdb))
1263 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1264 (number-alist (elmo-msgdb-get-number-alist msgdb))
1265 (message-id (cdr (assq number number-alist)))
1266 (ov (elmo-msgdb-overview-get-entity message-id msgdb))
1268 (size (elmo-msgdb-overview-entity-get-size ov))
1269 (inhibit-read-only t)
1270 (buffer-read-only nil)
1271 (force-read (and size
1272 (or (null wl-prefetch-threshold)
1273 (< size wl-prefetch-threshold))))
1276 (null (elmo-file-cache-exists-p message-id)))
1279 (when (and size (not force-read) wl-prefetch-confirm)
1285 "Message from %s has %d bytes. Prefetch it? "
1289 (wl-set-string-width
1290 wl-summary-from-width
1291 (wl-summary-from-func-internal
1292 (eword-decode-string
1296 (elmo-msgdb-overview-entity-get-from ov)
1299 (message "")) ; flush.
1300 (setq mark (cadr (assq number mark-alist)))
1305 (elmo-message-encache
1306 wl-summary-buffer-elmo-folder
1311 wl-summary-unread-uncached-mark)
1312 wl-summary-unread-cached-mark)
1313 ((string= mark wl-summary-new-mark)
1314 (setq wl-summary-buffer-new-count
1315 (- wl-summary-buffer-new-count 1))
1316 (setq wl-summary-buffer-unread-count
1317 (+ wl-summary-buffer-unread-count 1))
1318 wl-summary-unread-cached-mark)
1319 ((string= mark wl-summary-read-uncached-mark)
1322 (setq mark-alist (elmo-msgdb-mark-set
1323 mark-alist number new-mark))
1324 (or new-mark (setq new-mark " "))
1325 (elmo-msgdb-set-mark-alist msgdb mark-alist)
1326 (wl-summary-set-mark-modified)
1327 (wl-summary-update-modeline)
1328 (wl-folder-update-unread
1329 (wl-summary-buffer-folder-name)
1330 (+ wl-summary-buffer-unread-count
1331 wl-summary-buffer-new-count)))
1334 ;;(defvar wl-summary-message-uncached-marks
1335 ;; (list wl-summary-new-mark
1336 ;; wl-summary-unread-uncached-mark
1337 ;; wl-summary-read-uncached-mark))
1339 (defun wl-summary-prefetch-region (beg end &optional prefetch-marks)
1347 (setq start-pos (point))
1349 (narrow-to-region beg end)
1350 ;; collect prefetch targets.
1351 (message "Collecting marks...")
1352 (goto-char (point-min))
1355 (when (looking-at "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9]\\)")
1356 (setq mark (wl-match-buffer 2))
1357 (setq msg (string-to-int (wl-match-buffer 1)))
1358 (if (or (and (null prefetch-marks)
1360 (null (elmo-file-cache-exists-p
1362 (elmo-msgdb-get-number-alist
1363 (wl-summary-buffer-msgdb)))))))
1364 (member mark prefetch-marks))
1365 (setq targets (nconc targets (list msg))))
1366 (setq entity (wl-thread-get-entity msg))
1367 (if (or (not (eq wl-summary-buffer-view 'thread))
1368 (wl-thread-entity-get-opened entity))
1369 (); opened. no hidden children.
1370 ;; hidden children!!
1371 (setq targets (nconc
1373 (wl-thread-get-children-msgs-uncached
1374 msg prefetch-marks)))))
1376 (setq length (length targets))
1377 (message "Prefetching...")
1379 (setq mark (if (not (wl-thread-entity-parent-invisible-p
1380 (wl-thread-get-entity (car targets))))
1382 (wl-summary-jump-to-msg (car targets))
1383 (wl-summary-prefetch))
1384 (wl-summary-prefetch-msg (car targets))))
1385 (if (if prefetch-marks
1386 (string= mark wl-summary-unread-cached-mark)
1387 (or (string= mark wl-summary-unread-cached-mark)
1388 (string= mark " ")))
1389 (message "Prefetching... %d/%d message(s)"
1390 (setq count (+ 1 count)) length))
1394 (goto-char start-pos)
1395 (if (pos-visible-in-window-p pos)
1399 (setq targets (cdr targets)))
1400 (message "Prefetched %d/%d message(s)" count length)
1401 (cons count length)))))
1403 (defun wl-summary-prefetch (&optional arg)
1404 "Prefetch current message."
1409 (when (looking-at "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9]\\)")
1410 (goto-char (match-beginning 2))
1411 (let ((inhibit-read-only t)
1412 (buffer-read-only nil)
1413 (beg (match-beginning 2))
1416 (setq mark (wl-summary-prefetch-msg
1417 (string-to-int (wl-match-buffer 1)) arg))
1419 (delete-region beg end)
1421 (if wl-summary-highlight
1422 (wl-highlight-summary-current-line)))
1423 (set-buffer-modified-p nil)
1426 (defun wl-summary-delete-all-status-marks-on-buffer ()
1429 (goto-char (point-min))
1430 (let ((inhibit-read-only t)
1431 (buffer-read-only nil)
1432 (case-fold-search nil))
1433 (while (re-search-forward
1434 (concat "^" wl-summary-buffer-number-regexp ".\\(.\\)") nil t)
1435 (delete-region (match-beginning 1) (match-end 1))
1438 (defun wl-summary-delete-marks-on-buffer (marks)
1440 (wl-summary-unmark (pop marks))))
1442 (defun wl-summary-delete-copy-marks-on-buffer (copies)
1443 (wl-summary-delete-marks-on-buffer copies))
1445 (defun wl-summary-delete-all-refile-marks ()
1446 (let ((marks wl-summary-buffer-refile-list))
1448 (wl-summary-unmark (car (pop marks))))))
1450 (defun wl-summary-delete-all-copy-marks ()
1451 (let ((marks wl-summary-buffer-copy-list))
1453 (wl-summary-unmark (car (pop marks))))))
1455 (defun wl-summary-delete-all-delete-marks ()
1456 (wl-summary-delete-marks-on-buffer wl-summary-buffer-delete-list))
1458 (defun wl-summary-delete-all-target-marks ()
1459 (wl-summary-delete-marks-on-buffer wl-summary-buffer-target-mark-list))
1461 (defun wl-summary-delete-all-temp-marks-on-buffer (&optional sticky)
1462 ;; for summary view cache saving.
1465 (goto-char (point-min))
1466 (let ((inhibit-read-only t)
1467 (buffer-read-only nil)
1468 (case-fold-search nil)
1469 (regexp (concat "^" wl-summary-buffer-number-regexp "\\([^ ]\\)" )))
1470 (while (re-search-forward regexp nil t)
1471 (delete-region (match-beginning 1) (match-end 1))
1473 (if (and sticky wl-summary-highlight)
1474 (wl-highlight-summary-current-line))))))
1476 (defun wl-summary-delete-all-marks (mark-alist mark)
1477 "Delete all MARKs in MARK-ALIST."
1478 (let ((malist mark-alist)
1479 (ret-val mark-alist)
1482 (setq entity (car malist))
1483 (if (string= (cadr entity) mark)
1484 ;; delete this entity
1485 (setq ret-val (delete entity ret-val)))
1486 (setq malist (cdr malist)))
1489 ;; Does not work correctly...
1490 (defun wl-summary-mark-as-read-region (beg end)
1494 (narrow-to-region beg end)
1496 ;;; (save-excursion (goto-char end)
1497 ;;; (end-of-line) (point)))
1498 (goto-char (point-min))
1499 (if (eq wl-summary-buffer-view 'thread)
1502 (let* ((number (wl-summary-message-number))
1503 (entity (wl-thread-get-entity number))
1505 (if (wl-thread-entity-get-opened entity)
1506 ;; opened...mark line.
1507 ;; Crossposts are not processed
1508 (wl-summary-mark-as-read t)
1510 (wl-summary-mark-as-read t) ; mark itself.
1511 (setq children (wl-thread-get-children-msgs number))
1513 (wl-summary-mark-as-read t nil nil (car children))
1514 (setq children (cdr children))))
1517 (wl-summary-mark-as-read t)
1518 (forward-line 1)))))
1519 (wl-summary-count-unread (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
1520 (wl-summary-update-modeline))
1522 (defun wl-summary-mark-as-unread-region (beg end)
1526 (narrow-to-region beg end)
1528 ;;; (save-excursion (goto-char end)
1529 ;;; (end-of-line) (point)))
1530 (goto-char (point-min))
1531 (if (eq wl-summary-buffer-view 'thread)
1534 (let* ((number (wl-summary-message-number))
1535 (entity (wl-thread-get-entity number))
1537 (if (wl-thread-entity-get-opened entity)
1538 ;; opened...mark line.
1539 ;; Crossposts are not processed
1540 (wl-summary-mark-as-unread)
1542 (wl-summary-mark-as-unread) ; mark itself.
1544 (delq number (wl-thread-get-children-msgs number)))
1546 (wl-summary-mark-as-unread (car children))
1547 (setq children (cdr children))))
1550 (wl-summary-mark-as-unread)
1551 (forward-line 1)))))
1552 (wl-summary-count-unread (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
1553 (wl-summary-update-modeline))
1555 (defun wl-summary-mark-as-important-region (beg end)
1559 (narrow-to-region beg end);(save-excursion (goto-char end)
1560 ; (end-of-line) (point)))
1561 (goto-char (point-min))
1562 (if (eq wl-summary-buffer-view 'thread)
1565 (let* ((number (wl-summary-message-number))
1566 (entity (wl-thread-get-entity number))
1568 (if (wl-thread-entity-get-opened entity)
1569 ;; opened...mark line.
1570 ;; Crossposts are not processed
1571 (wl-summary-mark-as-important)
1573 (wl-summary-mark-as-important) ; mark itself.
1575 (delq number (wl-thread-get-children-msgs number)))
1577 (wl-thread-msg-mark-as-important (car children))
1578 (setq children (cdr children))))
1581 (wl-summary-mark-as-important)
1582 (forward-line 1)))))
1583 (wl-summary-count-unread (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
1584 (wl-summary-update-modeline))
1586 (defun wl-summary-mark-as-read-all ()
1588 (if (or (not (interactive-p))
1589 (y-or-n-p "Mark all messages as read? "))
1590 (let* ((folder wl-summary-buffer-elmo-folder)
1591 (cur-buf (current-buffer))
1592 (msgdb (wl-summary-buffer-msgdb))
1593 ;;; (number-alist (elmo-msgdb-get-number-alist msgdb))
1594 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1596 (inhibit-read-only t)
1597 (buffer-read-only nil)
1598 (case-fold-search nil)
1600 (message "Setting all msgs as read...")
1601 (elmo-folder-mark-as-read folder
1602 (elmo-folder-list-unreads
1604 (list wl-summary-unread-cached-mark
1605 wl-summary-unread-uncached-mark
1606 wl-summary-new-mark)))
1608 (goto-char (point-min))
1609 (while (re-search-forward "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9 ]\\)" nil t)
1610 (setq msg (string-to-int (wl-match-buffer 1)))
1611 (setq mark (wl-match-buffer 2))
1612 (when (and (not (string= mark wl-summary-important-mark))
1613 (not (string= mark wl-summary-read-uncached-mark)))
1614 (delete-region (match-beginning 2) (match-end 2))
1615 (if (or (not (elmo-message-use-cache-p folder msg))
1616 (string= mark wl-summary-unread-cached-mark))
1620 (elmo-msgdb-mark-set
1623 ;;; Use msg instead of (cdr (assq msg number-alist)).
1624 ;;; (cdr (assq msg number-alist))
1626 ;; New mark and unread-uncached mark
1627 (insert wl-summary-read-uncached-mark)
1629 (elmo-msgdb-mark-set mark-alist
1631 ;;; (cdr (assq msg number-alist))
1632 wl-summary-read-uncached-mark)))
1633 (if wl-summary-highlight
1634 (wl-highlight-summary-current-line nil nil t)))))
1635 (setq mark-alist (wl-summary-set-as-read-mark-alist mark-alist))
1636 (wl-summary-set-mark-modified)
1637 (set-buffer cur-buf); why is this needed???
1638 (elmo-msgdb-set-mark-alist msgdb mark-alist)
1639 (wl-folder-update-unread (wl-summary-buffer-folder-name) 0)
1640 (setq wl-summary-buffer-unread-count 0)
1641 (setq wl-summary-buffer-new-count 0)
1642 (wl-summary-update-modeline)
1643 (message "Setting all msgs as read...done")
1644 (set-buffer-modified-p nil))))
1646 (defun wl-summary-delete-cache ()
1647 "Delete cache of current message."
1650 (let* ((inhibit-read-only t)
1651 (buffer-read-only nil)
1652 (folder wl-summary-buffer-elmo-folder)
1653 (msgdb (wl-summary-buffer-msgdb))
1654 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1655 (number-alist (elmo-msgdb-get-number-alist msgdb))
1656 (case-fold-search nil)
1657 mark number unread new-mark)
1658 ;;; (re-search-backward "^ *[0-9]+..[0-9]+/[0-9]+" nil t) ; set cursor line
1660 (when (looking-at "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9]\\)")
1662 (setq mark (wl-match-buffer 2))
1664 ((or (string= mark wl-summary-new-mark)
1665 (string= mark wl-summary-unread-uncached-mark)
1666 (string= mark wl-summary-important-mark))
1669 ((string= mark wl-summary-unread-cached-mark)
1670 (setq new-mark wl-summary-unread-uncached-mark))
1672 (setq new-mark wl-summary-read-uncached-mark)))
1674 (setq number (string-to-int (wl-match-buffer 1)))
1675 (delete-region (match-beginning 2) (match-end 2))
1676 (goto-char (match-beginning 2))
1678 (elmo-file-cache-delete
1679 (elmo-file-cache-get-path
1680 (elmo-message-field wl-summary-buffer-elmo-folder
1684 (elmo-msgdb-mark-set mark-alist number new-mark))
1685 (elmo-msgdb-set-mark-alist msgdb mark-alist)
1686 (wl-summary-set-mark-modified)
1687 (if wl-summary-highlight
1688 (wl-highlight-summary-current-line nil nil t))
1689 (set-buffer-modified-p nil)))))))
1691 (defun wl-summary-resume-cache-status ()
1692 "Resume the cache status of all messages in the current folder."
1694 (let* ((folder wl-summary-buffer-elmo-folder)
1695 (cur-buf (current-buffer))
1696 (msgdb (wl-summary-buffer-msgdb))
1697 (number-alist (elmo-msgdb-get-number-alist msgdb))
1698 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1699 (inhibit-read-only t)
1700 (buffer-read-only nil)
1701 (case-fold-search nil)
1702 msg mark msgid set-mark)
1703 (message "Resuming cache status...")
1705 (goto-char (point-min))
1706 (while (re-search-forward "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9]\\)" nil t)
1707 (setq msg (string-to-int
1708 (wl-match-buffer 1)))
1709 (setq mark (wl-match-buffer 2))
1710 (setq msgid (cdr (assq msg number-alist)))
1712 (if (elmo-file-cache-exists-p msgid)
1714 (string= mark wl-summary-unread-uncached-mark) ; U -> !
1715 (string= mark wl-summary-new-mark) ; N -> !
1717 (setq set-mark wl-summary-unread-cached-mark)
1718 (if (string= mark wl-summary-read-uncached-mark) ; u -> ' '
1719 (setq set-mark " ")))
1720 (if (string= mark " ")
1721 (setq set-mark wl-summary-read-uncached-mark) ;' ' -> u
1722 (if (string= mark wl-summary-unread-cached-mark)
1723 (setq set-mark wl-summary-unread-uncached-mark) ; ! -> U
1726 (delete-region (match-beginning 2) (match-end 2))
1729 (elmo-msgdb-mark-set
1730 mark-alist msg ; msgid
1731 (if (string= set-mark " ") nil set-mark)))
1732 (if wl-summary-highlight
1733 (wl-highlight-summary-current-line))))
1734 (wl-summary-set-mark-modified)
1735 (set-buffer cur-buf); why is this needed???
1736 (elmo-msgdb-set-mark-alist msgdb mark-alist)
1737 (wl-summary-count-unread mark-alist)
1738 (wl-summary-update-modeline)
1739 (message "Resuming cache status...done")
1740 (set-buffer-modified-p nil))))
1742 (defun wl-summary-resume-marks-and-highlight ()
1743 (let* ((msgdb (wl-summary-buffer-msgdb))
1744 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1745 ;;; (number-alist (elmo-msgdb-get-number-alist msgdb))
1746 (count (count-lines (point-min)(point-max)))
1748 msg-num percent smark)
1750 (goto-char (point-min))
1751 (message "Resuming all marks...")
1753 (setq msg-num (wl-summary-message-number))
1754 (setq smark (car (cdr (assq msg-num mark-alist))))
1755 (if (looking-at (format "^ *%s \\( \\)" msg-num))
1757 (goto-char (match-end 1))
1758 (delete-region (match-beginning 1) (match-end 1))
1759 (insert (or smark " "))))
1760 (wl-highlight-summary-current-line smark)
1761 (when (> count elmo-display-progress-threshold)
1763 (setq percent (/ (* i 100) count))
1764 (elmo-display-progress
1765 'wl-summary-resume-marks-and-highlight "Resuming all marks..."
1768 (message "Resuming all marks...done")))
1770 (defun wl-summary-resume-marks ()
1771 (let* ((msgdb (wl-summary-buffer-msgdb))
1772 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
1773 (number-alist (elmo-msgdb-get-number-alist msgdb))
1774 (count (length mark-alist))
1776 entity msg-num percent)
1778 (message "Resuming all marks...")
1780 (setq entity (car mark-alist))
1781 (if (setq msg-num (car (rassoc (car entity) number-alist)))
1783 ;;; (goto-char (point-min))
1784 (if (re-search-forward (format "^ *%s \\( \\)" msg-num) nil t)
1786 (delete-region (match-beginning 1) (match-end 1))
1787 (insert (or (cadr entity)
1789 (if (re-search-backward (format "^ *%s \\( \\)" msg-num) nil t)
1791 (goto-char (match-end 1))
1792 (delete-region (match-beginning 1) (match-end 1))
1793 (insert (or (cadr entity)
1795 (when (> count elmo-display-progress-threshold)
1797 (setq percent (/ (* i 100) count))
1798 (elmo-display-progress
1799 'wl-summary-resume-marks "Resuming all marks..."
1801 (setq mark-alist (cdr mark-alist)))
1802 (message "Resuming all marks...done"))))
1804 (defun wl-summary-delete-messages-on-buffer (msgs &optional deleting-info)
1807 (let ((inhibit-read-only t)
1808 (buffer-read-only nil)
1813 (elmo-kill-buffer wl-summary-search-buf-name)
1815 (if (eq wl-summary-buffer-view 'thread)
1817 ;; don't use wl-append(nconc), because list is broken. ...why?
1820 (wl-thread-delete-message (car msgs))))
1821 (setq update-list (delq (car msgs) update-list)))
1822 (goto-char (point-min))
1823 (if (re-search-forward (format "^ *%d[^0-9]\\([^0-9]\\).*$"
1826 (delete-region (match-beginning 0) (match-end 0))
1827 (delete-char 1) ; delete '\n'
1828 (setq wl-summary-buffer-number-list
1829 (delq (car msgs) wl-summary-buffer-number-list)))))
1830 (when (and deleting-info
1831 (> len elmo-display-progress-threshold))
1833 (if (or (zerop (% i 5)) (= i len))
1834 (elmo-display-progress
1835 'wl-summary-delete-messages-on-buffer deleting-info
1836 (/ (* i 100) len))))
1837 (setq msgs (cdr msgs)))
1838 (when (eq wl-summary-buffer-view 'thread)
1839 (wl-thread-update-line-msgs (elmo-uniq-list update-list)
1840 (unless deleting-info 'no-msg))
1841 (wl-thread-cleanup-symbols msgs2))
1842 (wl-summary-count-unread
1843 (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
1844 (wl-summary-update-modeline)
1845 (wl-folder-update-unread
1846 (wl-summary-buffer-folder-name)
1847 (+ wl-summary-buffer-unread-count wl-summary-buffer-new-count)))))
1849 (defun wl-summary-set-as-read-mark-alist (mark-alist)
1850 (let ((marks (list (cons wl-summary-unread-cached-mark
1852 (cons wl-summary-unread-uncached-mark
1853 wl-summary-read-uncached-mark)
1854 (cons wl-summary-new-mark
1855 wl-summary-read-uncached-mark)))
1856 (ret-val mark-alist)
1859 (setq entity (car mark-alist))
1860 (when (setq pair (assoc (cadr entity) marks))
1861 (if (elmo-message-use-cache-p wl-summary-buffer-elmo-folder
1864 (setcar (cdr entity) (cdr pair))
1865 (setq ret-val (delete entity ret-val)))
1866 (setq ret-val (delete entity ret-val))))
1867 (setq mark-alist (cdr mark-alist)))
1870 (defun wl-summary-set-status-marks (mark-alist before after)
1871 "Set the BEFORE marks to AFTER."
1872 (let ((ret-val mark-alist)
1875 (setq entity (car mark-alist))
1876 (when (string= (cadr entity) before)
1878 (setcar (cdr entity) after)
1879 (setq ret-val (delete entity ret-val))))
1880 (setq mark-alist (cdr mark-alist)))
1883 (defun wl-summary-set-status-marks-on-buffer (before after)
1884 "Set the MARKS marks on buffer."
1887 (goto-char (point-min))
1888 (let ((inhibit-read-only t)
1889 (buffer-read-only nil)
1890 (regexp (concat "^" wl-summary-buffer-number-regexp ".\\(\\%s\\)")))
1891 (while (re-search-forward
1892 (format regexp (regexp-quote before)) nil t)
1893 (delete-region (match-beginning 1) (match-end 1))
1895 (if wl-summary-highlight
1896 (wl-highlight-summary-current-line))))))
1898 (defun wl-summary-get-delete-folder (folder)
1899 (if (string= folder wl-trash-folder)
1901 (let* ((type (or (wl-get-assoc-list-value wl-delete-folder-alist folder)
1903 (cond ((stringp type)
1905 ((or (equal type 'remove) (equal type 'null))
1907 (t;; (equal type 'trash)
1908 wl-trash-folder)))))
1910 (defun wl-summary-delete-important-msgs-from-list (delete-list
1912 (let ((dlist delete-list))
1914 (if (string= wl-summary-important-mark
1915 (car (cdr (assq (car dlist) mark-alist))))
1916 (setq delete-list (delete (car dlist) delete-list)))
1917 (setq dlist (cdr dlist)))
1920 (defun wl-summary-delete-canceled-msgs-from-list (delete-list msgdb)
1921 (let ((dlist delete-list))
1923 (if (null (cdr (assq (car dlist) (cadr msgdb))))
1924 (setq delete-list (delete (car dlist) delete-list)))
1925 (setq dlist (cdr dlist)))
1928 (defun wl-summary-get-append-message-func ()
1929 (if (eq wl-summary-buffer-view 'thread)
1930 'wl-summary-insert-thread-entity
1931 ;;; 'wl-summary-insert-thread
1932 'wl-summary-insert-summary))
1934 (defun wl-summary-sort ()
1936 (let ((sort-by (let ((input-range-list '("number" "date" "subject" "from"))
1941 (format "Sort by (%s): " default)
1943 (function (lambda (x) (cons x x)))
1948 (if (not (member sort-by '("number" "date" "subject" "from")))
1949 (error "Sort by %s is not implemented" sort-by))
1950 (wl-summary-rescan sort-by)))
1952 (defun wl-summary-sync-marks ()
1953 "Update marks in summary."
1955 (let ((last-progress 0)
1957 mark-alist unread-marks importants unreads
1958 importants-in-db unreads-in-db diff diffs
1959 mes num-ma progress)
1960 ;; synchronize marks.
1961 (when (not (eq (elmo-folder-type-internal
1962 wl-summary-buffer-elmo-folder)
1964 (message "Updating marks...")
1965 (setq unread-marks (list wl-summary-unread-cached-mark
1966 wl-summary-unread-uncached-mark
1967 wl-summary-new-mark)
1968 mark-alist (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb))
1969 num-ma (length mark-alist)
1970 importants (elmo-folder-list-importants
1971 wl-summary-buffer-elmo-folder
1972 wl-summary-important-mark)
1973 unreads (elmo-folder-list-unreads
1974 wl-summary-buffer-elmo-folder
1977 (if (string= (cadr (car mark-alist))
1978 wl-summary-important-mark)
1979 (setq importants-in-db (cons (car (car mark-alist))
1981 (if (member (cadr (car mark-alist)) unread-marks)
1982 (setq unreads-in-db (cons (car (car mark-alist))
1984 (setq mark-alist (cdr mark-alist))
1985 (when (> num-ma elmo-display-progress-threshold)
1987 progress (/ (* i 100) num-ma))
1988 (if (not (eq progress last-progress))
1989 (elmo-display-progress 'wl-summary-sync-marks
1992 (setq last-progress progress)))
1993 (setq diff (elmo-list-diff importants importants-in-db))
1994 (setq diffs (cadr diff)) ; important-deletes
1995 (setq mes (format "Updated (-%d" (length diffs)))
1997 (wl-summary-mark-as-important (car diffs)
1998 wl-summary-important-mark
2000 (setq diffs (cdr diffs)))
2001 (setq diffs (car diff)) ; important-appends
2002 (setq mes (concat mes (format "/+%d) important," (length diffs))))
2004 (wl-summary-mark-as-important (car diffs) " " 'no-server)
2005 (setq diffs (cdr diffs)))
2006 (setq diff (elmo-list-diff unreads unreads-in-db))
2007 (setq diffs (cadr diff))
2008 (setq mes (concat mes (format "(-%d" (length diffs))))
2010 (wl-summary-mark-as-read t 'no-server nil (car diffs))
2011 (setq diffs (cdr diffs)))
2012 (setq diffs (car diff)) ; unread-appends
2013 (setq mes (concat mes (format "/+%d) unread mark(s)." (length diffs))))
2015 (wl-summary-mark-as-unread (car diffs) 'no-server 'no-modeline)
2016 (setq diffs (cdr diffs)))
2017 (if (interactive-p) (message mes)))))
2019 (defun wl-summary-sync-update (&optional unset-cursor sync-all no-check)
2020 "Update the summary view to the newest folder status."
2022 (let* ((folder wl-summary-buffer-elmo-folder)
2023 (case-fold-search nil)
2024 (elmo-mime-charset wl-summary-buffer-mime-charset)
2025 (inhibit-read-only t)
2026 (buffer-read-only nil)
2028 overview number-alist mark-alist
2029 curp num i new-msgdb
2030 append-list delete-list crossed
2031 update-thread update-top-list
2032 expunged mes sync-result)
2035 (unless wl-summary-buffer-elmo-folder
2036 (error "(Internal error) Folder is not set:%s" (buffer-name
2038 (fset 'wl-summary-append-message-func-internal
2039 (wl-summary-get-append-message-func))
2040 ;; Flush pending append operations (disconnected operation).
2042 ;;(wl-summary-flush-pending-append-operations seen-list))
2043 (goto-char (point-max))
2044 (wl-folder-confirm-existence folder 'force)
2045 (setq sync-result (elmo-folder-synchronize
2048 wl-summary-unread-uncached-mark
2049 wl-summary-unread-cached-mark
2050 wl-summary-read-uncached-mark
2051 wl-summary-important-mark
2053 (setq new-msgdb (nth 0 sync-result))
2054 (setq delete-list (nth 1 sync-result))
2055 (setq crossed (nth 2 sync-result))
2059 (if sync-all (wl-summary-sync-all-init))
2061 ; (elmo-nntp-max-number-precedes-list-active-p))
2062 ;; XXX this does not work correctly in rare case.
2064 ; (wl-summary-delete-canceled-msgs-from-list
2066 ; (wl-summary-buffer-msgdb))))
2068 (wl-summary-delete-messages-on-buffer delete-list "Deleting...")
2069 (message "Deleting...done"))
2071 (wl-summary-set-status-marks-on-buffer
2073 wl-summary-unread-uncached-mark))
2074 (setq append-list (elmo-msgdb-get-overview new-msgdb))
2075 (setq curp append-list)
2076 (setq num (length curp))
2079 ;; set these value for append-message-func
2080 (setq overview (elmo-msgdb-get-overview
2081 (elmo-folder-msgdb folder)))
2082 (setq number-alist (elmo-msgdb-get-number-alist
2083 (elmo-folder-msgdb folder)))
2084 (setq mark-alist (elmo-msgdb-get-mark-alist
2085 (elmo-folder-msgdb folder)))
2086 (setq wl-summary-delayed-update nil)
2087 (elmo-kill-buffer wl-summary-search-buf-name)
2089 (setq entity (car curp))
2090 (when (setq update-thread
2091 (wl-summary-append-message-func-internal
2092 entity overview mark-alist
2094 (wl-append update-top-list update-thread))
2095 (if elmo-use-database
2096 (elmo-database-msgid-put
2097 (car entity) (elmo-folder-name-internal folder)
2098 (elmo-msgdb-overview-entity-get-number entity)))
2099 (setq curp (cdr curp))
2100 (when (> num elmo-display-progress-threshold)
2102 (if (or (zerop (% i 5)) (= i num))
2103 (elmo-display-progress
2104 'wl-summary-sync-update "Updating thread..."
2105 (/ (* i 100) num)))))
2106 (when wl-summary-delayed-update
2107 (while wl-summary-delayed-update
2108 (message "Parent (%d) of message %d is no entity"
2109 (caar wl-summary-delayed-update)
2110 (elmo-msgdb-overview-entity-get-number
2111 (cdar wl-summary-delayed-update)))
2112 (when (setq update-thread
2113 (wl-summary-append-message-func-internal
2114 (cdar wl-summary-delayed-update)
2115 overview mark-alist (not sync-all) t))
2116 (wl-append update-top-list update-thread))
2117 (setq wl-summary-delayed-update
2118 (cdr wl-summary-delayed-update))))
2119 (when (and (eq wl-summary-buffer-view 'thread)
2121 (wl-thread-update-indent-string-thread
2122 (elmo-uniq-list update-top-list)))
2123 (message "Updating thread...done"))
2124 (unless (eq wl-summary-buffer-view 'thread)
2125 (wl-summary-make-number-list))
2126 (wl-summary-set-message-modified)
2127 (wl-summary-set-mark-modified)
2128 (when (and sync-all (eq wl-summary-buffer-view 'thread))
2129 (elmo-kill-buffer wl-summary-search-buf-name)
2130 (message "Inserting thread...")
2131 (setq wl-thread-entity-cur 0)
2132 (wl-thread-insert-top)
2133 (message "Inserting thread...done"))
2134 (if elmo-use-database
2135 (elmo-database-close))
2136 (run-hooks 'wl-summary-sync-updated-hook)
2138 (if (and (eq (length delete-list) 0)
2141 "No updates for \"%s\"" (elmo-folder-name-internal
2143 (format "Updated (-%d/+%d) message(s)"
2144 (length delete-list) num))))
2145 (setq mes "Quit updating.")))
2146 ;; synchronize marks.
2147 (if (and wl-summary-auto-sync-marks sync-result)
2148 (wl-summary-sync-marks))
2150 (when wl-use-scoring
2151 (setq wl-summary-scored nil)
2152 (wl-summary-score-headers nil (wl-summary-buffer-msgdb)
2154 (wl-summary-rescore-msgs number-alist))
2156 (when (and wl-summary-scored
2157 (setq expunged (wl-summary-score-update-all-lines)))
2158 (setq mes (concat mes
2159 (format " (%d expunged)"
2160 (length expunged))))))
2161 (if (and crossed (> crossed 0))
2165 (format " (%d crosspost)" crossed))
2166 (format "%d crosspost message(s)" crossed)))
2167 (and mes (setq mes (concat mes "."))))
2168 ;; Update Folder mode
2169 (wl-folder-set-folder-updated
2170 (elmo-folder-name-internal folder)
2172 (wl-summary-count-unread
2173 (elmo-msgdb-get-mark-alist
2174 (elmo-folder-msgdb folder)))
2175 (elmo-folder-messages folder)))
2176 (wl-summary-update-modeline)
2177 (wl-summary-buffer-number-column-detect t)
2179 (unless unset-cursor
2180 (goto-char (point-min))
2181 (if (not (wl-summary-cursor-down t))
2183 (goto-char (point-max))
2185 (if (and wl-summary-highlight
2186 (not (get-text-property (point) 'face)))
2190 wl-summary-partial-highlight-above-lines
2191 wl-summary-highlight-partial-threshold)))
2192 (wl-highlight-summary (point) (point-max))))))
2193 (setq wl-summary-buffer-msgdb (elmo-folder-msgdb folder))
2194 (wl-delete-all-overlays)
2195 (set-buffer-modified-p nil)
2196 (if mes (message "%s" mes)))))
2198 (defun wl-summary-set-score-mark (mark)
2201 (let ((inhibit-read-only t)
2202 (buffer-read-only nil)
2205 (when (looking-at "^ *\\(-?[0-9]+\\)\\([^0-9]\\)")
2206 (setq msg-num (string-to-int (wl-match-buffer 1)))
2207 (setq cur-mark (wl-match-buffer 2))
2208 (when (member cur-mark (list " "
2209 wl-summary-score-below-mark
2210 wl-summary-score-over-mark))
2211 (goto-char (match-end 1))
2212 (delete-region (match-beginning 2) (match-end 2))
2214 (if wl-summary-highlight
2215 (wl-highlight-summary-current-line nil nil t))
2216 (set-buffer-modified-p nil))))))
2218 (defun wl-summary-get-score-mark (msg-num)
2219 (let ((score (cdr (assq msg-num wl-summary-scored))))
2221 (cond ((< score wl-summary-default-score)
2223 ((> score wl-summary-default-score)
2226 (defun wl-summary-update-modeline ()
2227 (setq wl-summary-buffer-unread-status
2228 (format " {%s}(%d new/%d unread)"
2229 (if (eq wl-summary-buffer-view 'thread)
2231 wl-summary-buffer-new-count
2232 (+ wl-summary-buffer-new-count
2233 wl-summary-buffer-unread-count))))
2235 (defsubst wl-summary-jump-to-msg (&optional number)
2237 (let ((num (or number
2239 (read-from-minibuffer "Jump to Message(No.): ")))))
2240 (setq num (int-to-string num))
2242 (if (or (re-search-forward (concat "^[ \t]*" num "[^0-9]") nil t)
2243 (re-search-backward (concat "^[ \t]*" num "[^0-9]") nil t))
2244 (progn (beginning-of-line) t)
2247 (defun wl-summary-highlight-msgs (msgs)
2249 (let ((len (length msgs))
2251 (message "Hilighting...")
2254 (if (wl-summary-jump-to-msg (car msgs))
2255 (wl-highlight-summary-current-line))
2256 (setq msgs (cdr msgs))
2257 (when (> len elmo-display-progress-threshold)
2259 (if (or (zerop (% i 5)) (= i len))
2260 (elmo-display-progress
2261 'wl-summary-highlight-msgs "Highlighting..."
2262 (/ (* i 100) len)))))
2263 (message "Highlighting...done"))))
2265 (defun wl-summary-message-number ()
2268 (if (looking-at "^ *\\(-?[0-9]+\\)")
2269 (string-to-int (wl-match-buffer 1))
2272 (defun wl-summary-move (src dsts-msgs)
2273 (let* ((dsts (car dsts-msgs)) ; (+foo +bar)
2274 ;;; (msgs (cdr dsts-msgs)) ; (1 2 3)
2275 ;;; (msgdb (wl-summary-buffer-msgdb))
2279 (setq dsts (cdr dsts)))))
2281 (defun wl-summary-delete-all-msgs ()
2283 (let ((cur-buf (current-buffer))
2284 (dels (elmo-folder-list-messages wl-summary-buffer-elmo-folder)))
2285 (set-buffer cur-buf)
2287 (message "No message to delete.")
2288 (if (y-or-n-p (format "%s has %d message(s). Delete all? "
2289 (wl-summary-buffer-folder-name)
2292 (message "Deleting...")
2293 (elmo-folder-delete-messages
2294 wl-summary-buffer-elmo-folder dels)
2295 (elmo-msgdb-delete-msgs (wl-summary-buffer-msgdb)
2297 ;;; (elmo-msgdb-save (wl-summary-buffer-folder-name) nil)
2298 (wl-summary-set-message-modified)
2299 (wl-summary-set-mark-modified)
2300 (wl-folder-set-folder-updated (wl-summary-buffer-folder-name)
2303 ;;; (setq wl-thread-top-entity '(nil t nil nil))
2304 (setq wl-summary-buffer-unread-count 0)
2305 (setq wl-summary-buffer-new-count 0)
2306 (wl-summary-update-modeline)
2307 (set-buffer cur-buf)
2308 (let ((inhibit-read-only t)
2309 (buffer-read-only nil))
2311 ;;; (if wl-summary-cache-use (wl-summary-save-view-cache))
2312 (message "Deleting...done")
2316 (defun wl-summary-toggle-thread (&optional arg)
2317 "Toggle thread status (T)hread and (S)equential.
2318 If ARG, without confirm."
2321 (y-or-n-p (format "Toggle threading? (y=%s): "
2322 (if (eq wl-summary-buffer-view 'thread)
2323 "\"off\"" "\"on\""))))
2324 (if (eq wl-summary-buffer-view 'thread)
2325 (setq wl-summary-buffer-view 'sequence)
2326 (setq wl-summary-buffer-view 'thread))
2327 (wl-summary-update-modeline)
2328 (force-mode-line-update)
2329 (wl-summary-rescan)))
2331 (defun wl-summary-load-file-object (filename)
2332 "Load lisp object from dir."
2334 (let ((tmp-buffer (get-buffer-create " *wl-summary-load-file-object*"))
2335 insert-file-contents-pre-hook ; To avoid autoconv-xmas...
2336 insert-file-contents-post-hook
2338 (if (not (file-readable-p filename))
2340 (set-buffer tmp-buffer)
2341 (as-binary-input-file (insert-file-contents filename))
2344 (read (current-buffer))
2345 (error (error "Reading failed")))))
2346 (kill-buffer tmp-buffer)
2349 (defun wl-summary-goto-folder (&optional arg)
2351 (wl-summary-goto-folder-subr nil nil nil arg t))
2353 (defun wl-summary-goto-last-visited-folder ()
2356 (wl-folder-search-entity-by-name wl-summary-last-visited-folder
2359 (if entity (wl-folder-set-current-entity-id
2360 (wl-folder-get-entity-id entity))))
2361 (wl-summary-goto-folder-subr wl-summary-last-visited-folder nil nil nil t))
2363 (defun wl-summary-sticky-p (&optional folder)
2365 (get-buffer (wl-summary-sticky-buffer-name
2366 (elmo-folder-name-internal folder)))
2367 (not (string= wl-summary-buffer-name (buffer-name)))))
2369 (defun wl-summary-always-sticky-folder-p (folder)
2370 (or (eq t wl-summary-always-sticky-folder-list)
2371 (wl-string-match-member
2372 (elmo-folder-name-internal folder)
2373 wl-summary-always-sticky-folder-list)))
2375 (defun wl-summary-stick (&optional force)
2376 "Make current summary buffer sticky."
2378 (if (wl-summary-sticky-p)
2379 (message "Current summary buffer is already sticky.")
2380 (when (or force (y-or-n-p "Stick current summary buffer? "))
2381 (wl-summary-toggle-disp-msg 'off)
2382 (wl-summary-switch-to-clone-buffer
2383 (wl-summary-sticky-buffer-name
2384 (wl-summary-buffer-folder-name)))
2386 ;;; (rename-buffer (wl-summary-sticky-buffer-name
2387 ;;; (wl-summary-buffer-folder-name))))
2388 (message "Folder `%s' is now sticky." (wl-summary-buffer-folder-name)))))
2390 (defun wl-summary-switch-to-clone-buffer (buffer-name)
2391 (let ((cur-buf (current-buffer))
2392 (msg (wl-summary-message-number))
2393 (buf (get-buffer-create buffer-name))
2394 (folder wl-summary-buffer-elmo-folder)
2396 (append '(wl-summary-buffer-view
2397 wl-summary-buffer-refile-list
2398 wl-summary-buffer-delete-list
2399 wl-summary-buffer-copy-list
2400 wl-summary-buffer-target-mark-list
2401 wl-summary-buffer-elmo-folder
2402 wl-summary-buffer-number-column
2403 wl-summary-buffer-number-regexp
2404 wl-summary-buffer-message-modified
2405 wl-summary-buffer-mark-modified
2406 wl-summary-buffer-thread-modified
2407 wl-summary-buffer-number-list
2408 wl-summary-buffer-msgdb
2409 wl-summary-buffer-folder-name)
2410 (and (eq wl-summary-buffer-view 'thread)
2411 '(wl-thread-entity-hashtb
2413 wl-thread-entity-list))
2416 wl-summary-default-score
2417 wl-summary-important-above
2418 wl-summary-target-above
2419 wl-summary-mark-below
2420 wl-summary-expunge-below))
2421 (and (featurep 'wl-score)
2422 '(wl-current-score-file
2426 (wl-summary-buffer-set-folder folder)
2427 (let ((buffer-read-only nil))
2428 (insert-buffer cur-buf))
2429 (set-buffer-modified-p nil)
2430 (while copy-variables
2431 (set (car copy-variables)
2433 (set-buffer cur-buf)
2434 (symbol-value (car copy-variables))))
2435 (setq copy-variables (cdr copy-variables)))
2436 (switch-to-buffer buf)
2437 (kill-buffer cur-buf)
2438 (wl-summary-count-unread
2439 (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
2440 (wl-summary-update-modeline)
2442 (if (eq wl-summary-buffer-view 'thread)
2443 (wl-thread-jump-to-msg msg)
2444 (wl-summary-jump-to-msg msg))
2445 (goto-char (point-max))
2446 (beginning-of-line))))
2448 (defun wl-summary-get-buffer (folder)
2450 (get-buffer (wl-summary-sticky-buffer-name folder)))
2451 (get-buffer wl-summary-buffer-name)))
2453 (defun wl-summary-get-buffer-create (name &optional force-sticky)
2456 (wl-summary-sticky-buffer-name name))
2457 (or (get-buffer (wl-summary-sticky-buffer-name name))
2458 (get-buffer-create wl-summary-buffer-name))))
2460 (defun wl-summary-make-number-list ()
2461 (setq wl-summary-buffer-number-list
2463 (lambda (x) (elmo-msgdb-overview-entity-get-number x))
2464 (elmo-msgdb-get-overview (wl-summary-buffer-msgdb)))))
2466 (defun wl-summary-auto-select-msg-p (unread-msg)
2469 (cadr (assoc unread-msg
2470 (elmo-msgdb-get-mark-alist
2471 (wl-summary-buffer-msgdb))))
2472 wl-summary-important-mark))))
2474 (defsubst wl-summary-open-folder (folder)
2476 (let ((elmo-mime-charset wl-summary-buffer-mime-charset))
2478 (elmo-folder-open folder 'load-msgdb)
2479 ;; For compatibility
2480 (setq wl-summary-buffer-msgdb (elmo-folder-msgdb folder))
2481 (setq wl-summary-buffer-folder-name (elmo-folder-name-internal
2484 (defun wl-summary-goto-folder-subr (&optional name scan-type other-window
2485 sticky interactive scoring)
2486 "Display target folder on summary."
2488 (let* ((keep-cursor (memq this-command
2489 wl-summary-keep-cursor-command))
2490 (name (or name (wl-summary-read-folder wl-default-folder)))
2491 (cur-fld wl-summary-buffer-elmo-folder)
2492 folder buf mes hilit reuse-buf
2494 (if (string= name "")
2495 (setq name wl-default-folder))
2496 (setq folder (wl-folder-get-elmo-folder name))
2497 (when (and (not (string=
2498 (and cur-fld (elmo-folder-name-internal cur-fld))
2499 (elmo-folder-name-internal folder))) ; folder is moved.
2500 (eq major-mode 'wl-summary-mode)) ; called in summary.
2501 (setq wl-summary-last-visited-folder (wl-summary-buffer-folder-name))
2502 (run-hooks 'wl-summary-exit-pre-hook)
2503 (wl-summary-cleanup-temp-marks (wl-summary-sticky-p))
2504 (wl-summary-save-view)
2505 (elmo-folder-commit wl-summary-buffer-elmo-folder))
2506 (setq buf (wl-summary-get-buffer-create (elmo-folder-name-internal folder)
2511 (string= (elmo-folder-name-internal folder)
2512 (wl-summary-buffer-folder-name))))
2516 (switch-to-buffer buf)
2519 (delete-other-windows))
2521 (unless (eq major-mode 'wl-summary-mode)
2523 (wl-summary-buffer-set-folder folder)
2524 (setq wl-summary-buffer-disp-msg nil)
2525 (setq wl-summary-buffer-last-displayed-msg nil)
2526 (setq wl-summary-buffer-current-msg nil)
2527 (let ((case-fold-search nil)
2528 (inhibit-read-only t)
2529 (buffer-read-only nil))
2531 ;; Resume summary view
2532 (if wl-summary-cache-use
2533 (let* ((dir (elmo-folder-msgdb-path folder))
2534 (cache (expand-file-name wl-summary-cache-file dir))
2535 (view (expand-file-name wl-summary-view-file dir)))
2536 (when (file-exists-p cache)
2537 (insert-file-contents-as-binary cache)
2538 (elmo-set-buffer-multibyte
2539 default-enable-multibyte-characters)
2540 (decode-mime-charset-region
2541 (point-min)(point-max)
2542 wl-summary-buffer-mime-charset))
2543 (when (file-exists-p view)
2544 (setq wl-summary-buffer-view
2545 (wl-summary-load-file-object view)))
2546 (wl-thread-resume-entity folder)
2547 (wl-summary-open-folder folder))
2548 (setq wl-summary-buffer-view
2549 (wl-summary-load-file-object
2550 (expand-file-name wl-summary-view-file
2551 (elmo-folder-msgdb-path folder))))
2552 (wl-summary-open-folder folder)
2553 (wl-summary-rescan))
2554 (wl-summary-count-unread
2555 (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
2556 (wl-summary-update-modeline)))
2557 (unless (eq wl-summary-buffer-view 'thread)
2558 (wl-summary-make-number-list))
2559 (wl-summary-buffer-number-column-detect t)
2560 (wl-summary-toggle-disp-msg (if wl-summary-buffer-disp-msg 'on 'off))
2561 (unless (and reuse-buf keep-cursor)
2562 ;(setq hilit wl-summary-highlight)
2564 (let ((wl-summary-highlight (if reuse-buf wl-summary-highlight))
2566 (if (or scoring interactive) wl-use-scoring)))
2567 (if (and (not scan-type)
2570 (setq scan-type (wl-summary-get-sync-range folder)))
2573 (wl-summary-sync 'unset-cursor))
2574 ((eq scan-type 'all)
2575 (wl-summary-sync 'unset-cursor "all"))
2576 ((eq scan-type 'no-sync))
2577 ((or (eq scan-type 'force-update)
2578 (eq scan-type 'update))
2579 (setq mes (wl-summary-sync-force-update
2580 'unset-cursor 'no-check)))))
2582 (switch-to-buffer buf)
2584 ;; stick always-sticky-folder
2585 (when (wl-summary-always-sticky-folder-p folder)
2586 (or (wl-summary-sticky-p) (wl-summary-stick t)))
2587 (run-hooks 'wl-summary-prepared-pre-hook)
2588 (set-buffer-modified-p nil)
2589 (goto-char (point-min))
2590 (if (wl-summary-cursor-down t)
2591 (let ((unreadp (wl-summary-next-message
2592 (wl-summary-message-number)
2594 (cond ((and wl-auto-select-first
2595 (wl-summary-auto-select-msg-p unreadp))
2596 ;; wl-auto-select-first is non-nil and
2597 ;; unreadp is non-nil but not important
2598 (setq retval 'disp-msg))
2599 ((not (wl-summary-auto-select-msg-p unreadp))
2600 ;; unreadp is nil or important
2601 (setq retval 'more-next))))
2602 (goto-char (point-max))
2603 (if (elmo-folder-plugged-p folder)
2606 (setq retval 'more-next))
2607 ;(setq wl-summary-highlight hilit)
2608 (if (and wl-summary-highlight
2609 (not wl-summary-lazy-highlight)
2611 (if (and wl-summary-highlight-partial-threshold
2612 (> (count-lines (point-min) (point-max))
2613 wl-summary-highlight-partial-threshold))
2618 wl-summary-partial-highlight-above-lines
2619 wl-summary-highlight-partial-threshold)))
2620 (wl-highlight-summary (point) (point-max)))
2621 (wl-highlight-summary (point-min) (point-max))))
2622 (if (eq retval 'disp-msg)
2623 (wl-summary-redisplay))
2624 (if mes (message "%s" mes))
2625 (if (and interactive wl-summary-recenter)
2626 (recenter (/ (- (window-height) 2) 2))))))
2627 ;; set current entity-id
2628 (if (and (not folder)
2630 (wl-folder-search-entity-by-name (elmo-folder-name-internal
2634 ;; entity-id is unknown.
2635 (wl-folder-set-current-entity-id
2636 (wl-folder-get-entity-id entity)))
2638 (run-hooks 'wl-summary-prepared-hook)
2639 (set-buffer-modified-p nil))
2642 (defun wl-summary-summary-line-already-exists-p (parent-number buffer)
2645 (goto-char (point-max))
2647 (when (re-search-backward (format "^ *%s..../..\(.*\)..:.. "
2648 parent-number) nil t)
2649 (goto-char (match-end 0))
2650 (while (string-match wl-thread-indent-regexp
2652 (char-after (point))))
2653 (setq depth (+ 1 depth))
2655 (/ depth wl-thread-indent-level-internal))))
2657 (defun wl-summary-goto-bottom-of-current-thread ()
2658 (if (re-search-forward (concat "^" wl-summary-buffer-number-regexp
2659 "..../..\(.*\)..:.. [[<]") nil t)
2661 (goto-char (point-max))))
2663 (defun wl-summary-goto-top-of-current-thread ()
2664 (wl-summary-jump-to-msg
2665 (wl-thread-entity-get-number
2666 (wl-thread-entity-get-top-entity (wl-thread-get-entity
2667 (wl-summary-message-number))))))
2669 (defun wl-summary-goto-bottom-of-sub-thread (&optional depth)
2671 (let ((depth (or depth
2672 (wl-thread-get-depth-of-current-line))))
2674 (while (and (not (eobp))
2675 (>= (wl-thread-get-depth-of-current-line)
2678 (beginning-of-line)))
2680 (defun wl-summary-insert-line (line)
2681 "Insert LINE in the Summary."
2682 (if wl-use-highlight-mouse-line
2683 ;; remove 'mouse-face of current line.
2685 (save-excursion (beginning-of-line)(point))
2686 (save-excursion (end-of-line)(point))
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))
2695 (condition-case nil ; it's dangerous, so ignore error.
2696 (run-hooks 'wl-summary-line-inserted-hook)
2698 (message "Error in wl-summary-line-inserted-hook"))))
2700 (defun wl-summary-insert-summary (entity database mark-alist dummy &optional dumm)
2701 (let ((overview-entity entity)
2703 (setq msg (elmo-msgdb-overview-entity-get-number entity))
2704 (when (setq summary-line
2705 (wl-summary-overview-create-summary-line
2706 msg entity nil 0 mark-alist))
2707 (let ((inhibit-read-only t)
2709 (goto-char (point-max))
2710 (wl-summary-insert-line summary-line)))))
2712 (defun wl-summary-default-subject-filter (subject)
2713 (let ((case-fold-search t))
2714 (setq subject (elmo-replace-in-string subject "[ \t]*\\(re\\|was\\)[:>]" ""))
2715 (setq subject (elmo-replace-in-string subject "[ \t]" ""))
2716 (elmo-replace-in-string subject "^\\[.*\\]" "")))
2718 (defun wl-summary-subject-equal (subject1 subject2)
2719 (string= (wl-summary-subject-filter-func-internal subject1)
2720 (wl-summary-subject-filter-func-internal subject2)))
2722 (defmacro wl-summary-put-alike (alike)
2723 (` (elmo-set-hash-val (format "#%d" (wl-count-lines))
2725 wl-summary-alike-hashtb)))
2727 (defmacro wl-summary-get-alike ()
2728 (` (elmo-get-hash-val (format "#%d" (wl-count-lines))
2729 wl-summary-alike-hashtb)))
2731 (defun wl-summary-insert-headers (overview func mime-decode)
2732 (let (ov this last alike)
2733 (buffer-disable-undo (current-buffer))
2734 (make-local-variable 'wl-summary-alike-hashtb)
2735 (setq wl-summary-alike-hashtb (elmo-make-hash (* (length overview) 2)))
2737 (elmo-set-buffer-multibyte default-enable-multibyte-characters))
2738 (while (setq ov (pop overview))
2739 (setq this (funcall func ov))
2740 (and this (setq this (std11-unfold-string this)))
2741 (if (equal last this)
2742 (wl-append alike (list ov))
2744 (wl-summary-put-alike alike)
2746 (setq alike (list ov)
2749 (wl-summary-put-alike alike)
2752 (decode-mime-charset-region (point-min) (point-max)
2754 (when (eq mime-decode 'mime)
2755 (eword-decode-region (point-min) (point-max))))
2756 (run-hooks 'wl-summary-insert-headers-hook)))
2758 (defun wl-summary-search-by-subject (entity overview)
2759 (let ((summary-buf (current-buffer))
2760 (buf (get-buffer-create wl-summary-search-buf-name))
2761 (folder-name (wl-summary-buffer-folder-name))
2762 match founds found-entity)
2763 (with-current-buffer buf
2764 (let ((case-fold-search t))
2765 (when (or (not (string= wl-summary-search-buf-folder-name folder-name))
2766 (zerop (buffer-size)))
2767 (setq wl-summary-search-buf-folder-name folder-name)
2768 (wl-summary-insert-headers
2772 (wl-summary-subject-filter-func-internal
2773 (elmo-msgdb-overview-entity-get-subject-no-decode x))))
2775 (setq match (wl-summary-subject-filter-func-internal
2776 (elmo-msgdb-overview-entity-get-subject entity)))
2777 (if (string= match "")
2779 (goto-char (point-min))
2780 (while (and (not founds)
2781 (not (= (point) (point-max)))
2782 (search-forward match nil t))
2783 ;; check exactly match
2786 (match-beginning 0)))
2787 (setq found-entity (wl-summary-get-alike))
2788 (if (and found-entity
2789 ;; Is founded entity myself or children?
2791 (elmo-msgdb-overview-entity-get-id entity)
2792 (elmo-msgdb-overview-entity-get-id
2793 (car found-entity))))
2794 (with-current-buffer summary-buf
2795 (not (wl-thread-descendant-p
2796 (elmo-msgdb-overview-entity-get-number entity)
2797 (elmo-msgdb-overview-entity-get-number
2798 (car found-entity))))))
2799 ;; return matching entity
2800 (setq founds found-entity))))
2804 (defun wl-summary-insert-thread-entity (entity overview mark-alist update
2805 &optional force-insert)
2806 (let (update-list entity-stack)
2808 (let* ((this-id (elmo-msgdb-overview-entity-get-id entity))
2810 (elmo-msgdb-overview-get-parent-entity entity overview));; temp
2811 ;;; (parent-id (elmo-msgdb-overview-entity-get-id parent-entity))
2812 (parent-number (elmo-msgdb-overview-entity-get-number parent-entity))
2813 (case-fold-search t)
2814 msg overview2 cur-entity linked retval delayed-entity)
2815 (setq msg (elmo-msgdb-overview-entity-get-number entity))
2816 (if (and parent-number
2817 (not (wl-thread-get-entity parent-number))
2819 ;; parent is exists in overview, but not exists in wl-thread-entities
2821 (wl-append wl-summary-delayed-update
2822 (list (cons parent-number entity)))
2823 (setq entity nil)) ;; exit loop
2824 ;; Search parent by subject.
2825 (when (and (null parent-number)
2826 wl-summary-search-parent-by-subject-regexp
2828 wl-summary-search-parent-by-subject-regexp
2829 (elmo-msgdb-overview-entity-get-subject entity)))
2830 (let ((found (wl-summary-search-by-subject entity overview)))
2832 (not (member found wl-summary-delayed-update)))
2833 (setq parent-entity found)
2835 (elmo-msgdb-overview-entity-get-number parent-entity))
2837 ;; If subject is change, divide thread.
2838 (if (and parent-number
2839 wl-summary-divide-thread-when-subject-changed
2840 (not (wl-summary-subject-equal
2841 (or (elmo-msgdb-overview-entity-get-subject
2843 (or (elmo-msgdb-overview-entity-get-subject
2844 parent-entity) ""))))
2845 (setq parent-number nil))
2848 (wl-thread-insert-message entity overview mark-alist
2849 msg parent-number update linked))
2851 (wl-append update-list (list retval)))
2852 (setq entity nil) ; exit loop
2853 (while (setq delayed-entity (assq msg wl-summary-delayed-update))
2854 (setq wl-summary-delayed-update
2855 (delete delayed-entity wl-summary-delayed-update))
2856 ;; update delayed message
2857 (wl-append entity-stack (list (cdr delayed-entity)))))
2858 (if (and (not entity)
2860 (setq entity (pop entity-stack)))))
2863 (defun wl-summary-update-thread (entity
2869 (this-id (elmo-msgdb-overview-entity-get-id entity))
2870 (overview-entity entity)
2871 (parent-id (elmo-msgdb-overview-entity-get-id parent-entity))
2872 (parent-number (elmo-msgdb-overview-entity-get-number parent-entity))
2873 summary-line msg subject-differ)
2875 ((or (not parent-id)
2876 (string= this-id parent-id))
2877 (goto-char (point-max))
2878 (beginning-of-line))
2879 ;; parent already exists in buffer.
2880 ((setq depth (or (wl-summary-summary-line-already-exists-p
2881 parent-number (current-buffer)) -1))
2882 (setq depth (+ 1 depth))
2883 (wl-thread-goto-bottom-of-sub-thread)))
2884 (if (and (setq msg (elmo-msgdb-overview-entity-get-number entity)))
2885 (if (setq summary-line
2886 (wl-summary-overview-create-summary-line
2887 msg entity parent-entity depth mark-alist
2888 (wl-thread-maybe-get-children-num msg)
2890 (let ((inhibit-read-only t)
2891 (buffer-read-only nil))
2892 (wl-summary-insert-line summary-line))))))
2894 (defun wl-summary-mark-as-unread (&optional number
2900 (inhibit-read-only t)
2901 (buffer-read-only nil)
2902 (folder wl-summary-buffer-elmo-folder)
2903 (msgdb (wl-summary-buffer-msgdb))
2904 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
2905 ;;; (number-alist (elmo-msgdb-get-number-alist msgdb))
2906 new-mark visible mark)
2909 (setq visible (wl-summary-jump-to-msg number))
2910 (unless (setq mark (cadr (assq number mark-alist)))
2915 (if (null (wl-summary-message-number))
2916 (message "No message.")
2919 (re-search-backward (concat "^" wl-summary-buffer-number-regexp
2920 "..../..")) ; set cursor line
2921 (beginning-of-line)))
2922 (if (or (and (not visible)
2923 ;; already exists in msgdb.
2924 (assq number (elmo-msgdb-get-number-alist msgdb)))
2926 (format (concat "^ *\\("
2927 (if number (int-to-string number)
2929 "\\)[^0-9]\\(%s\\|%s\\)")
2930 wl-summary-read-uncached-mark
2933 (setq number (or number (string-to-int (wl-match-buffer 1))))
2934 (setq mark (or mark (elmo-match-buffer 2)))
2936 (setq new-mark (if (string= mark
2937 wl-summary-read-uncached-mark)
2938 wl-summary-unread-uncached-mark
2939 (if (elmo-message-use-cache-p folder number)
2940 wl-summary-unread-mark
2941 wl-summary-unread-uncached-mark))))
2943 (unless no-server-update
2945 (unless (elmo-folder-unmark-read folder (list number))
2946 (error "Setting mark failed"))))
2948 (delete-region (match-beginning 2) (match-end 2))
2951 (elmo-msgdb-mark-set mark-alist
2954 (elmo-msgdb-set-mark-alist msgdb mark-alist)
2955 (unless no-modeline-update
2956 (setq wl-summary-buffer-unread-count
2957 (+ 1 wl-summary-buffer-unread-count))
2958 (wl-summary-update-modeline)
2959 (wl-folder-update-unread
2960 (wl-summary-buffer-folder-name)
2961 (+ wl-summary-buffer-unread-count
2962 wl-summary-buffer-new-count)))
2963 (wl-summary-set-mark-modified)
2964 (if (and visible wl-summary-highlight)
2965 (wl-highlight-summary-current-line))))))
2966 (set-buffer-modified-p nil))
2968 (defun wl-summary-delete (&optional number)
2969 "Mark Delete mark 'D'.
2970 If optional argument NUMBER is specified, mark message specified by NUMBER."
2972 (let* ((buffer-num (wl-summary-message-number))
2973 (msg-num (or number buffer-num))
2976 (when (null msg-num)
2978 (message "No message."))
2980 (when (setq mark (wl-summary-get-mark msg-num))
2981 (when (wl-summary-reserve-temp-mark-p mark)
2983 (error "Already marked as `%s'" mark))
2985 (wl-summary-unmark msg-num))
2986 (if (or (interactive-p)
2987 (eq number buffer-num))
2988 (wl-summary-mark-line "D"))
2989 (setq wl-summary-buffer-delete-list
2990 (cons msg-num wl-summary-buffer-delete-list))
2992 (if (eq wl-summary-move-direction-downward nil)
2997 (defun wl-summary-remove-destination ()
2999 (let ((inhibit-read-only t)
3000 (buffer-read-only nil)
3001 (buf (current-buffer))
3007 (setq rs (next-single-property-change sol 'wl-summary-destination
3009 (setq re (next-single-property-change rs 'wl-summary-destination
3011 (put-text-property rs re 'wl-summary-destination nil)
3012 (put-text-property rs re 'invisible nil)
3014 (delete-char (- eol re)))))
3016 (defun wl-summary-check-mark (msg mark)
3017 (let ((check-func (cond ((string= mark "o")
3018 'wl-summary-msg-marked-as-refiled)
3020 'wl-summary-msg-marked-as-copied)
3022 'wl-summary-msg-marked-as-deleted)
3024 'wl-summary-msg-marked-as-target))))
3026 (funcall check-func msg))))
3028 (defun wl-summary-mark-collect (mark &optional begin end)
3032 (narrow-to-region (or begin (point-min))
3033 (or end (point-max)))
3034 (goto-char (point-min))
3036 (if (eq wl-summary-buffer-view 'thread)
3039 (let* ((number (wl-summary-message-number))
3040 (entity (wl-thread-get-entity number))
3042 ;; opened...only myself is checked.
3043 (if (wl-summary-check-mark number mark)
3044 (wl-append msglist (list number)))
3045 (unless (wl-thread-entity-get-opened entity)
3046 ;; closed...children is also checked.
3047 (if (setq result (wl-thread-get-children-msgs-with-mark
3050 (wl-append msglist result)))
3052 (elmo-uniq-list msglist))
3053 (let* ((case-fold-search nil)
3054 (re (format (concat wl-summary-message-regexp "%s")
3055 (regexp-quote mark))))
3056 (while (re-search-forward re nil t)
3057 (setq msglist (cons (wl-summary-message-number) msglist)))
3058 (nreverse msglist)))))))
3060 (defun wl-summary-exec ()
3062 (wl-summary-exec-subr (mapcar 'car wl-summary-buffer-refile-list)
3063 (reverse wl-summary-buffer-delete-list)
3064 (mapcar 'car wl-summary-buffer-copy-list)))
3066 (defun wl-summary-exec-region (beg end)
3068 (message "Collecting marks ...")
3073 (goto-char (1- end))
3076 (wl-summary-exec-subr (wl-summary-mark-collect "o" beg end)
3077 (wl-summary-mark-collect "D" beg end)
3078 (wl-summary-mark-collect "O" beg end))))
3080 (defun wl-summary-exec-subr (moves dels copies)
3081 (if (not (or moves dels copies))
3082 (message "No marks")
3084 (let ((del-fld (wl-summary-get-delete-folder
3085 (wl-summary-buffer-folder-name)))
3087 (unread-marks (list wl-summary-unread-cached-mark
3088 wl-summary-unread-uncached-mark
3089 wl-summary-new-mark))
3090 (refiles (append moves dels))
3093 (copy-len (length copies))
3095 dst-msgs ; loop counter
3097 (message "Executing ...")
3099 (when (not (assq (car dels) wl-summary-buffer-refile-list))
3100 (wl-append wl-summary-buffer-refile-list
3101 (list (cons (car dels) del-fld)))
3102 (setq wl-summary-buffer-delete-list
3103 (delete (car dels) wl-summary-buffer-delete-list)))
3104 (setq dels (cdr dels)))
3106 (setq refile-len (length refiles))
3108 (wl-inverse-alist refiles wl-summary-buffer-refile-list))
3109 (goto-char start) ; avoid moving cursor to
3111 (when (> refile-len elmo-display-progress-threshold)
3112 (elmo-progress-set 'elmo-folder-move-messages
3113 refile-len "Moving messages..."))
3117 (setq result (elmo-folder-move-messages
3118 wl-summary-buffer-elmo-folder
3119 (cdr (car dst-msgs))
3120 (if (eq 'null (car (car dst-msgs)))
3122 (wl-folder-get-elmo-folder
3123 (car (car dst-msgs))))
3124 (wl-summary-buffer-msgdb)
3125 (not (null (cdr dst-msgs)))
3131 (if result ; succeeded.
3134 (wl-summary-delete-messages-on-buffer (cdr (car dst-msgs)))
3135 ;; update refile-alist.
3136 (setq wl-summary-buffer-refile-list
3137 (wl-delete-associations (cdr (car dst-msgs))
3138 wl-summary-buffer-refile-list)))
3139 (setq refile-failures
3140 (+ refile-failures (length (cdr (car dst-msgs))))))
3141 (setq dst-msgs (cdr dst-msgs)))
3142 (elmo-progress-clear 'elmo-folder-move-messages)
3145 (setq dst-msgs (wl-inverse-alist copies wl-summary-buffer-copy-list))
3146 (when (> copy-len elmo-display-progress-threshold)
3147 (elmo-progress-set 'elmo-folder-move-messages
3148 copy-len "Copying messages..."))
3152 (setq result (elmo-folder-move-messages
3153 wl-summary-buffer-elmo-folder
3154 (cdr (car dst-msgs))
3155 (wl-folder-get-elmo-folder
3156 (car (car dst-msgs)))
3157 (wl-summary-buffer-msgdb)
3158 (not (null (cdr dst-msgs)))
3159 t ; t is no-delete (copy)
3164 (if result ; succeeded.
3167 (wl-summary-delete-copy-marks-on-buffer (cdr (car dst-msgs)))
3168 ;; update copy-alist
3169 (setq wl-summary-buffer-copy-list
3170 (wl-delete-associations (cdr (car dst-msgs))
3171 wl-summary-buffer-copy-list)))
3173 (+ copy-failures (length (cdr (car dst-msgs))))))
3174 (setq dst-msgs (cdr dst-msgs)))
3175 ;; Hide progress bar.
3176 (elmo-progress-clear 'elmo-folder-move-messages)
3178 (wl-summary-folder-info-update)
3179 (wl-summary-set-message-modified)
3180 (wl-summary-set-mark-modified)
3181 (run-hooks 'wl-summary-exec-hook)
3182 (unless (and wl-message-buffer
3183 (eq (wl-summary-message-number)
3184 (with-current-buffer wl-message-buffer
3185 wl-message-buffer-cur-number)))
3186 (wl-summary-toggle-disp-msg 'off))
3187 (set-buffer-modified-p nil)
3188 (message (concat "Executing ... done"
3189 (if (> refile-failures 0)
3190 (format " (%d refiling failed)" refile-failures)
3192 (if (> copy-failures 0)
3193 (format " (%d copying failed)" copy-failures)
3197 (defun wl-summary-read-folder (default &optional purpose ignore-error
3199 (let ((fld (completing-read
3200 (format "Folder name %s(%s): " (or purpose "")
3202 (or wl-folder-completion-function
3203 (if (memq 'read-folder wl-use-folder-petname)
3204 (wl-folder-get-entity-with-petname)
3205 wl-folder-entity-hashtb))
3206 nil nil (or init wl-default-spec)
3207 'wl-read-folder-hist)))
3208 (if (or (string= fld wl-default-spec)
3211 (setq fld (elmo-string (wl-folder-get-realname fld)))
3212 (if (string-match "\n" fld)
3213 (error "Not supported folder name: %s" fld))
3217 (wl-folder-confirm-existence
3218 (wl-folder-get-elmo-folder
3221 (wl-folder-confirm-existence (wl-folder-get-elmo-folder
3225 (defun wl-summary-print-destination (msg-num folder)
3226 "Print refile destination on line."
3227 (wl-summary-remove-destination)
3228 (let ((inhibit-read-only t)
3229 (folder (copy-sequence folder))
3230 (buffer-read-only nil)
3232 (setq len (string-width folder))
3239 (setq c (+ c (char-width (following-char)))))
3240 (and (> c len) (setq folder (concat " " folder)))
3242 (put-text-property rs re 'invisible t)
3243 (put-text-property rs re 'wl-summary-destination t)
3245 (wl-highlight-refile-destination-string folder)
3247 (set-buffer-modified-p nil))))
3249 (defsubst wl-summary-get-mark (number)
3250 "Return a temporal mark of message specified by NUMBER."
3251 (or (and (memq number wl-summary-buffer-delete-list) "D")
3252 (and (assq number wl-summary-buffer-copy-list) "O")
3253 (and (assq number wl-summary-buffer-refile-list) "o")
3254 (and (memq number wl-summary-buffer-target-mark-list) "*")))
3256 (defsubst wl-summary-reserve-temp-mark-p (mark)
3257 "Return t if temporal MARK should be reserved."
3258 (member mark wl-summary-reserve-mark-list))
3260 (defun wl-summary-refile (&optional dst number)
3261 "Put refile mark on current line message.
3262 If optional argument DST is specified, put mark without asking
3264 If optional argument NUMBER is specified, mark message specified by NUMBER.
3266 If folder is read-only, message should be copied.
3267 See `wl-refile-policy-alist' for more details."
3269 (let ((policy (wl-get-assoc-list-value wl-refile-policy-alist
3270 (wl-summary-buffer-folder-name))))
3271 (cond ((eq policy 'copy)
3273 (call-interactively 'wl-summary-copy)
3274 (wl-summary-copy dst number)))
3276 (wl-summary-refile-subr 'refile (interactive-p) dst number)))))
3278 (defun wl-summary-copy (&optional dst number)
3279 "Put copy mark on current line message.
3280 If optional argument DST is specified, put mark without asking
3282 If optional argument NUMBER is specified, mark message specified by NUMBER."
3284 (wl-summary-refile-subr 'copy (interactive-p) dst number))
3286 (defun wl-summary-refile-subr (copy-or-refile interactive &optional dst number)
3288 (let* ((buffer-num (wl-summary-message-number))
3289 (msg-num (or number buffer-num))
3291 (elmo-message-field wl-summary-buffer-elmo-folder
3292 msg-num 'message-id)))
3293 (entity (and msg-num
3294 (elmo-msgdb-overview-get-entity
3295 msg-num (wl-summary-buffer-msgdb))))
3297 (intern (format "wl-summary-buffer-%s-list" copy-or-refile)))
3298 folder mark already tmp-folder)
3303 (message "Cannot refile."))
3305 (when (null msg-num)
3307 (message "No message."))
3309 (when (setq mark (wl-summary-get-mark msg-num))
3310 (when (wl-summary-reserve-temp-mark-p mark)
3312 (error "Already marked as `%s'" mark))
3314 (setq folder (and msg-num
3315 (or dst (wl-summary-read-folder
3316 (or (wl-refile-guess entity) wl-trash-folder)
3317 (format "for %s" copy-or-refile)))))
3318 ;; Cache folder hack by okada@opaopa.org
3319 (if (and (eq (elmo-folder-type-internal
3320 (wl-folder-get-elmo-folder
3321 (wl-folder-get-realname folder))) 'cache)
3322 (not (string= folder
3325 (elmo-cache-get-path-subr
3326 (elmo-msgid-to-cache msgid)))))))
3328 (setq folder tmp-folder)
3329 (message "Force refile to %s." folder)))
3330 (if (string= folder (wl-summary-buffer-folder-name))
3331 (error "Same folder"))
3332 (if (or (string= folder wl-queue-folder)
3333 (string= folder wl-draft-folder))
3334 (error "Don't %s messages to %s" copy-or-refile folder))
3335 ;; learn for refile.
3336 (if (eq copy-or-refile 'refile)
3337 (wl-refile-learn entity folder))
3338 (wl-summary-unmark msg-num)
3339 (set variable (append
3340 (symbol-value variable)
3341 (list (cons msg-num folder))))
3342 (when (or interactive
3343 (eq number buffer-num))
3344 (wl-summary-mark-line (if (eq copy-or-refile 'refile)
3346 ;; print refile destination
3347 (wl-summary-print-destination msg-num folder))
3349 (if (eq wl-summary-move-direction-downward nil)
3352 (run-hooks (intern (format "wl-summary-%s-hook" copy-or-refile)))
3353 (setq wl-summary-buffer-prev-refile-destination folder)
3356 (defun wl-summary-refile-prev-destination ()
3357 "Refile message to previously refiled destination."
3359 (wl-summary-refile wl-summary-buffer-prev-refile-destination
3360 (wl-summary-message-number))
3361 (if (eq wl-summary-move-direction-downward nil)
3365 (defun wl-summary-copy-prev-destination ()
3366 "Refile message to previously refiled destination."
3368 (wl-summary-copy wl-summary-buffer-prev-copy-destination
3369 (wl-summary-message-number))
3370 (if (eq wl-summary-move-direction-downward nil)
3374 (defsubst wl-summary-no-auto-refile-message-p (msg mark-alist)
3375 (member (cadr (assq msg mark-alist)) wl-summary-auto-refile-skip-marks))
3377 (defun wl-summary-auto-refile (&optional open-all)
3378 "Set refile mark automatically according to 'wl-refile-guess-by-rule'."
3380 (message "Marking...")
3382 (if (and (eq wl-summary-buffer-view 'thread)
3384 (wl-thread-open-all))
3385 (let* ((spec (wl-summary-buffer-folder-name))
3386 (overview (elmo-msgdb-get-overview
3387 (wl-summary-buffer-msgdb)))
3388 (mark-alist (elmo-msgdb-get-mark-alist
3389 (wl-summary-buffer-msgdb)))
3392 number dst thr-entity)
3395 (setq number (wl-summary-message-number))
3396 (when (and (not (wl-summary-no-auto-refile-message-p number
3399 (wl-folder-get-realname
3400 (wl-refile-guess-by-rule
3401 (elmo-msgdb-overview-get-entity
3402 number (wl-summary-buffer-msgdb)))))
3403 (not (equal dst spec)))
3404 (when (not (member dst checked-dsts))
3405 (wl-folder-confirm-existence (wl-folder-get-elmo-folder dst))
3406 (setq checked-dsts (cons dst checked-dsts)))
3407 (if (wl-summary-refile dst number)
3409 (message "Marking...%d message(s)." count))
3410 (if (eq wl-summary-buffer-view 'thread)
3411 ;; process invisible children.
3412 (unless (wl-thread-entity-get-opened
3413 (setq thr-entity (wl-thread-get-entity number)))
3418 (wl-summary-no-auto-refile-message-p
3420 (wl-thread-entity-get-descendant thr-entity))))
3422 (when (and (setq dst
3423 (wl-refile-guess-by-rule
3424 (elmo-msgdb-overview-get-entity
3425 (car messages) (wl-summary-buffer-msgdb))))
3426 (not (equal dst spec)))
3427 (if (wl-summary-refile dst (car messages))
3429 (message "Marking...%d message(s)." count))
3430 (setq messages (cdr messages))))))
3433 (message "No message was marked.")
3434 (message "Marked %d message(s)." count)))))
3436 (defun wl-summary-unmark (&optional number)
3437 "Unmark marks (temporary, refile, copy, delete)of current line.
3438 If optional argument NUMBER is specified, unmark message specified by NUMBER."
3442 (let ((inhibit-read-only t)
3443 (buffer-read-only nil)
3449 (setq visible (wl-summary-jump-to-msg number))
3451 ;; Delete mark on buffer.
3453 (looking-at "^ *\\(-?[0-9]+\\)\\([^0-9]\\)"))
3454 (goto-char (match-end 2))
3456 (setq number (string-to-int (wl-match-buffer 1))))
3457 (setq cur-mark (wl-match-buffer 2))
3458 (if (string= cur-mark " ")
3460 (delete-region (match-beginning 2) (match-end 2))
3461 (if (setq score-mark (wl-summary-get-score-mark number))
3464 (if (or (string= cur-mark "o")
3465 (string= cur-mark "O"))
3466 (wl-summary-remove-destination))
3467 (if wl-summary-highlight
3468 (wl-highlight-summary-current-line nil nil score-mark))
3469 (set-buffer-modified-p nil))
3470 ;; Remove from temporary mark structure.
3472 (wl-summary-delete-mark number)))))
3474 (defun wl-summary-msg-marked-as-target (msg)
3475 (if (memq msg wl-summary-buffer-target-mark-list)
3478 (defun wl-summary-msg-marked-as-copied (msg)
3479 (assq msg wl-summary-buffer-copy-list))
3481 (defun wl-summary-msg-marked-as-deleted (msg)
3482 (if (memq msg wl-summary-buffer-delete-list)
3485 (defun wl-summary-msg-marked-as-refiled (msg)
3486 (assq msg wl-summary-buffer-refile-list))
3488 (defun wl-summary-target-mark (&optional number)
3489 "Put target mark '*' on current message.
3490 If optional argument NUMBER is specified, mark message specified by NUMBER."
3492 (let* ((buffer-num (wl-summary-message-number))
3493 (msg-num (or number buffer-num))
3496 (when (null msg-num)
3498 (message "No message."))
3500 (when (setq mark (wl-summary-get-mark msg-num))
3501 (when (wl-summary-reserve-temp-mark-p mark)
3503 (error "Already marked as `%s'" mark))
3505 (wl-summary-unmark msg-num))
3506 (if (or (interactive-p)
3507 (eq number buffer-num))
3508 (wl-summary-mark-line "*"))
3509 (setq wl-summary-buffer-target-mark-list
3510 (cons msg-num wl-summary-buffer-target-mark-list))
3512 (if (eq wl-summary-move-direction-downward nil)
3518 (defun wl-summary-refile-region (beg end)
3519 "Put copy mark on messages in the region specified by BEG and END."
3521 (wl-summary-refile-region-subr "refile" beg end))
3523 (defun wl-summary-copy-region (beg end)
3524 "Put copy mark on messages in the region specified by BEG and END."
3526 (wl-summary-refile-region-subr "copy" beg end))
3528 (defun wl-summary-refile-region-subr (copy-or-refile beg end)
3532 ;; guess by first msg
3533 (let* ((msgid (cdr (assq (wl-summary-message-number)
3534 (elmo-msgdb-get-number-alist
3535 (wl-summary-buffer-msgdb)))))
3536 (function (intern (format "wl-summary-%s" copy-or-refile)))
3537 (entity (assoc msgid (elmo-msgdb-get-overview
3538 (wl-summary-buffer-msgdb))))
3541 (setq folder (wl-summary-read-folder (wl-refile-guess entity)
3544 (narrow-to-region beg end)
3545 (if (eq wl-summary-buffer-view 'thread)
3548 (let* ((number (wl-summary-message-number))
3549 (entity (wl-thread-get-entity number))
3551 (if (wl-thread-entity-get-opened entity)
3552 ;; opened...refile line.
3553 (funcall function folder number)
3555 (setq children (wl-thread-get-children-msgs number))
3557 (funcall function folder (pop children))))
3560 (funcall function folder (wl-summary-message-number))
3561 (forward-line 1)))))))
3563 (defun wl-summary-unmark-region (beg end)
3567 (narrow-to-region beg end)
3568 (goto-char (point-min))
3569 (if (eq wl-summary-buffer-view 'thread)
3572 (let* ((number (wl-summary-message-number))
3573 (entity (wl-thread-get-entity number)))
3574 (if (wl-thread-entity-get-opened entity)
3575 ;; opened...unmark line.
3578 (wl-summary-delete-marks-on-buffer
3579 (wl-thread-get-children-msgs number))))
3583 (forward-line 1))))))
3585 (defun wl-summary-mark-region-subr (function beg end)
3588 (narrow-to-region beg end)
3589 (goto-char (point-min))
3590 (if (eq wl-summary-buffer-view 'thread)
3593 (let* ((number (wl-summary-message-number))
3594 (entity (wl-thread-get-entity number))
3595 (wl-summary-move-direction-downward t)
3597 (if (wl-thread-entity-get-opened entity)
3598 ;; opened...delete line.
3599 (funcall function number)
3601 (setq children (wl-thread-get-children-msgs number))
3603 (funcall function (pop children))))
3606 (funcall function (wl-summary-message-number))
3607 (forward-line 1))))))
3609 (defun wl-summary-delete-region (beg end)
3611 (wl-summary-mark-region-subr 'wl-summary-delete beg end))
3613 (defun wl-summary-target-mark-region (beg end)
3615 (wl-summary-mark-region-subr 'wl-summary-target-mark beg end))
3617 (defun wl-summary-target-mark-all ()
3619 (wl-summary-target-mark-region (point-min) (point-max))
3620 (setq wl-summary-buffer-target-mark-list
3622 (elmo-msgdb-get-number-alist (wl-summary-buffer-msgdb)))))
3624 (defun wl-summary-delete-all-mark (mark)
3625 (goto-char (point-min))
3626 (let ((case-fold-search nil))
3627 (while (re-search-forward (format "^ *-?[0-9]+%s"
3628 (regexp-quote mark)) nil t)
3629 (wl-summary-unmark))
3630 (cond ((string= mark "*")
3631 (setq wl-summary-buffer-target-mark-list nil))
3633 (setq wl-summary-buffer-delete-list nil))
3635 (setq wl-summary-buffer-copy-list nil))
3637 (setq wl-summary-buffer-refile-list nil)))))
3639 (defun wl-summary-unmark-all ()
3640 "Unmark all according to what you input."
3642 (let ((unmarks (string-to-char-list (read-from-minibuffer "Unmark: ")))
3646 (setq cur-mark (char-to-string (car unmarks)))
3647 (wl-summary-delete-all-mark cur-mark)
3648 (setq unmarks (cdr unmarks))))))
3650 (defun wl-summary-target-mark-thread ()
3654 (wl-summary-goto-top-of-current-thread)
3655 (wl-thread-force-open)
3658 (wl-summary-goto-bottom-of-current-thread)
3659 ;;; (forward-line -1)
3662 (wl-summary-target-mark-region beg end)))
3664 (defun wl-summary-target-mark-msgs (msgs)
3666 (if (eq wl-summary-buffer-view 'thread)
3667 (wl-thread-jump-to-msg (car msgs))
3668 (wl-summary-jump-to-msg (car msgs)))
3669 (wl-summary-target-mark (wl-summary-message-number))
3670 (setq msgs (cdr msgs))))
3672 (defun wl-summary-pick (&optional from-list delete-marks)
3674 (let ((result (elmo-msgdb-search
3675 wl-summary-buffer-elmo-folder
3676 (elmo-read-search-condition wl-summary-pick-field-default)
3677 (wl-summary-buffer-msgdb))))
3679 (let ((mlist wl-summary-buffer-target-mark-list))
3681 (when (wl-summary-jump-to-msg (car mlist))
3682 (wl-summary-unmark))
3683 (setq mlist (cdr mlist)))
3684 (setq wl-summary-buffer-target-mark-list nil)))
3686 (setq result (elmo-list-filter from-list result)))
3687 (message "%d message(s) are picked." (length result))
3689 (message "No message was picked.")
3690 (wl-summary-target-mark-msgs result))))
3692 (defun wl-summary-unvirtual ()
3693 "Exit from current virtual folder."
3696 (elmo-folder-type-internal wl-summary-buffer-elmo-folder))
3697 (wl-summary-goto-folder-subr
3698 (elmo-folder-name-internal
3699 (elmo-filter-folder-target-internal
3700 wl-summary-buffer-elmo-folder))
3702 (error "This folder is not filtered")))
3704 (defun wl-summary-virtual (&optional arg)
3705 "Goto virtual folder.
3706 If ARG, exit virtual folder."
3709 (wl-summary-unvirtual)
3710 (wl-summary-goto-folder-subr (concat "/"
3711 (elmo-read-search-condition
3712 wl-summary-pick-field-default)
3714 (wl-summary-buffer-folder-name))
3715 'update nil nil t)))
3717 (defun wl-summary-delete-all-temp-marks ()
3720 (goto-char (point-min))
3721 (message "Unmarking...")
3725 (message "Unmarking...done")
3726 (setq wl-summary-buffer-target-mark-list nil)
3727 (setq wl-summary-buffer-delete-list nil)
3728 (setq wl-summary-buffer-refile-list nil)
3729 (setq wl-summary-buffer-copy-list nil)))
3731 (defun wl-summary-delete-mark (number)
3732 "Delete temporary mark of the message specified by NUMBER."
3734 ((memq number wl-summary-buffer-target-mark-list)
3735 (setq wl-summary-buffer-target-mark-list
3736 (delq number wl-summary-buffer-target-mark-list)))
3737 ((memq number wl-summary-buffer-delete-list)
3738 (setq wl-summary-buffer-delete-list
3739 (delq number wl-summary-buffer-delete-list)))
3743 ((setq pair (assq number wl-summary-buffer-copy-list))
3744 (setq wl-summary-buffer-copy-list
3745 (delq pair wl-summary-buffer-copy-list)))
3746 ((setq pair (assq number wl-summary-buffer-refile-list))
3747 (setq wl-summary-buffer-refile-list
3748 (delq pair wl-summary-buffer-refile-list))))))))
3750 (defun wl-summary-mark-line (mark)
3751 "Put MARK on current line. Return message number."
3754 (let ((inhibit-read-only t)
3755 (buffer-read-only nil)
3758 (when (looking-at "^ *\\(-?[0-9]+\\)\\([^0-9]\\)")
3759 (setq msg-num (string-to-int (wl-match-buffer 1)))
3760 (setq cur-mark (wl-match-buffer 2))
3761 (goto-char (match-end 1))
3762 (delete-region (match-beginning 2) (match-end 2))
3763 ;;; (wl-summary-delete-mark msg-num)
3765 (if wl-summary-highlight
3766 (wl-highlight-summary-current-line nil nil t))
3767 (set-buffer-modified-p nil)
3770 (defun wl-summary-target-mark-delete ()
3773 (goto-char (point-min))
3774 (let ((regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
3776 (while (re-search-forward regexp nil t)
3777 (let (wl-summary-buffer-disp-msg)
3778 (when (setq number (wl-summary-message-number))
3779 (wl-summary-delete number)
3780 (setq wl-summary-buffer-target-mark-list
3781 (delq number wl-summary-buffer-target-mark-list)))))
3782 (setq mlist wl-summary-buffer-target-mark-list)
3784 (wl-append wl-summary-buffer-delete-list (list (car mlist)))
3785 (setq wl-summary-buffer-target-mark-list
3786 (delq (car mlist) wl-summary-buffer-target-mark-list))
3787 (setq mlist (cdr mlist))))))
3789 (defun wl-summary-target-mark-prefetch (&optional ignore-cache)
3792 (let* ((mlist (nreverse wl-summary-buffer-target-mark-list))
3793 (inhibit-read-only t)
3794 (buffer-read-only nil)
3796 (length (length mlist))
3801 (setq new-mark (wl-summary-prefetch-msg (car mlist) ignore-cache))
3804 (message "Prefetching... %d/%d message(s)"
3805 (setq count (+ 1 count)) length)
3806 (when (wl-summary-jump-to-msg (car mlist))
3809 (when (looking-at "^ *-?[0-9]+[^0-9]\\([^0-9]\\)")
3810 (delete-region (match-beginning 1) (match-end 1)))
3811 (goto-char (match-beginning 1))
3813 (if wl-summary-highlight
3814 (wl-highlight-summary-current-line))
3818 (setq skipped (cons (car mlist) skipped)))
3819 (setq mlist (cdr mlist)))
3820 (setq wl-summary-buffer-target-mark-list skipped)
3821 (message "Prefetching... %d/%d message(s)." count length)
3822 (set-buffer-modified-p nil))))
3824 (defun wl-summary-target-mark-refile-subr (copy-or-refile)
3826 (intern (format "wl-summary-buffer-%s-list" copy-or-refile)))
3828 (intern (format "wl-summary-%s" copy-or-refile)))
3829 regexp number msgid entity folder mlist)
3831 (goto-char (point-min))
3832 (setq regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
3833 ;; guess by first mark
3834 (when (re-search-forward regexp nil t)
3835 (setq msgid (cdr (assq (setq number (wl-summary-message-number))
3836 (elmo-msgdb-get-number-alist
3837 (wl-summary-buffer-msgdb))))
3839 (elmo-msgdb-get-overview
3840 (wl-summary-buffer-msgdb))))
3842 (error "Cannot %s" copy-or-refile))
3844 (setq folder (wl-summary-read-folder
3845 (wl-refile-guess entity)
3846 (format "for %s" copy-or-refile)))
3849 (setq wl-summary-buffer-target-mark-list
3850 (delq number wl-summary-buffer-target-mark-list)))
3851 (while (re-search-forward regexp nil t)
3852 (let (wl-summary-buffer-disp-msg)
3853 (when (setq number (wl-summary-message-number))
3854 (funcall function folder number)
3855 (setq wl-summary-buffer-target-mark-list
3856 (delq number wl-summary-buffer-target-mark-list)))))
3857 ;; process invisible messages.
3858 (setq mlist wl-summary-buffer-target-mark-list)
3861 (append (symbol-value variable)
3862 (list (cons (car mlist) folder))))
3863 (setq wl-summary-buffer-target-mark-list
3864 (delq (car mlist) wl-summary-buffer-target-mark-list))
3865 (setq mlist (cdr mlist)))))))
3867 (defun wl-summary-target-mark-copy ()
3869 (wl-summary-target-mark-refile-subr "copy"))
3871 (defun wl-summary-target-mark-refile ()
3873 (wl-summary-target-mark-refile-subr "refile"))
3875 (defun wl-summary-target-mark-mark-as-read ()
3878 (goto-char (point-min))
3879 (let ((regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
3880 (inhibit-read-only t)
3881 (buffer-read-only nil)
3883 (while (re-search-forward regexp nil t)
3884 (let (wl-summary-buffer-disp-msg)
3885 ;; delete target-mark from buffer.
3886 (delete-region (match-beginning 1) (match-end 1))
3888 (setq number (wl-summary-mark-as-read t))
3889 (if wl-summary-highlight
3890 (wl-highlight-summary-current-line))
3892 (setq wl-summary-buffer-target-mark-list
3893 (delq number wl-summary-buffer-target-mark-list)))))
3894 (setq mlist wl-summary-buffer-target-mark-list)
3896 (wl-summary-mark-as-read t nil nil (car mlist))
3897 (setq wl-summary-buffer-target-mark-list
3898 (delq (car mlist) wl-summary-buffer-target-mark-list))
3899 (setq mlist (cdr mlist)))
3900 (wl-summary-count-unread
3901 (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
3902 (wl-summary-update-modeline))))
3904 (defun wl-summary-target-mark-mark-as-unread ()
3907 (goto-char (point-min))
3908 (let ((regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
3909 (inhibit-read-only t)
3910 (buffer-read-only nil)
3912 (while (re-search-forward regexp nil t)
3913 (let (wl-summary-buffer-disp-msg)
3914 ;; delete target-mark from buffer.
3915 (delete-region (match-beginning 1) (match-end 1))
3917 (setq number (wl-summary-mark-as-unread))
3918 (if wl-summary-highlight
3919 (wl-highlight-summary-current-line))
3921 (setq wl-summary-buffer-target-mark-list
3922 (delq number wl-summary-buffer-target-mark-list)))))
3923 (setq mlist wl-summary-buffer-target-mark-list)
3925 (wl-summary-mark-as-unread (car mlist))
3926 ;;; (wl-thread-msg-mark-as-unread (car mlist))
3927 (setq wl-summary-buffer-target-mark-list
3928 (delq (car mlist) wl-summary-buffer-target-mark-list))
3929 (setq mlist (cdr mlist)))
3930 (wl-summary-count-unread
3931 (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
3932 (wl-summary-update-modeline))))
3934 (defun wl-summary-target-mark-mark-as-important ()
3937 (goto-char (point-min))
3938 (let ((regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
3939 (inhibit-read-only t)
3940 (buffer-read-only nil)
3942 (while (re-search-forward regexp nil t)
3943 (let (wl-summary-buffer-disp-msg)
3944 ;; delete target-mark from buffer.
3945 (delete-region (match-beginning 1) (match-end 1))
3947 (setq number (wl-summary-mark-as-important))
3948 (if wl-summary-highlight
3949 (wl-highlight-summary-current-line))
3951 (setq wl-summary-buffer-target-mark-list
3952 (delq number wl-summary-buffer-target-mark-list)))))
3953 (setq mlist wl-summary-buffer-target-mark-list)
3955 (wl-summary-mark-as-important (car mlist))
3956 (wl-thread-msg-mark-as-important (car mlist))
3957 (setq wl-summary-buffer-target-mark-list
3958 (delq (car mlist) wl-summary-buffer-target-mark-list))
3959 (setq mlist (cdr mlist)))
3960 (wl-summary-count-unread
3961 (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
3962 (wl-summary-update-modeline))))
3964 (defun wl-summary-target-mark-save ()
3967 (goto-char (point-min))
3969 (wl-read-directory-name "Save to directory: "
3970 wl-temporary-file-directory))
3971 (regexp (concat "^" wl-summary-buffer-number-regexp "\\(\\*\\)"))
3973 (if (null (file-exists-p wl-save-dir))
3974 (make-directory wl-save-dir))
3975 (while (re-search-forward regexp nil t)
3976 (let (wl-summary-buffer-disp-msg)
3977 (setq number (wl-summary-save t wl-save-dir))
3980 (setq wl-summary-buffer-target-mark-list
3981 (delq number wl-summary-buffer-target-mark-list))))))))
3983 (defun wl-summary-target-mark-pick ()
3985 (wl-summary-pick wl-summary-buffer-target-mark-list 'delete))
3987 (defun wl-summary-mark-as-read (&optional notcrosses
3988 leave-server-side-mark-untouched
3995 (inhibit-read-only t)
3996 (buffer-read-only nil)
3997 (folder wl-summary-buffer-elmo-folder)
3998 (msgdb (wl-summary-buffer-msgdb))
3999 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
4000 ;;; (number-alist (elmo-msgdb-get-number-alist msgdb))
4001 (case-fold-search nil)
4002 mark stat visible uncached new-mark marked)
4005 (setq visible (wl-summary-jump-to-msg number))
4006 (setq mark (cadr (assq number mark-alist))))
4010 (if (or (not visible)
4012 (format "^ *\\(-?[0-9]+\\)[^0-9]\\(%s\\|%s\\|%s\\|%s\\).*$"
4013 (regexp-quote wl-summary-read-uncached-mark)
4014 (regexp-quote wl-summary-unread-uncached-mark)
4015 (regexp-quote wl-summary-unread-cached-mark)
4016 (regexp-quote wl-summary-new-mark))))
4018 (setq mark (or mark (wl-match-buffer 2)))
4021 ((string= mark wl-summary-new-mark) ; N
4024 ((string= mark wl-summary-unread-uncached-mark) ; U
4027 ((string= mark wl-summary-unread-cached-mark) ; !
4028 (setq stat 'unread))
4030 ;; no need to mark server.
4031 (setq leave-server-side-mark-untouched t))))
4032 (setq number (or number (string-to-int (wl-match-buffer 1))))
4033 ;; set server side mark...
4034 (setq new-mark (if (and uncached
4035 (if (elmo-message-use-cache-p folder number)
4036 (not (elmo-folder-local-p folder)))
4038 wl-summary-read-uncached-mark
4040 (if (not leave-server-side-mark-untouched)
4042 (setq marked (elmo-folder-mark-as-read
4045 (if (or leave-server-side-mark-untouched
4048 (cond ((eq stat 'unread)
4049 (setq wl-summary-buffer-unread-count
4050 (1- wl-summary-buffer-unread-count)))
4052 (setq wl-summary-buffer-new-count
4053 (1- wl-summary-buffer-new-count))))
4054 (wl-summary-update-modeline)
4055 (wl-folder-update-unread
4056 (wl-summary-buffer-folder-name)
4057 (+ wl-summary-buffer-unread-count
4058 wl-summary-buffer-new-count))
4059 (when (or stat cached)
4061 (goto-char (match-end 2))
4062 (delete-region (match-beginning 2) (match-end 2))
4063 (insert (or new-mark " ")))
4065 (elmo-msgdb-mark-set mark-alist number new-mark))
4066 (elmo-msgdb-set-mark-alist msgdb mark-alist)
4067 (wl-summary-set-mark-modified))
4068 (if (and visible wl-summary-highlight)
4069 (wl-highlight-summary-current-line nil nil t)))
4070 (if mark (message "Warning: Changing mark failed.")))))
4071 (set-buffer-modified-p nil)
4073 (run-hooks 'wl-summary-unread-message-hook))
4074 number ;return value
4077 (defun wl-summary-mark-as-important (&optional number
4081 (if (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
4083 (error "Cannot process mark in this folder"))
4086 (inhibit-read-only t)
4087 (buffer-read-only nil)
4088 (folder wl-summary-buffer-elmo-folder)
4089 (msgdb (wl-summary-buffer-msgdb))
4090 (mark-alist (elmo-msgdb-get-mark-alist msgdb))
4091 (number-alist (elmo-msgdb-get-number-alist msgdb))
4095 (setq visible (wl-summary-jump-to-msg number))
4096 (setq mark (or mark (cadr (assq number mark-alist)))))
4099 (if (null (setq number (wl-summary-message-number)))
4101 (message "No message.")
4105 (re-search-backward (concat "^" wl-summary-buffer-number-regexp
4106 "..../..") nil t)) ; set cursor line
4107 (beginning-of-line))
4108 (if (or (and (not visible)
4109 (assq number (elmo-msgdb-get-number-alist msgdb)))
4110 (re-search-forward "^ *\\(-?[0-9]+\\)[^0-9]\\([^0-9]\\)" eol t))
4112 (setq number (or number (string-to-int (wl-match-buffer 1))))
4113 (setq mark (or mark (wl-match-buffer 2)))
4114 (setq message-id (elmo-message-field
4115 wl-summary-buffer-elmo-folder
4118 (if (string= mark wl-summary-important-mark)
4122 (unless no-server-update
4123 (elmo-folder-unmark-important folder (list number))
4124 (elmo-msgdb-global-mark-delete message-id))
4125 ;; Remove cache if local folder.
4126 (if (and (elmo-folder-local-p folder)
4128 (elmo-folder-type-internal folder))))
4129 (elmo-file-cache-delete
4130 (elmo-file-cache-get-path message-id))))
4132 (delete-region (match-beginning 2) (match-end 2))
4135 (elmo-msgdb-mark-set mark-alist
4140 (unless no-server-update
4141 (elmo-folder-mark-as-important folder (list number))))
4143 (delete-region (match-beginning 2) (match-end 2))
4144 (insert wl-summary-important-mark))
4146 (elmo-msgdb-mark-set mark-alist
4148 wl-summary-important-mark))
4149 (if (elmo-file-cache-exists-p message-id)
4150 (elmo-folder-mark-as-read folder (list number))
4151 ;; Force cache message.
4152 (elmo-message-encache folder number 'read))
4153 (unless no-server-update
4154 (elmo-msgdb-global-mark-set message-id
4155 wl-summary-important-mark)))
4156 (elmo-msgdb-set-mark-alist msgdb mark-alist)
4157 (wl-summary-set-mark-modified)))
4158 (if (and visible wl-summary-highlight)
4159 (wl-highlight-summary-current-line nil nil t))))
4160 (set-buffer-modified-p nil)
4163 (defsubst wl-summary-format-date (date-string)
4165 (let ((datevec (timezone-fix-time date-string nil
4166 wl-summary-fix-timezone)))
4167 (format "%02d/%02d(%s)%02d:%02d"
4170 (elmo-date-get-week (aref datevec 0)
4175 (error "??/??(??)??:??")))
4177 (defun wl-summary-overview-create-summary-line (msg
4184 temp-mark thr-entity
4186 (let ((wl-mime-charset wl-summary-buffer-mime-charset)
4187 (elmo-mime-charset wl-summary-buffer-mime-charset)
4188 no-parent before-indent
4189 from subject parent-raw-subject parent-subject
4191 (elmo-lang wl-summary-buffer-weekday-name-lang)
4192 (children-num (if children-num (int-to-string children-num)))
4196 (setq thr-str (wl-thread-make-indent-string thr-entity))
4197 (setq linked (wl-thread-entity-get-linked thr-entity)))
4198 (if (string= thr-str "")
4199 (setq no-parent t)) ; no parent
4200 (if (and wl-summary-indent-length-limit
4201 (< wl-summary-indent-length-limit
4202 (string-width thr-str)))
4203 (setq thr-str (wl-set-string-width
4204 wl-summary-indent-length-limit
4207 (wl-set-string-width
4209 (- wl-summary-from-width (length children-num) 2)
4210 wl-summary-from-width)
4211 (elmo-delete-char ?\n
4212 (wl-summary-from-func-internal
4213 (elmo-msgdb-overview-entity-get-from entity)))))
4215 (elmo-delete-char ?\n
4216 (or (elmo-msgdb-overview-entity-get-subject
4218 wl-summary-no-subject-message)))
4219 (setq parent-raw-subject
4220 (elmo-msgdb-overview-entity-get-subject parent-entity))
4221 (setq parent-subject
4222 (if parent-raw-subject
4223 (elmo-delete-char ?\n parent-raw-subject)))
4224 (setq mark (or (cadr (assq msg mark-alist)) " "))
4230 wl-summary-buffer-number-column)
4235 (wl-summary-format-date
4236 (elmo-msgdb-overview-entity-get-date entity))
4237 (if thr-str thr-str "")))
4242 (concat "+" children-num ": " from)
4247 (null parent-subject)
4248 (not (wl-summary-subject-equal
4249 subject parent-subject)))
4250 (wl-summary-subject-func-internal subject) ""))
4251 (if (and (not wl-summary-width)
4252 wl-summary-subject-length-limit)
4253 (truncate-string subject wl-summary-subject-length-limit)
4255 (if wl-summary-width (setq line
4256 (wl-set-string-width
4257 (- wl-summary-width 1) line)))
4258 (if wl-summary-highlight
4259 (wl-highlight-summary-line-string line
4265 (defsubst wl-summary-buffer-number-column-detect (update)
4268 (goto-char (point-min))
4269 (setq wl-summary-buffer-number-column
4272 (setq end (if (re-search-forward
4273 "^ *-?[0-9]+[^0-9]" nil t)
4275 (- end (progn (beginning-of-line) (point)) 1))
4276 (wl-get-assoc-list-value wl-summary-number-column-alist
4277 (wl-summary-buffer-folder-name))
4278 wl-summary-default-number-column))
4279 (setq wl-summary-buffer-number-regexp
4280 (wl-repeat-string "." wl-summary-buffer-number-column)))))
4282 (defsubst wl-summary-proc-wday (wday-str year month mday)
4284 (if (string-match "\\([A-Z][a-z][a-z]\\).*" wday-str)
4285 (wl-match-string 1 wday-str)
4286 (elmo-date-get-week year month mday))))
4288 (defvar wl-summary-move-spec-plugged-alist
4289 (` ((new . ((t . nil)
4290 (p . (, wl-summary-new-mark))
4291 (p . (, (wl-regexp-opt
4292 (list wl-summary-unread-uncached-mark
4293 wl-summary-unread-cached-mark))))
4294 (p . (, (regexp-quote wl-summary-important-mark)))))
4295 (unread . ((t . nil)
4296 (p . (, (wl-regexp-opt
4297 (list wl-summary-new-mark
4298 wl-summary-unread-uncached-mark
4299 wl-summary-unread-cached-mark))))
4300 (p . (, (regexp-quote wl-summary-important-mark))))))))
4302 (defvar wl-summary-move-spec-unplugged-alist
4303 (` ((new . ((t . nil)
4304 (p . (, wl-summary-unread-cached-mark))
4305 (p . (, (regexp-quote wl-summary-important-mark)))))
4306 (unread . ((t . nil)
4307 (p . (, wl-summary-unread-cached-mark))
4308 (p . (, (regexp-quote wl-summary-important-mark))))))))
4310 (defsubst wl-summary-next-message (num direction hereto)
4311 (if wl-summary-buffer-next-message-function
4312 (funcall wl-summary-buffer-next-message-function num direction hereto)
4313 (let ((cur-spec (cdr (assq wl-summary-move-order
4314 (if (elmo-folder-plugged-p
4315 wl-summary-buffer-elmo-folder)
4316 wl-summary-move-spec-plugged-alist
4317 wl-summary-move-spec-unplugged-alist))))
4318 (nums (memq num (if (eq direction 'up)
4319 (reverse wl-summary-buffer-number-list)
4320 wl-summary-buffer-number-list)))
4322 (unless hereto (setq nums (cdr nums)))
4328 (cond ((eq (car (car cur-spec)) 'p)
4329 (if (setq marked-list
4330 (elmo-folder-list-messages-mark-match
4331 wl-summary-buffer-elmo-folder
4332 (cdr (car cur-spec))))
4334 (if (memq (car nums) marked-list)
4335 (throw 'done (car nums)))
4336 (setq nums (cdr nums)))))
4337 ((eq (car (car cur-spec)) 't)
4338 (if wl-summary-buffer-target-mark-list
4340 (if (memq (car nums)
4341 wl-summary-buffer-target-mark-list)
4342 (throw 'done (car nums)))
4343 (setq nums (cdr nums))))))
4344 (setq cur-spec (cdr cur-spec))))
4347 (defsubst wl-summary-cursor-move (direction hereto)
4348 (when (and (eq direction 'up)
4353 (when (setq num (wl-summary-next-message (wl-summary-message-number)
4356 (wl-thread-jump-to-msg num))
4359 ;; Goto unread or important
4360 ;; returns t if next message exists in this folder.
4361 (defun wl-summary-cursor-down (&optional hereto)
4363 (wl-summary-cursor-move 'down hereto))
4365 (defun wl-summary-cursor-up (&optional hereto)
4367 (wl-summary-cursor-move 'up hereto))
4369 (defun wl-summary-save-view-cache ()
4371 (let* ((dir (elmo-folder-msgdb-path wl-summary-buffer-elmo-folder))
4372 (cache (expand-file-name wl-summary-cache-file dir))
4373 (view (expand-file-name wl-summary-view-file dir))
4374 (save-view wl-summary-buffer-view)
4375 (tmp-buffer (get-buffer-create " *wl-summary-save-view-cache*"))
4376 (charset wl-summary-buffer-mime-charset))
4377 (if (file-directory-p dir)
4379 (if (file-exists-p dir)
4380 (error "File %s already exists" dir)
4381 (elmo-make-directory dir)))
4382 (if (eq save-view 'thread)
4383 (wl-thread-save-entity dir))
4386 (when (file-writable-p cache)
4387 (copy-to-buffer tmp-buffer (point-min) (point-max))
4388 (with-current-buffer tmp-buffer
4390 (encode-mime-charset-region
4391 (point-min) (point-max) charset)
4392 (write-region-as-binary (point-min)(point-max)
4393 cache nil 'no-msg)))
4394 (when (file-writable-p view) ; 'thread or 'sequence
4396 (set-buffer tmp-buffer)
4398 (prin1 save-view tmp-buffer)
4399 (princ "\n" tmp-buffer)
4400 (write-region (point-min) (point-max) view nil 'no-msg))))
4402 (kill-buffer tmp-buffer)))))
4404 (defsubst wl-summary-get-sync-range (folder)
4406 (elmo-folder-plugged-p folder)
4407 (wl-get-assoc-list-value
4408 wl-folder-sync-range-alist
4409 (elmo-folder-name-internal folder)))
4410 wl-default-sync-range)))
4412 ;; redefined for wl-summary-sync-update
4413 (defun wl-summary-input-range (folder)
4414 "returns update or all or rescan."
4415 ;; for the case when parts are expanded in the bottom of the folder
4416 (let ((input-range-list '("update" "all" "rescan" "first:" "last:"
4417 "no-sync" "rescan-noscore" "all-visible"))
4418 (default (or (wl-get-assoc-list-value
4419 wl-folder-sync-range-alist
4421 wl-default-sync-range))
4424 (completing-read (format "Range (%s): " default)
4426 (function (lambda (x) (cons x x)))
4428 (if (string= range "")
4432 (defun wl-summary-toggle-disp-folder (&optional arg)
4434 (let ((cur-buf (current-buffer))
4435 (summary-win (get-buffer-window (current-buffer)))
4439 (setq wl-summary-buffer-disp-folder t)
4440 ;; hide your folder window
4441 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
4442 (if (setq fld-win (get-buffer-window fld-buf))
4443 (delete-window fld-win))))
4445 (setq wl-summary-buffer-disp-folder nil)
4446 ;; hide your wl-message window!
4447 (when (buffer-live-p wl-message-buffer)
4448 (wl-message-select-buffer wl-message-buffer)
4450 (select-window (get-buffer-window cur-buf))
4451 ;; display wl-folder window!!
4452 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
4453 (if (setq fld-win (get-buffer-window fld-buf))
4454 ;; folder win is already displayed.
4455 (select-window fld-win)
4456 ;; folder win is not displayed.
4457 (switch-to-buffer fld-buf))
4460 ;; temporarily delete summary-win.
4462 (delete-window summary-win))
4463 (split-window-horizontally wl-folder-window-width)
4465 (switch-to-buffer cur-buf))
4467 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
4468 (if (setq fld-win (get-buffer-window fld-buf))
4469 (setq wl-summary-buffer-disp-folder nil)
4470 (setq wl-summary-buffer-disp-folder t)))
4471 (if (not wl-summary-buffer-disp-folder)
4472 ;; hide message window
4473 (let ((mes-win (and wl-message-buffer
4474 (get-buffer-window wl-message-buffer)))
4475 (wl-stay-folder-window t))
4476 (if mes-win (delete-window mes-win))
4477 ;; hide your folder window
4478 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
4479 (if (setq fld-win (get-buffer-window fld-buf))
4481 (delete-window (get-buffer-window cur-buf))
4482 (select-window fld-win)
4483 (switch-to-buffer cur-buf))))
4484 (run-hooks 'wl-summary-toggle-disp-folder-off-hook)
4485 ;; resume message window.
4487 (wl-message-select-buffer wl-message-buffer)
4488 (run-hooks 'wl-summary-toggle-disp-folder-message-resumed-hook)
4489 (select-window (get-buffer-window cur-buf))))
4490 ;; hide message window
4491 (let ((wl-stay-folder-window t)
4492 (mes-win (and wl-message-buffer
4493 (get-buffer-window wl-message-buffer))))
4494 (if mes-win (delete-window mes-win))
4495 (select-window (get-buffer-window cur-buf))
4496 ;; display wl-folder window!!
4497 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
4498 (if (setq fld-win (get-buffer-window fld-buf))
4499 ;; folder win is already displayed.
4500 (select-window fld-win)
4501 ;; folder win is not displayed...occupy all.
4502 (switch-to-buffer fld-buf))
4505 (split-window-horizontally wl-folder-window-width)
4507 (switch-to-buffer cur-buf)
4508 ;; resume message window.
4509 (run-hooks 'wl-summary-toggle-disp-folder-on-hook)
4511 (wl-message-select-buffer wl-message-buffer)
4512 (run-hooks 'wl-summary-toggle-disp-folder-message-resumed-hook)
4513 (select-window (get-buffer-window cur-buf))))))))
4514 (run-hooks 'wl-summary-toggle-disp-folder-hook))
4516 (defun wl-summary-toggle-disp-msg (&optional arg)
4518 (let ((cur-buf (current-buffer))
4523 (setq wl-summary-buffer-disp-msg t)
4525 ;; hide your folder window
4526 (if (and (not wl-stay-folder-window)
4527 (setq fld-buf (get-buffer wl-folder-buffer-name)))
4528 (if (setq fld-win (get-buffer-window fld-buf))
4529 (unless (one-window-p fld-win)
4530 (delete-window fld-win))))))
4532 (wl-delete-all-overlays)
4533 (setq wl-summary-buffer-disp-msg nil)
4535 (when (buffer-live-p wl-message-buffer)
4536 (wl-message-select-buffer wl-message-buffer)
4538 (and (get-buffer-window cur-buf)
4539 (select-window (get-buffer-window cur-buf))))
4540 (run-hooks 'wl-summary-toggle-disp-off-hook)))
4542 (if (and wl-message-buffer
4543 (get-buffer-window wl-message-buffer)) ; already displayed
4544 (setq wl-summary-buffer-disp-msg nil)
4545 (setq wl-summary-buffer-disp-msg t))
4546 (if wl-summary-buffer-disp-msg
4548 (wl-summary-redisplay)
4549 ;;; hide your folder window
4550 ;;; (setq fld-buf (get-buffer wl-folder-buffer-name))
4551 ;;; (if (setq fld-win (get-buffer-window fld-buf))
4552 ;;; (delete-window fld-win)))
4553 (run-hooks 'wl-summary-toggle-disp-on-hook))
4554 (wl-delete-all-overlays)
4556 (wl-message-select-buffer wl-message-buffer)
4558 (select-window (get-buffer-window cur-buf))
4559 (run-hooks 'wl-summary-toggle-disp-off-hook))
4560 ;;; (switch-to-buffer cur-buf)
4563 (defun wl-summary-next-line-content ()
4564 "Show next line of the message."
4566 (let ((cur-buf (current-buffer)))
4567 (wl-summary-toggle-disp-msg 'on)
4568 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
4569 (set-buffer cur-buf)
4570 (wl-message-next-page 1))))
4572 (defun wl-summary-prev-line-content ()
4574 (let ((cur-buf (current-buffer)))
4575 (wl-summary-toggle-disp-msg 'on)
4576 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
4577 (set-buffer cur-buf)
4578 (wl-message-prev-page 1))))
4580 (defun wl-summary-next-page ()
4582 (wl-message-next-page))
4584 (defun wl-summary-prev-page ()
4586 (wl-message-prev-page))
4588 (defsubst wl-summary-no-mime-p (folder)
4589 (wl-string-match-member (elmo-folder-name-internal folder)
4590 wl-summary-no-mime-folder-list))
4592 (defun wl-summary-set-message-buffer-or-redisplay (&rest args)
4593 "Set message buffer.
4594 If message is not displayed yet, display it.
4595 Return t if message exists."
4596 (let ((folder wl-summary-buffer-elmo-folder)
4597 (number (wl-summary-message-number))
4598 cur-folder cur-number message-last-pos)
4599 (when (buffer-live-p wl-message-buffer)
4600 (save-window-excursion
4601 (wl-message-select-buffer wl-message-buffer)
4602 (setq cur-folder wl-message-buffer-cur-folder)
4603 (setq cur-number wl-message-buffer-cur-number)))
4604 (if (and (string= (elmo-folder-name-internal folder) (or cur-folder ""))
4605 (eq number (or cur-number 0)))
4607 (set-buffer wl-message-buffer)
4609 (if (wl-summary-no-mime-p folder)
4610 (wl-summary-redisplay-no-mime folder number)
4611 (wl-summary-redisplay-internal folder number))
4612 (when (buffer-live-p wl-message-buffer)
4613 (set-buffer wl-message-buffer))
4616 (defun wl-summary-target-mark-forward (&optional arg)
4618 (let ((mlist (nreverse wl-summary-buffer-target-mark-list))
4619 (summary-buf (current-buffer))
4620 (wl-draft-forward t)
4623 (wl-summary-jump-to-msg (car mlist))
4624 (wl-summary-forward t)
4625 (setq start-point (point))
4626 (setq draft-buf (current-buffer))
4627 (setq mlist (cdr mlist))
4628 (save-window-excursion
4631 (set-buffer summary-buf)
4632 (wl-summary-jump-to-msg (car mlist))
4633 (wl-summary-redisplay)
4634 (set-buffer draft-buf)
4635 (goto-char (point-max))
4636 (wl-draft-insert-message)
4637 (setq mlist (cdr mlist)))
4638 (wl-draft-body-goto-top)
4639 (wl-draft-enclose-digest-region (point) (point-max)))
4640 (goto-char start-point)
4642 (set-buffer summary-buf)
4643 (wl-summary-delete-all-temp-marks)))
4644 (run-hooks 'wl-mail-setup-hook)))
4646 (defun wl-summary-target-mark-reply-with-citation (&optional arg)
4648 (let ((mlist (nreverse wl-summary-buffer-target-mark-list))
4649 (summary-buf (current-buffer))
4650 change-major-mode-hook
4653 (wl-summary-jump-to-msg (car mlist))
4654 (wl-summary-reply arg t)
4655 (goto-char (point-max))
4656 (setq start-point (point-marker))
4657 (setq draft-buf (current-buffer))
4658 (save-window-excursion
4660 (set-buffer summary-buf)
4661 (delete-other-windows)
4662 (wl-summary-jump-to-msg (car mlist))
4663 (wl-summary-redisplay)
4664 (set-buffer draft-buf)
4665 (goto-char (point-max))
4666 (wl-draft-yank-original)
4667 (setq mlist (cdr mlist)))
4668 (goto-char start-point)
4670 (set-buffer summary-buf)
4671 (wl-summary-delete-all-temp-marks)))
4672 (run-hooks 'wl-mail-setup-hook)))
4674 (defun wl-summary-reply-with-citation (&optional arg)
4676 (when (wl-summary-reply arg t)
4677 (goto-char (point-max))
4678 (wl-draft-yank-original)
4679 (run-hooks 'wl-mail-setup-hook)))
4681 (defun wl-summary-jump-to-msg-by-message-id (&optional id)
4683 (let* ((original (wl-summary-message-number))
4684 (msgid (elmo-string (or id (read-from-minibuffer "Message-ID: "))))
4685 (number-alist (elmo-msgdb-get-number-alist (wl-summary-buffer-msgdb)))
4688 (format "No message with id \"%s\" in the folder." msgid)))
4689 (if (setq msg (car (rassoc msgid number-alist)))
4690 ;;; (wl-summary-jump-to-msg-internal
4691 ;;; (wl-summary-buffer-folder-name) msg 'no-sync)
4693 (wl-thread-jump-to-msg msg)
4696 (if (and elmo-use-database
4699 "No message with id \"%s\" in the database." msgid))
4700 (setq otherfld (elmo-database-msgid-get msgid)))
4701 (if (cdr (wl-summary-jump-to-msg-internal
4702 (car otherfld) (nth 1 otherfld) 'no-sync))
4704 ;; Back to original.
4705 (wl-summary-jump-to-msg-internal
4706 (wl-summary-buffer-folder-name) original 'no-sync))
4707 (cond ((eq wl-summary-search-via-nntp 'confirm)
4708 (require 'elmo-nntp)
4709 (message "Search message in nntp server \"%s\" <y/n/s(elect)>?"
4710 elmo-nntp-default-server)
4711 (setq schar (read-char))
4712 (cond ((eq schar ?y)
4713 (wl-summary-jump-to-msg-by-message-id-via-nntp msgid))
4715 (wl-summary-jump-to-msg-by-message-id-via-nntp
4717 (read-from-minibuffer "NNTP Server: ")))
4721 (wl-summary-search-via-nntp
4722 (wl-summary-jump-to-msg-by-message-id-via-nntp msgid))
4727 (defun wl-summary-jump-to-msg-by-message-id-via-nntp (&optional id server-spec)
4729 (let* ((msgid (elmo-string (or id (read-from-minibuffer "Message-ID: "))))
4730 newsgroups folder ret
4731 user server port type spec)
4733 (if (string-match "^-" server-spec)
4734 (setq spec (wl-folder-get-elmo-folder server-spec)
4735 user (elmo-net-folder-user-internal spec)
4736 server (elmo-net-folder-server-internal spec)
4737 port (elmo-net-folder-port-internal spec)
4738 type (elmo-net-folder-stream-type-internal spec))
4739 (setq server server-spec)))
4740 (when (setq ret (elmo-nntp-get-newsgroup-by-msgid
4742 (or server elmo-nntp-default-server)
4743 (or user elmo-nntp-default-user)
4744 (or port elmo-nntp-default-port)
4745 (or type elmo-nntp-default-stream-type)))
4746 (setq newsgroups (elmo-nntp-parse-newsgroups ret))
4747 (setq folder (concat "-" (car newsgroups)
4748 (elmo-nntp-folder-postfix user server port type)))
4751 (if (wl-folder-entity-exists-p (car newsgroups)
4752 wl-folder-newsgroups-hashtb)
4754 (setq folder (concat "-" (car newsgroups)
4755 (elmo-nntp-folder-postfix
4756 user server port type)))))
4757 (setq newsgroups (cdr newsgroups)))))
4759 (wl-summary-jump-to-msg-internal folder nil 'update msgid)
4760 (message "No message id \"%s\" in nntp server \"%s\"."
4761 msgid (or server elmo-nntp-default-server))
4764 (defun wl-summary-jump-to-msg-internal (folder msg scan-type &optional msgid)
4765 (let (wl-auto-select-first entity)
4766 (if (or (string= folder (wl-summary-buffer-folder-name))
4769 "Message was found in the folder \"%s\". Jump to it? "
4773 (wl-summary-goto-folder-subr
4774 folder scan-type nil nil t)
4778 (elmo-msgdb-get-number-alist
4779 (wl-summary-buffer-msgdb))))))
4780 (setq entity (wl-folder-search-entity-by-name folder
4784 (wl-folder-set-current-entity-id
4785 (wl-folder-get-entity-id entity))))
4787 (message "Message was not found currently in this folder.")
4788 (setq msg (and (wl-thread-jump-to-msg msg) msg)))
4789 (cons folder msg)))))
4791 (defun wl-summary-jump-to-parent-message (arg)
4793 (let ((cur-buf (current-buffer))
4794 (number (wl-summary-message-number))
4795 (regexp "\\(<[^<>]*>\\)[ \t]*$")
4797 msg-id msg-num ref-list ref irt)
4799 (message "No message.")
4800 (when (eq wl-summary-buffer-view 'thread)
4801 (cond ((and arg (not (numberp arg)))
4803 (wl-thread-entity-get-number
4804 (wl-thread-entity-get-top-entity
4805 (wl-thread-get-entity number)))))
4806 ((and arg (numberp arg))
4808 (setq msg-num number)
4811 (wl-thread-entity-get-number
4812 (wl-thread-entity-get-parent-entity
4813 (wl-thread-get-entity msg-num))))
4816 (wl-thread-entity-get-number
4817 (wl-thread-entity-get-parent-entity
4818 (wl-thread-get-entity number)))))))
4819 (when (null msg-num)
4820 (wl-summary-set-message-buffer-or-redisplay)
4821 (set-buffer (wl-message-get-original-buffer))
4822 (message "Searching parent message...")
4823 (setq ref (std11-field-body "References")
4824 irt (std11-field-body "In-Reply-To"))
4826 ((and arg (not (numberp arg)) ref (not (string= ref ""))
4827 (string-match regexp ref))
4828 ;; The first message of the thread.
4829 (setq msg-id (wl-match-string 1 ref)))
4830 ;; "In-Reply-To:" has only one msg-id.
4831 ((and (null arg) irt (not (string= irt ""))
4832 (string-match regexp irt))
4833 (setq msg-id (wl-match-string 1 irt)))
4834 ((and (or (null arg) (numberp arg)) ref (not (string= ref ""))
4835 (string-match regexp ref))
4836 ;; "^" searching parent, "C-u 2 ^" looking for grandparent.
4837 (while (string-match regexp ref)
4840 (wl-match-string 1 ref))
4842 (setq ref (substring ref (match-end 0)))
4845 (if (null arg) (nth 0 ref-list) ;; previous
4846 (if (<= arg i) (nth (1- arg) ref-list)
4847 (nth i ref-list)))))))
4848 (set-buffer cur-buf)
4849 (cond ((and (null msg-id) (null msg-num))
4850 (message "No parent message!")
4852 ((and msg-id (wl-summary-jump-to-msg-by-message-id msg-id))
4853 (wl-summary-redisplay)
4854 (message "Searching parent message...done")
4856 ((and msg-num (wl-summary-jump-to-msg msg-num))
4857 (wl-summary-redisplay)
4858 (message "Searching parent message...done")
4861 (message "Parent message was not found.")
4864 (defun wl-summary-reply (&optional arg without-setup-hook)
4865 "Reply to current message. Default is \"wide\" reply.
4866 Reply to author if invoked with ARG."
4868 (let ((folder wl-summary-buffer-elmo-folder)
4869 (number (wl-summary-message-number))
4870 (summary-buf (current-buffer))
4874 (wl-summary-redisplay-internal folder number))
4875 (setq mes-buf wl-message-buffer)
4876 (wl-message-select-buffer wl-message-buffer)
4877 (set-buffer mes-buf)
4878 (goto-char (point-min))
4879 (unless wl-draft-use-frame
4880 (split-window-vertically)
4882 (when (setq mes-buf (wl-message-get-original-buffer))
4883 (wl-draft-reply mes-buf arg summary-buf)
4884 (unless without-setup-hook
4885 (run-hooks 'wl-mail-setup-hook)))
4888 (defun wl-summary-write ()
4889 "Write a new draft from Summary."
4891 (wl-draft nil nil nil nil nil
4892 nil nil nil nil nil nil (current-buffer)
4893 nil (wl-summary-buffer-folder-name))
4894 (run-hooks 'wl-mail-setup-hook)
4895 (mail-position-on-field "To"))
4897 (defvar wl-summary-write-current-folder-functions
4898 '(wl-folder-get-newsgroups
4899 wl-folder-guess-mailing-list-by-refile-rule
4900 wl-folder-guess-mailing-list-by-folder-name)
4901 "Newsgroups or Mailing List address guess functions list.
4902 Call from `wl-summary-write-current-folder'.
4903 When guess function return nil, challenge next guess-function.")
4905 (defun wl-summary-write-current-folder (&optional folder)
4906 "Write message to current FOLDER's newsgroup or mailing-list.
4907 Use function list is `wl-summary-write-current-folder-functions'."
4909 ;; default FOLDER is current buffer folder
4910 (setq folder (or folder (wl-summary-buffer-folder-name)))
4911 (let ((func-list wl-summary-write-current-folder-functions)
4912 guess-list guess-func)
4914 (setq guess-list (funcall (car func-list) folder))
4915 (if (null guess-list)
4916 (setq func-list (cdr func-list))
4917 (setq guess-func (car func-list))
4918 (setq func-list nil)))
4919 (when (null guess-func)
4920 (error "Can't guess by folder %s" folder))
4921 (unless (or (stringp (nth 0 guess-list))
4922 (stringp (nth 1 guess-list))
4923 (stringp (nth 2 guess-list)))
4924 (error "Invalid value return guess function `%s'"
4925 (symbol-name guess-func)))
4926 (wl-draft (nth 0 guess-list) nil nil ; To:
4927 (nth 1 guess-list) nil ; Cc:
4928 (nth 2 guess-list) ; Newsgroups:
4929 nil nil nil nil nil nil nil
4931 (run-hooks 'wl-mail-setup-hook)
4932 (mail-position-on-field "Subject")))
4934 (defun wl-summary-forward (&optional without-setup-hook)
4937 (let ((folder wl-summary-buffer-elmo-folder)
4938 (number (wl-summary-message-number))
4939 (summary-buf (current-buffer))
4940 (wl-draft-forward t)
4944 (message "No message.")
4945 (if (and (elmo-message-use-cache-p folder number)
4946 (eq (elmo-file-cache-status
4947 (elmo-file-cache-get
4948 (elmo-message-field folder number 'message-id)))
4951 (wl-summary-redisplay-internal nil nil 'force-reload)
4952 (wl-summary-redisplay-internal folder number))
4953 (setq mes-buf wl-message-buffer)
4954 (wl-message-select-buffer mes-buf)
4955 (unless wl-draft-use-frame
4956 (split-window-vertically)
4958 ;; get original subject.
4961 (set-buffer summary-buf)
4963 (or (elmo-message-field folder number 'subject) ""))))
4964 (set-buffer mes-buf)
4965 (wl-draft-forward subject summary-buf)
4966 (unless without-setup-hook
4967 (run-hooks 'wl-mail-setup-hook)))))
4969 (defun wl-summary-click (e)
4974 (defun wl-summary-read ()
4975 "Proceed reading message in the summary buffer."
4977 (let ((cur-buf (current-buffer)))
4978 (wl-summary-toggle-disp-msg 'on)
4979 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
4980 (set-buffer cur-buf)
4981 (if (wl-message-next-page)
4982 (wl-summary-down t)))))
4984 (defun wl-summary-prev (&optional interactive)
4987 (if wl-summary-move-direction-toggle
4988 (setq wl-summary-move-direction-downward nil))
4989 (let ((skip-mark-regexp (mapconcat
4991 wl-summary-skip-mark-list ""))
4992 goto-next regex-list regex next-entity finfo)
4994 (if (elmo-folder-plugged-p wl-summary-buffer-elmo-folder)
4995 (setq regex (format "^%s[^%s]"
4996 wl-summary-buffer-number-regexp
4998 (setq regex (format "^%s[^%s]\\(%s\\|%s\\| \\)"
4999 wl-summary-buffer-number-regexp
5001 (regexp-quote wl-summary-unread-cached-mark)
5002 (regexp-quote wl-summary-important-mark))))
5003 (unless (re-search-backward regex nil t)
5008 (if wl-summary-buffer-disp-msg
5009 (wl-summary-redisplay)))
5010 (if (or interactive (interactive-p))
5011 (if wl-summary-buffer-prev-folder-function
5012 (funcall wl-summary-buffer-prev-folder-function)
5013 (when wl-auto-select-next
5014 (setq next-entity (wl-summary-get-prev-folder))
5016 (setq finfo (wl-folder-get-entity-info next-entity))))
5018 '(lambda () (wl-summary-next-folder-or-exit next-entity))
5020 "No more messages. Type SPC to go to %s."
5021 (wl-summary-entity-info-msg next-entity finfo))))))))
5023 (defun wl-summary-next (&optional interactive)
5026 (if wl-summary-move-direction-toggle
5027 (setq wl-summary-move-direction-downward t))
5028 (let ((skip-mark-regexp (mapconcat
5030 wl-summary-skip-mark-list ""))
5031 goto-next regex regex-list next-entity finfo)
5033 (if (elmo-folder-plugged-p wl-summary-buffer-elmo-folder)
5034 (setq regex (format "^%s[^%s]"
5035 wl-summary-buffer-number-regexp
5037 (setq regex (format "^%s[^%s]\\(%s\\|%s\\| \\)"
5038 wl-summary-buffer-number-regexp
5040 (regexp-quote wl-summary-unread-cached-mark)
5041 (regexp-quote wl-summary-important-mark))))
5042 (unless (re-search-forward regex nil t)
5047 (if wl-summary-buffer-disp-msg
5048 (wl-summary-redisplay))
5049 (if (or interactive (interactive-p))
5050 (if wl-summary-buffer-next-folder-function
5051 (funcall wl-summary-buffer-next-folder-function)
5052 (when wl-auto-select-next
5053 (setq next-entity (wl-summary-get-next-folder))
5055 (setq finfo (wl-folder-get-entity-info next-entity))))
5057 '(lambda () (wl-summary-next-folder-or-exit next-entity))
5059 "No more messages. Type SPC to go to %s."
5060 (wl-summary-entity-info-msg next-entity finfo))))))))
5062 (defun wl-summary-up (&optional interactive skip-no-unread)
5065 (if wl-summary-move-direction-toggle
5066 (setq wl-summary-move-direction-downward nil))
5067 (if (wl-summary-cursor-up)
5068 (if wl-summary-buffer-disp-msg
5069 (wl-summary-redisplay))
5072 (if wl-summary-buffer-prev-folder-function
5073 (funcall wl-summary-buffer-prev-folder-function)
5074 (let (next-entity finfo)
5075 (when wl-auto-select-next
5077 (setq next-entity (wl-summary-get-prev-unread-folder))
5079 (setq finfo (wl-folder-get-entity-info next-entity)))))
5080 (if (and skip-no-unread
5081 (eq wl-auto-select-next 'skip-no-unread))
5082 (wl-summary-next-folder-or-exit next-entity t)
5084 '(lambda () (wl-summary-next-folder-or-exit next-entity t))
5086 "No more unread messages. Type SPC to go to %s."
5087 (wl-summary-entity-info-msg next-entity finfo)))))))))
5089 (defun wl-summary-get-prev-folder ()
5090 (let ((folder-buf (get-buffer wl-folder-buffer-name))
5093 (setq cur-id (save-excursion (set-buffer folder-buf)
5094 wl-folder-buffer-cur-entity-id))
5095 (wl-folder-get-prev-folder cur-id))))
5097 (defun wl-summary-get-next-folder ()
5098 (let ((folder-buf (get-buffer wl-folder-buffer-name))
5101 (setq cur-id (save-excursion (set-buffer folder-buf)
5102 wl-folder-buffer-cur-entity-id))
5103 (wl-folder-get-next-folder cur-id))))
5105 (defun wl-summary-get-next-unread-folder ()
5106 (let ((folder-buf (get-buffer wl-folder-buffer-name))
5109 (setq cur-id (save-excursion (set-buffer folder-buf)
5110 wl-folder-buffer-cur-entity-id))
5111 (wl-folder-get-next-folder cur-id 'unread))))
5113 (defun wl-summary-get-prev-unread-folder ()
5114 (let ((folder-buf (get-buffer wl-folder-buffer-name))
5117 (setq cur-id (save-excursion (set-buffer folder-buf)
5118 wl-folder-buffer-cur-entity-id))
5119 (wl-folder-get-prev-folder cur-id 'unread))))
5121 (defun wl-summary-down (&optional interactive skip-no-unread)
5123 (if wl-summary-move-direction-toggle
5124 (setq wl-summary-move-direction-downward t))
5125 (if (wl-summary-cursor-down)
5126 (if wl-summary-buffer-disp-msg
5127 (wl-summary-redisplay))
5130 (if wl-summary-buffer-next-folder-function
5131 (funcall wl-summary-buffer-next-folder-function)
5132 (let (next-entity finfo)
5133 (when wl-auto-select-next
5134 (setq next-entity (wl-summary-get-next-unread-folder)))
5136 (setq finfo (wl-folder-get-entity-info next-entity)))
5137 (if (and skip-no-unread
5138 (eq wl-auto-select-next 'skip-no-unread))
5139 (wl-summary-next-folder-or-exit next-entity)
5141 '(lambda () (wl-summary-next-folder-or-exit next-entity))
5143 "No more unread messages. Type SPC to go to %s."
5144 (wl-summary-entity-info-msg next-entity finfo)))))))))
5146 (defun wl-summary-goto-last-displayed-msg ()
5148 (unless wl-summary-buffer-last-displayed-msg
5149 (setq wl-summary-buffer-last-displayed-msg
5150 wl-summary-buffer-current-msg))
5151 (if wl-summary-buffer-last-displayed-msg
5153 (wl-summary-jump-to-msg wl-summary-buffer-last-displayed-msg)
5154 (if wl-summary-buffer-disp-msg
5155 (wl-summary-redisplay)))
5156 (message "No last message.")))
5158 (defun wl-summary-redisplay (&optional arg)
5161 (wl-summary-no-mime-p wl-summary-buffer-elmo-folder))
5162 (wl-summary-redisplay-no-mime)
5163 (wl-summary-redisplay-internal nil nil arg)))
5165 (defsubst wl-summary-redisplay-internal (&optional folder number force-reload)
5167 (let* ((msgdb (wl-summary-buffer-msgdb))
5168 (folder (or folder wl-summary-buffer-elmo-folder))
5169 (num (or number (wl-summary-message-number)))
5170 (wl-mime-charset wl-summary-buffer-mime-charset)
5171 (default-mime-charset wl-summary-buffer-mime-charset)
5172 fld-buf fld-win thr-entity)
5173 (if (and wl-thread-open-reading-thread
5174 (eq wl-summary-buffer-view 'thread)
5175 (not (wl-thread-entity-get-opened
5176 (setq thr-entity (wl-thread-get-entity
5178 (wl-thread-entity-get-children thr-entity))
5179 (wl-thread-force-open))
5182 (setq wl-summary-buffer-disp-msg t)
5183 (setq wl-summary-buffer-last-displayed-msg
5184 wl-summary-buffer-current-msg)
5185 ;; hide folder window
5186 (if (and (not wl-stay-folder-window)
5187 (setq fld-buf (get-buffer wl-folder-buffer-name)))
5188 (if (setq fld-win (get-buffer-window fld-buf))
5189 (delete-window fld-win)))
5190 (setq wl-current-summary-buffer (current-buffer))
5191 (wl-summary-mark-as-read
5193 ;; not fetched, then change server-mark.
5194 (if (wl-message-redisplay folder num 'mime
5196 (string= (elmo-folder-name-internal
5200 ;; plugged, then leave server-mark.
5203 (elmo-folder-local-p
5204 wl-summary-buffer-elmo-folder))
5205 (elmo-folder-plugged-p
5206 wl-summary-buffer-elmo-folder))
5210 'cached ; cached by reading.
5212 (setq wl-summary-buffer-current-msg num)
5213 (when wl-summary-recenter
5214 (recenter (/ (- (window-height) 2) 2))
5215 (if (not wl-summary-indent-length-limit)
5216 (wl-horizontal-recenter)))
5217 (wl-highlight-summary-displaying)
5218 (wl-message-buffer-prefetch-next folder num (current-buffer)
5219 wl-summary-buffer-mime-charset)
5220 (run-hooks 'wl-summary-redisplay-hook))
5221 (message "No message to display."))))
5223 (defun wl-summary-redisplay-no-mime (&optional folder number)
5225 (let* ((fld (or folder wl-summary-buffer-elmo-folder))
5226 (num (or number (wl-summary-message-number)))
5230 (setq wl-summary-buffer-disp-msg t)
5231 (setq wl-summary-buffer-last-displayed-msg
5232 wl-summary-buffer-current-msg)
5233 (setq wl-current-summary-buffer (current-buffer))
5234 (wl-message-redisplay fld num 'as-is
5235 (string= (elmo-folder-name-internal fld)
5237 (wl-summary-mark-as-read nil nil t)
5238 (setq wl-summary-buffer-current-msg num)
5239 (when wl-summary-recenter
5240 (recenter (/ (- (window-height) 2) 2))
5241 (if (not wl-summary-indent-length-limit)
5242 (wl-horizontal-recenter)))
5243 (wl-highlight-summary-displaying)
5244 (run-hooks 'wl-summary-redisplay-hook))
5245 (message "No message to display.")
5246 (wl-ask-folder 'wl-summary-exit
5247 "No more messages. Type SPC to go to folder mode."))))
5249 (defun wl-summary-redisplay-all-header (&optional folder number)
5251 (let* ((fld (or folder wl-summary-buffer-elmo-folder))
5252 (num (or number (wl-summary-message-number)))
5253 (wl-mime-charset wl-summary-buffer-mime-charset)
5254 (default-mime-charset wl-summary-buffer-mime-charset))
5257 (setq wl-summary-buffer-disp-msg t)
5258 (setq wl-summary-buffer-last-displayed-msg
5259 wl-summary-buffer-current-msg)
5260 (setq wl-current-summary-buffer (current-buffer))
5261 (if (wl-message-redisplay fld num 'all-header
5262 (string= (elmo-folder-name-internal fld)
5264 (wl-summary-mark-as-read nil nil t))
5265 (setq wl-summary-buffer-current-msg num)
5266 (when wl-summary-recenter
5267 (recenter (/ (- (window-height) 2) 2))
5268 (if (not wl-summary-indent-length-limit)
5269 (wl-horizontal-recenter)))
5270 (wl-highlight-summary-displaying)
5271 (run-hooks 'wl-summary-redisplay-hook))
5272 (message "No message to display."))))
5274 (defun wl-summary-jump-to-current-message ()
5276 (let (message-buf message-win)
5277 (if (setq message-buf wl-message-buffer)
5278 (if (setq message-win (get-buffer-window message-buf))
5279 (select-window message-win)
5280 (wl-message-select-buffer wl-message-buffer))
5281 (wl-summary-redisplay)
5282 (wl-message-select-buffer wl-message-buffer))))
5284 (defun wl-summary-cancel-message ()
5285 "Cancel an article on news."
5287 (if (null (wl-summary-message-number))
5288 (message "No message.")
5289 (let ((summary-buf (current-buffer))
5291 (wl-summary-set-message-buffer-or-redisplay)
5292 (if (setq message-buf (wl-message-get-original-buffer))
5293 (set-buffer message-buf))
5294 (unless (wl-message-news-p)
5295 (set-buffer summary-buf)
5296 (if (and (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
5298 (y-or-n-p "Cannot get Newsgroups. Fetch again? "))
5300 (wl-summary-redisplay t)
5301 (wl-summary-supersedes-message))
5302 (error "This is not a news article; supersedes is impossible")))
5303 (when (yes-or-no-p "Do you really want to cancel this article? ")
5304 (let (from newsgroups message-id distribution buf)
5306 (setq from (std11-field-body "from")
5307 newsgroups (std11-field-body "newsgroups")
5308 message-id (std11-field-body "message-id")
5309 distribution (std11-field-body "distribution"))
5310 ;; Make sure that this article was written by the user.
5311 (unless (wl-address-user-mail-address-p
5312 (wl-address-header-extract-address
5313 (car (wl-parse-addresses from))))
5314 (error "This article is not yours"))
5315 ;; Make control message.
5316 (setq buf (set-buffer (get-buffer-create " *message cancel*")))
5317 (setq wl-draft-buffer-cur-summary-buffer summary-buf)
5318 (buffer-disable-undo (current-buffer))
5320 (insert "Newsgroups: " newsgroups "\n"
5321 "From: " (wl-address-header-extract-address
5323 "Subject: cmsg cancel " message-id "\n"
5324 "Control: cancel " message-id "\n"
5326 (concat "Distribution: " distribution "\n")
5328 mail-header-separator "\n"
5329 wl-summary-cancel-message)
5330 (message "Canceling your message...")
5331 (wl-draft-raw-send t t) ; kill when done, force-pre-hooks.
5332 (message "Canceling your message...done")))))))
5334 (defun wl-summary-supersedes-message ()
5335 "Supersede current message."
5337 (let ((summary-buf (current-buffer))
5339 (wl-summary-set-message-buffer-or-redisplay)
5340 (if (setq message-buf (wl-message-get-original-buffer))
5341 (set-buffer message-buf))
5342 (unless (wl-message-news-p)
5343 (set-buffer summary-buf)
5344 (if (and (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
5346 (y-or-n-p "Cannot get Newsgroups. Fetch again? "))
5348 (wl-summary-redisplay t)
5349 (wl-summary-supersedes-message))
5350 (error "This is not a news article; supersedes is impossible")))
5352 (setq from (std11-field-body "from"))
5353 ;; Make sure that this article was written by the user.
5354 (unless (wl-address-user-mail-address-p
5355 (wl-address-header-extract-address
5356 (car (wl-parse-addresses from))))
5357 (error "This article is not yours"))
5358 (let* ((message-id (std11-field-body "message-id"))
5359 (followup-to (std11-field-body "followup-to"))
5360 (mail-default-headers
5361 (concat mail-default-headers
5362 "Supersedes: " message-id "\n"
5364 (concat "Followup-To: " followup-to "\n")))))
5365 (if message-buf (set-buffer message-buf))
5366 (wl-draft-edit-string (buffer-substring (point-min) (point-max)))))))
5368 (defun wl-summary-save (&optional arg wl-save-dir)
5371 (num (wl-summary-message-number)))
5372 (if (null wl-save-dir)
5373 (setq wl-save-dir wl-temporary-file-directory))
5376 (setq filename (expand-file-name
5380 (null (file-exists-p filename))))
5382 (read-file-name "Save to file: " filename)))
5384 (wl-summary-set-message-buffer-or-redisplay)
5385 (set-buffer (wl-message-get-original-buffer))
5386 (if (and (null arg) (file-exists-p filename))
5387 (if (y-or-n-p "File already exists. override it? ")
5388 (write-region (point-min) (point-max) filename))
5389 (write-region (point-min) (point-max) filename)))
5390 (message "No message to save."))
5393 (defun wl-summary-save-region (beg end)
5397 (narrow-to-region beg end)
5398 (goto-char (point-min))
5400 (wl-read-directory-name "Save to directory: "
5401 wl-temporary-file-directory)))
5402 (if (null (file-exists-p wl-save-dir))
5403 (make-directory wl-save-dir))
5404 (if (eq wl-summary-buffer-view 'thread)
5407 (let* ((number (wl-summary-message-number))
5408 (entity (wl-thread-get-entity number)))
5409 (if (wl-thread-entity-get-opened entity)
5410 (wl-summary-save t wl-save-dir)
5412 (wl-summary-save t wl-save-dir))
5415 (wl-summary-save t wl-save-dir)
5416 (forward-line 1)))))))
5418 ;; mew-summary-pipe-message()
5419 (defun wl-summary-pipe-message (prefix command)
5420 "Send this message via pipe."
5421 (interactive (list current-prefix-arg nil))
5422 (if (null (wl-summary-message-number))
5423 (message "No message.")
5424 (setq command (read-string "Shell command on message: "
5425 wl-summary-shell-command-last))
5426 (if (y-or-n-p "Send this message to pipe? ")
5428 (wl-summary-set-message-buffer-or-redisplay)
5429 (set-buffer (wl-message-get-original-buffer))
5430 (if (string= command "")
5431 (setq command wl-summary-shell-command-last))
5432 (goto-char (point-min)) ; perhaps this line won't be necessary
5434 (search-forward "\n\n"))
5435 (shell-command-on-region (point) (point-max) command nil)
5436 (setq wl-summary-shell-command-last command)))))
5438 (defun wl-summary-print-message (&optional arg)
5440 (if (null (wl-summary-message-number))
5441 (message "No message.")
5443 (wl-summary-set-message-buffer-or-redisplay)
5444 (if (or (not (interactive-p))
5445 (y-or-n-p "Print ok? "))
5447 (let ((buffer (generate-new-buffer " *print*")))
5448 (copy-to-buffer buffer (point-min) (point-max))
5450 (funcall wl-print-buffer-function)
5451 (kill-buffer buffer)))
5454 (defun wl-summary-print-message-with-ps-print (&optional filename)
5456 (if (null (wl-summary-message-number))
5457 (message "No message.")
5458 (setq filename (ps-print-preprint current-prefix-arg))
5459 (if (or (not (interactive-p))
5460 (y-or-n-p "Print ok? "))
5461 (let ((summary-buffer (current-buffer))
5464 (wl-summary-set-message-buffer-or-redisplay)
5465 ;; (wl-summary-redisplay-internal)
5466 (let* ((buffer (generate-new-buffer " *print*"))
5468 (set-buffer summary-buffer)
5470 (wl-summary-message-number)
5471 (elmo-msgdb-get-number-alist
5472 (wl-summary-buffer-msgdb))))
5473 (elmo-msgdb-get-overview
5474 (wl-summary-buffer-msgdb)))))
5477 (or (elmo-msgdb-overview-entity-get-subject entity)
5481 (or (elmo-msgdb-overview-entity-get-from entity) "")))
5484 (or (elmo-msgdb-overview-entity-get-date entity) ""))))
5485 (run-hooks 'wl-ps-preprint-hook)
5486 (set-buffer wl-message-buffer)
5487 (copy-to-buffer buffer (point-min) (point-max))
5490 (let ((ps-left-header
5491 (list (concat "(" wl-ps-subject ")")
5492 (concat "(" wl-ps-from ")")))
5494 (list "/pagenumberstring load"
5495 (concat "(" wl-ps-date ")"))))
5496 (run-hooks 'wl-ps-print-hook)
5497 (funcall wl-ps-print-buffer-function filename))
5498 (kill-buffer buffer)))))
5501 (if (featurep 'ps-print) ; ps-print is available.
5502 (fset 'wl-summary-print-message 'wl-summary-print-message-with-ps-print))
5504 (defun wl-summary-folder-info-update ()
5505 (let ((folder (elmo-string (wl-summary-buffer-folder-name)))
5506 (num-db (elmo-msgdb-get-number-alist
5507 (wl-summary-buffer-msgdb))))
5508 (wl-folder-set-folder-updated folder
5510 (+ wl-summary-buffer-unread-count
5511 wl-summary-buffer-new-count)
5514 (defun wl-summary-get-original-buffer ()
5515 "Get original buffer for the current summary."
5517 (wl-summary-set-message-buffer-or-redisplay)
5518 (wl-message-get-original-buffer)))
5520 (defun wl-summary-pack-number (&optional arg)
5522 (elmo-folder-pack-numbers wl-summary-buffer-elmo-folder)
5523 (let (wl-use-scoring)
5524 (wl-summary-rescan)))
5526 (defun wl-summary-target-mark-uudecode ()
5528 (let ((mlist (reverse wl-summary-buffer-target-mark-list))
5529 (summary-buf (current-buffer))
5530 (tmp-buf (get-buffer-create "*WL UUENCODE*"))
5531 orig-buf i k filename rc errmsg)
5533 (setq k (length mlist))
5534 (set-buffer tmp-buf)
5536 (save-window-excursion
5538 (set-buffer summary-buf)
5539 (wl-summary-jump-to-msg (car mlist))
5540 (wl-summary-redisplay)
5541 (set-buffer (setq orig-buf (wl-summary-get-original-buffer)))
5542 (goto-char (point-min))
5543 (cond ((= i 1) ; first
5544 (if (setq filename (wl-message-uu-substring
5548 (error "Can't find begin line")))
5550 (wl-message-uu-substring orig-buf tmp-buf))
5552 (wl-message-uu-substring orig-buf tmp-buf nil t)))
5554 (setq mlist (cdr mlist)))
5555 (set-buffer tmp-buf)
5556 (message "Exec %s..." wl-prog-uudecode)
5558 (let ((decode-dir wl-temporary-file-directory))
5559 (if (not wl-prog-uudecode-no-stdout-option)
5560 (setq filename (read-file-name "Save to file: "
5562 (elmo-safe-filename filename)
5563 wl-temporary-file-directory)))
5565 (wl-read-directory-name "Save to directory: "
5566 wl-temporary-file-directory))
5567 (setq filename (expand-file-name filename decode-dir)))
5568 (if (file-exists-p filename)
5569 (or (yes-or-no-p (format "File %s exists. Save anyway? "
5572 (elmo-bind-directory
5576 (apply 'call-process-region (point-min) (point-max)
5577 wl-prog-uudecode t (current-buffer) nil
5578 wl-prog-uudecode-arg))))
5579 (when (not (= 0 rc))
5580 (setq errmsg (buffer-substring (point-min)(point-max)))
5581 (error "Uudecode error: %s" errmsg))
5582 (if (not wl-prog-uudecode-no-stdout-option)
5583 (let (file-name-handler-alist) ;; void jka-compr
5584 (as-binary-output-file
5585 (write-region (point-min) (point-max)
5586 filename nil 'no-msg))))
5588 (set-buffer summary-buf)
5589 (wl-summary-delete-all-temp-marks))
5590 (if (file-exists-p filename)
5591 (message "Saved as %s" filename)))
5592 (kill-buffer tmp-buf)))))
5595 ;; (defun wl-summary-drop-unsync ()
5596 ;; "Drop all unsync messages."
5598 ;; (if (elmo-folder-pipe-p (wl-summary-buffer-folder-name))
5599 ;; (error "You cannot drop unsync messages in this folder"))
5600 ;; (if (or (not (interactive-p))
5601 ;; (y-or-n-p "Drop all unsync messages? "))
5602 ;; (let* ((folder-list (elmo-folder-get-primitive-folder-list
5603 ;; (wl-summary-buffer-folder-name)))
5604 ;; (is-multi (elmo-multi-p (wl-summary-buffer-folder-name)))
5608 ;; (message "Dropping...")
5609 ;; (while folder-list
5610 ;; (setq pair (elmo-folder-message-numbers (car folder-list)))
5611 ;; (when is-multi ;; dirty hack...
5613 ;; (setcar pair (+ (* multi-num elmo-multi-divide-number)
5615 ;; (elmo-msgdb-set-number-alist
5616 ;; (wl-summary-buffer-msgdb)
5618 ;; (elmo-msgdb-get-number-alist (wl-summary-buffer-msgdb))
5619 ;; (list (cons (car pair) nil))))
5620 ;; (setq sum (+ sum (cdr pair)))
5621 ;; (setq folder-list (cdr folder-list)))
5622 ;; (wl-summary-set-message-modified)
5623 ;; (wl-folder-set-folder-updated (wl-summary-buffer-folder-name)
5625 ;; (+ wl-summary-buffer-unread-count
5626 ;; wl-summary-buffer-new-count)
5628 ;; (message "Dropping...done"))))
5630 (defun wl-summary-default-get-next-msg (msg)
5631 (or (wl-summary-next-message msg
5632 (if wl-summary-move-direction-downward 'down
5635 (cadr (memq msg (if wl-summary-move-direction-downward
5636 wl-summary-buffer-number-list
5637 (reverse wl-summary-buffer-number-list))))))
5639 (defun wl-summary-save-current-message ()
5640 "Save current message for `wl-summary-yank-saved-message'."
5642 (let ((number (wl-summary-message-number)))
5643 (setq wl-summary-buffer-saved-message number)
5644 (and number (message "No: %s is saved." number))))
5646 (defun wl-summary-yank-saved-message ()
5647 "Set current message as a parent of the saved message."
5649 (if wl-summary-buffer-saved-message
5650 (let ((number (wl-summary-message-number)))
5651 (if (eq wl-summary-buffer-saved-message number)
5652 (message "Cannot set itself as a parent.")
5654 (wl-thread-jump-to-msg wl-summary-buffer-saved-message)
5655 (wl-thread-set-parent number)
5656 (wl-summary-set-thread-modified))
5657 (setq wl-summary-buffer-saved-message nil)))
5658 (message "There's no saved message.")))
5661 (product-provide (provide 'wl-summary) (require 'wl-version))
5663 ;;; wl-summary.el ends here