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)
63 (defvar elmo-global-flag-list)
65 (defvar wl-summary-buffer-name "Summary")
66 (defvar wl-summary-mode-map nil)
67 (defvar wl-current-summary-buffer nil)
69 (defvar wl-summary-buffer-elmo-folder nil)
71 (defmacro wl-summary-buffer-folder-name ()
72 (` (and wl-summary-buffer-elmo-folder
73 (elmo-folder-name-internal wl-summary-buffer-elmo-folder))))
75 (defvar wl-summary-buffer-disp-msg nil)
76 (defvar wl-summary-buffer-disp-folder nil)
77 (defvar wl-summary-buffer-temp-mark-list nil)
78 (defvar wl-summary-buffer-last-displayed-msg nil)
79 (defvar wl-summary-buffer-current-msg nil)
80 (defvar wl-summary-buffer-unread-count 0)
81 (defvar wl-summary-buffer-new-count 0)
82 (defvar wl-summary-buffer-answered-count 0)
83 (defvar wl-summary-buffer-mime-charset nil)
84 (defvar wl-summary-buffer-weekday-name-lang nil)
85 (defvar wl-summary-buffer-thread-indent-set-alist nil)
86 (defvar wl-summary-buffer-view nil)
87 (defvar wl-summary-buffer-message-modified nil)
88 (defvar wl-summary-buffer-thread-modified nil)
90 (defvar wl-summary-buffer-number-column nil)
91 (defvar wl-summary-buffer-temp-mark-column nil)
92 (defvar wl-summary-buffer-persistent-mark-column nil)
94 (defvar wl-summary-buffer-unsync-mark-number-list nil)
96 (defvar wl-summary-buffer-persistent nil)
97 (defvar wl-summary-buffer-thread-nodes nil)
98 (defvar wl-summary-buffer-target-mark-list nil)
99 (defvar wl-summary-buffer-prev-refile-destination nil)
100 (defvar wl-summary-buffer-saved-message nil)
101 (defvar wl-summary-buffer-prev-folder-function nil)
102 (defvar wl-summary-buffer-next-folder-function nil)
103 (defvar wl-summary-buffer-exit-function nil)
104 (defvar wl-summary-buffer-next-message-function nil)
105 (defvar wl-summary-buffer-window-scroll-functions nil)
106 (defvar wl-summary-buffer-number-list nil)
107 (defvar wl-summary-buffer-folder-name nil)
108 (defvar wl-summary-buffer-line-formatter nil)
109 (defvar wl-summary-buffer-line-format nil)
110 (defvar wl-summary-buffer-mode-line-formatter nil)
111 (defvar wl-summary-buffer-mode-line nil)
113 (defvar wl-thread-indent-level-internal nil)
114 (defvar wl-thread-have-younger-brother-str-internal nil)
115 (defvar wl-thread-youngest-child-str-internal nil)
116 (defvar wl-thread-vertical-str-internal nil)
117 (defvar wl-thread-horizontal-str-internal nil)
118 (defvar wl-thread-space-str-internal nil)
119 (defvar wl-summary-last-visited-folder nil)
120 (defvar wl-read-folder-history nil)
121 (defvar wl-summary-scored nil)
122 (defvar wl-crosspost-alist-modified nil)
123 (defvar wl-summary-alike-hashtb nil)
124 (defvar wl-summary-search-buf-name " *wl-search-subject*")
125 (defvar wl-summary-delayed-update nil)
126 (defvar wl-summary-search-buf-folder-name nil)
128 (defvar wl-summary-get-petname-function 'wl-address-get-petname-1)
130 (defvar wl-summary-shell-command-last "")
132 (defvar wl-ps-preprint-hook nil)
133 (defvar wl-ps-print-hook nil)
135 (defvar wl-thread-saved-entity-hashtb-internal nil)
137 (make-variable-buffer-local 'wl-summary-buffer-elmo-folder)
138 (make-variable-buffer-local 'wl-summary-search-buf-folder-name)
139 (make-variable-buffer-local 'wl-summary-buffer-disp-msg)
140 (make-variable-buffer-local 'wl-summary-buffer-disp-folder)
141 (make-variable-buffer-local 'wl-summary-buffer-target-mark-list)
142 (make-variable-buffer-local 'wl-summary-buffer-temp-mark-list)
143 (make-variable-buffer-local 'wl-summary-buffer-last-displayed-msg)
144 (make-variable-buffer-local 'wl-summary-buffer-unread-count)
145 (make-variable-buffer-local 'wl-summary-buffer-new-count)
146 (make-variable-buffer-local 'wl-summary-buffer-answered-count)
147 (make-variable-buffer-local 'wl-summary-buffer-mime-charset)
148 (make-variable-buffer-local 'wl-summary-buffer-weekday-name-lang)
149 (make-variable-buffer-local 'wl-summary-buffer-thread-indent-set)
150 (make-variable-buffer-local 'wl-summary-buffer-view)
151 (make-variable-buffer-local 'wl-summary-buffer-message-modified)
152 (make-variable-buffer-local 'wl-summary-buffer-thread-modified)
153 (make-variable-buffer-local 'wl-summary-buffer-number-column)
154 (make-variable-buffer-local 'wl-summary-buffer-temp-mark-column)
155 (make-variable-buffer-local 'wl-summary-buffer-persistent-mark-column)
156 (make-variable-buffer-local 'wl-summary-buffer-unsync-mark-number-list)
157 (make-variable-buffer-local 'wl-summary-buffer-persistent)
158 (make-variable-buffer-local 'wl-summary-buffer-thread-nodes)
159 (make-variable-buffer-local 'wl-summary-buffer-prev-refile-destination)
160 (make-variable-buffer-local 'wl-summary-buffer-saved-message)
161 (make-variable-buffer-local 'wl-summary-scored)
162 (make-variable-buffer-local 'wl-summary-default-score)
163 (make-variable-buffer-local 'wl-summary-move-direction-downward)
164 (make-variable-buffer-local 'wl-summary-important-above)
165 (make-variable-buffer-local 'wl-summary-target-above)
166 (make-variable-buffer-local 'wl-summary-mark-below)
167 (make-variable-buffer-local 'wl-summary-expunge-below)
168 (make-variable-buffer-local 'wl-thread-indent-level-internal)
169 (make-variable-buffer-local 'wl-thread-have-younger-brother-str-internal)
170 (make-variable-buffer-local 'wl-thread-youngest-child-str-internal)
171 (make-variable-buffer-local 'wl-thread-vertical-str-internal)
172 (make-variable-buffer-local 'wl-thread-horizontal-str-internal)
173 (make-variable-buffer-local 'wl-thread-space-str-internal)
174 (make-variable-buffer-local 'wl-summary-buffer-prev-folder-function)
175 (make-variable-buffer-local 'wl-summary-buffer-next-folder-function)
176 (make-variable-buffer-local 'wl-summary-buffer-exit-function)
177 (make-variable-buffer-local 'wl-summary-buffer-next-message-function)
178 (make-variable-buffer-local 'wl-summary-buffer-window-scroll-functions)
179 (make-variable-buffer-local 'wl-summary-buffer-number-list)
180 (make-variable-buffer-local 'wl-summary-buffer-folder-name)
181 (make-variable-buffer-local 'wl-summary-buffer-line-formatter)
182 (make-variable-buffer-local 'wl-summary-buffer-line-format)
183 (make-variable-buffer-local 'wl-summary-buffer-mode-line-formatter)
184 (make-variable-buffer-local 'wl-summary-buffer-mode-line)
187 (defvar wl-thr-indent-string)
188 (defvar wl-thr-children-number)
189 (defvar wl-thr-linked)
190 (defvar wl-message-entity)
191 (defvar wl-parent-message-entity)
192 (defvar wl-temp-mark)
193 (defvar wl-persistent-mark)
195 (defmacro wl-summary-sticky-buffer-name (name)
196 (` (concat wl-summary-buffer-name ":" (, name))))
198 (defun wl-summary-default-subject (subject-string)
199 (if (string-match "^[ \t]*\\[[^:]+[,: ][0-9]+\\][ \t]*" subject-string)
200 (substring subject-string (match-end 0))
203 (defun wl-summary-default-from (from)
204 "Instance of `wl-summary-from-function'.
205 Ordinarily returns the sender name. Returns recipient names if (1)
206 summary's folder name matches with `wl-summary-showto-folder-regexp'
207 and (2) sender address is yours.
209 See also variable `wl-use-petname'."
212 (and (eq major-mode 'wl-summary-mode)
213 (stringp wl-summary-showto-folder-regexp)
214 (string-match wl-summary-showto-folder-regexp
215 (wl-summary-buffer-folder-name))
216 (wl-address-user-mail-address-p from)
218 ((and (setq tos (elmo-message-entity-field
219 wl-message-entity 'to t))
220 (not (string= "" tos)))
230 wl-summary-get-petname-function to)
232 (std11-extract-address-components to))
235 (wl-parse-addresses tos)
237 ((setq ng (elmo-message-entity-field
238 wl-message-entity 'newsgroups))
239 (setq retval (concat "Ng:" ng)))))
241 (setq retval (or (funcall wl-summary-get-petname-function from)
242 (car (std11-extract-address-components from))
247 (defun wl-summary-simple-from (string)
249 (or (funcall wl-summary-get-petname-function string)
250 (car (std11-extract-address-components string))
254 (defvar wl-summary-sort-specs '(number date subject from list-info size))
255 (defvar wl-summary-default-sort-spec 'date)
257 (defvar wl-summary-mode-menu-spec
259 ["Read" wl-summary-read t]
260 ["Prev page" wl-summary-prev-page t]
261 ["Next page" wl-summary-next-page t]
262 ["Top" wl-summary-display-top t]
263 ["Bottom" wl-summary-display-bottom t]
264 ["Prev" wl-summary-prev t]
265 ["Next" wl-summary-next t]
266 ["Up" wl-summary-up t]
267 ["Down" wl-summary-down t]
268 ["Parent message" wl-summary-jump-to-parent-message t]
270 ["Sync" wl-summary-sync t]
271 ["Execute" wl-summary-exec t]
272 ["Go to other folder" wl-summary-goto-folder t]
273 ["Pick" wl-summary-pick t]
274 ["Mark as read all" wl-summary-mark-as-read-all t]
275 ["Unmark all" wl-summary-unmark-all t]
276 ["Toggle display message" wl-summary-toggle-disp-msg t]
277 ["Display folder" wl-summary-toggle-disp-folder t]
278 ["Toggle threading" wl-summary-toggle-thread t]
279 ["Stick" wl-summary-stick t]
281 ["By Number" wl-summary-sort-by-number t]
282 ["By Size" wl-summary-sort-by-size t]
283 ["By Date" wl-summary-sort-by-date t]
284 ["By From" wl-summary-sort-by-from t]
285 ["By Subject" wl-summary-sort-by-subject t]
286 ["By List Info" wl-summary-sort-by-list-info t])
289 ["Mark as read" wl-summary-mark-as-read t]
290 ["Set flags" wl-summary-set-flags t]
291 ["Mark as unread" wl-summary-mark-as-unread t]
292 ["Mark as answered" wl-summary-mark-as-answered t]
293 ["Set dispose mark" wl-summary-dispose t]
294 ["Set refile mark" wl-summary-refile t]
295 ["Set copy mark" wl-summary-copy t]
296 ["Set resend mark" wl-summary-resend t]
297 ["Prefetch" wl-summary-prefetch t]
298 ["Set target mark" wl-summary-target-mark t]
299 ["Unmark" wl-summary-unmark t]
300 ["Save" wl-summary-save t]
301 ["Cancel posted news" wl-summary-cancel-message t]
302 ["Supersedes message" wl-summary-supersedes-message t]
303 ["Resend bounced mail" wl-summary-resend-bounced-mail t]
304 ["Enter the message" wl-summary-jump-to-current-message t]
305 ["Pipe message" wl-summary-pipe-message t]
306 ["Print message" wl-summary-print-message t])
308 ["Open or Close" wl-thread-open-close (eq wl-summary-buffer-view 'thread)]
309 ["Open all" wl-thread-open-all (eq wl-summary-buffer-view 'thread)]
310 ["Close all" wl-thread-close-all (eq wl-summary-buffer-view 'thread)]
311 ["Mark as read" wl-thread-mark-as-read (eq wl-summary-buffer-view 'thread)]
312 ["Set flags" wl-thread-set-flags (eq wl-summary-buffer-view 'thread)]
313 ["Mark as unread" wl-thread-mark-as-unread (eq wl-summary-buffer-view 'thread)]
314 ["Mark as answered" wl-thread-mark-as-answered (eq wl-summary-buffer-view 'thread)]
315 ["Set delete mark" wl-thread-delete (eq wl-summary-buffer-view 'thread)]
316 ["Set refile mark" wl-thread-refile (eq wl-summary-buffer-view 'thread)]
317 ["Set copy mark" wl-thread-copy (eq wl-summary-buffer-view 'thread)]
318 ["Prefetch" wl-thread-prefetch (eq wl-summary-buffer-view 'thread)]
319 ["Set target mark" wl-thread-target-mark (eq wl-summary-buffer-view 'thread)]
320 ["Unmark" wl-thread-unmark (eq wl-summary-buffer-view 'thread)]
321 ["Save" wl-thread-save (eq wl-summary-buffer-view 'thread)]
322 ["Execute" wl-thread-exec (eq wl-summary-buffer-view 'thread)])
324 ["Mark as read" wl-summary-mark-as-read-region t]
325 ["Set flags" wl-summary-set-flags-region t]
326 ["Mark as unread" wl-summary-mark-as-unread-region t]
327 ["Mark as answered" wl-summary-mark-as-answered-region t]
328 ["Set dispose mark" wl-summary-dispose-region t]
329 ["Set refile mark" wl-summary-refile-region t]
330 ["Set copy mark" wl-summary-copy-region t]
331 ["Prefetch" wl-summary-prefetch-region t]
332 ["Set target mark" wl-summary-target-mark-region t]
333 ["Unmark" wl-summary-unmark-region t]
334 ["Save" wl-summary-save-region t]
335 ["Execute" wl-summary-exec-region t])
337 ["Mark as read" wl-summary-target-mark-mark-as-read t]
338 ["Set flags" wl-summary-target-mark-set-flags t]
339 ["Mark as unread" wl-summary-target-mark-mark-as-unread t]
340 ["Set delete mark" wl-summary-target-mark-delete t]
341 ["Set refile mark" wl-summary-target-mark-refile t]
342 ["Set copy mark" wl-summary-target-mark-copy t]
343 ["Prefetch" wl-summary-target-mark-prefetch t]
344 ["Save" wl-summary-target-mark-save t]
345 ["Reply with citation" wl-summary-target-mark-reply-with-citation t]
346 ["Forward" wl-summary-target-mark-forward t]
347 ["uudecode" wl-summary-target-mark-uudecode t])
349 ["Switch current score file" wl-score-change-score-file t]
350 ["Edit current score file" wl-score-edit-current-scores t]
351 ["Edit score file" wl-score-edit-file t]
352 ["Set mark below" wl-score-set-mark-below t]
353 ["Set expunge below" wl-score-set-expunge-below t]
354 ["Rescore buffer" wl-summary-rescore t]
355 ["Increase score" wl-summary-increase-score t]
356 ["Lower score" wl-summary-lower-score t])
359 ["Write a message" wl-summary-write t]
360 ["Write for current folder" wl-summary-write-current-folder t]
361 ["Reply" wl-summary-reply t]
362 ["Reply with citation" wl-summary-reply-with-citation t]
363 ["Forward" wl-summary-forward t])
365 ["Toggle Plug Status" wl-toggle-plugged t]
366 ["Change Plug Status" wl-plugged-change t]
368 ["Exit Current Folder" wl-summary-exit t]))
371 (defun wl-summary-setup-mouse ()
372 (define-key wl-summary-mode-map 'button4 'wl-summary-prev)
373 (define-key wl-summary-mode-map 'button5 'wl-summary-next)
374 (define-key wl-summary-mode-map [(shift button4)]
376 (define-key wl-summary-mode-map [(shift button5)]
378 (define-key wl-summary-mode-map 'button2 'wl-summary-click))
379 (defun wl-summary-setup-mouse ()
380 (define-key wl-summary-mode-map [mouse-4] 'wl-summary-prev)
381 (define-key wl-summary-mode-map [mouse-5] 'wl-summary-next)
382 (define-key wl-summary-mode-map [S-mouse-4] 'wl-summary-up)
383 (define-key wl-summary-mode-map [S-mouse-5] 'wl-summary-down)
385 (define-key wl-summary-mode-map [mouse-wheel1]
386 'wl-summary-wheel-dispatcher)
387 (define-key wl-summary-mode-map [S-mouse-wheel1]
388 'wl-summary-wheel-dispatcher)
389 (define-key wl-summary-mode-map [mouse-2] 'wl-summary-click)))
391 (if wl-summary-mode-map
393 (setq wl-summary-mode-map (make-sparse-keymap))
394 (define-key wl-summary-mode-map " " 'wl-summary-read)
395 (define-key wl-summary-mode-map "." 'wl-summary-redisplay)
396 (define-key wl-summary-mode-map "<" 'wl-summary-display-top)
397 (define-key wl-summary-mode-map ">" 'wl-summary-display-bottom)
398 (define-key wl-summary-mode-map "\177" 'wl-summary-prev-page)
399 (define-key wl-summary-mode-map [backspace] 'wl-summary-prev-page)
400 (define-key wl-summary-mode-map "\r" 'wl-summary-next-line-content)
401 (define-key wl-summary-mode-map "\C-m" 'wl-summary-next-line-content)
402 (define-key wl-summary-mode-map "/" 'wl-thread-open-close)
403 (define-key wl-summary-mode-map "[" 'wl-thread-open-all)
404 (define-key wl-summary-mode-map "]" 'wl-thread-close-all)
405 (define-key wl-summary-mode-map "-" 'wl-summary-prev-line-content)
406 (define-key wl-summary-mode-map "\e\r" 'wl-summary-prev-line-content)
407 (define-key wl-summary-mode-map "g" 'wl-summary-goto-folder)
408 (define-key wl-summary-mode-map "G" 'wl-summary-goto-folder-sticky)
409 (define-key wl-summary-mode-map "c" 'wl-summary-mark-as-read-all)
411 (define-key wl-summary-mode-map "a" 'wl-summary-reply)
412 (define-key wl-summary-mode-map "A" 'wl-summary-reply-with-citation)
413 (define-key wl-summary-mode-map "C" 'wl-summary-cancel-message)
414 (define-key wl-summary-mode-map "E" 'wl-summary-reedit)
415 (define-key wl-summary-mode-map "\eE" 'wl-summary-resend-bounced-mail)
416 (define-key wl-summary-mode-map "f" 'wl-summary-forward)
417 (define-key wl-summary-mode-map "$" 'wl-summary-mark-as-important)
418 (define-key wl-summary-mode-map "F" 'wl-summary-set-flags)
419 (define-key wl-summary-mode-map "&" 'wl-summary-mark-as-answered)
420 (define-key wl-summary-mode-map "@" 'wl-summary-edit-addresses)
422 (define-key wl-summary-mode-map "y" 'wl-summary-save)
423 (define-key wl-summary-mode-map "n" 'wl-summary-next)
424 (define-key wl-summary-mode-map "p" 'wl-summary-prev)
425 (define-key wl-summary-mode-map "N" 'wl-summary-down)
426 (define-key wl-summary-mode-map "P" 'wl-summary-up)
427 (define-key wl-summary-mode-map "w" 'wl-summary-write)
428 (define-key wl-summary-mode-map "W" 'wl-summary-write-current-folder)
429 (define-key wl-summary-mode-map "e" 'wl-summary-save)
430 (define-key wl-summary-mode-map "\C-c\C-o" 'wl-jump-to-draft-buffer)
431 (define-key wl-summary-mode-map "\C-c\C-a" 'wl-addrmgr)
432 (define-key wl-summary-mode-map "\C-c\C-p" 'wl-summary-previous-buffer)
433 (define-key wl-summary-mode-map "\C-c\C-n" 'wl-summary-next-buffer)
434 (define-key wl-summary-mode-map "H" 'wl-summary-redisplay-all-header)
435 (define-key wl-summary-mode-map "M" 'wl-summary-redisplay-no-mime)
436 (define-key wl-summary-mode-map "B" 'wl-summary-burst)
437 (define-key wl-summary-mode-map "Z" 'wl-status-update)
438 (define-key wl-summary-mode-map "#" 'wl-summary-print-message)
439 (define-key wl-summary-mode-map "|" 'wl-summary-pipe-message)
440 (define-key wl-summary-mode-map "z" 'wl-summary-suspend)
441 (define-key wl-summary-mode-map "q" 'wl-summary-exit)
442 (define-key wl-summary-mode-map "Q" 'wl-summary-force-exit)
444 (define-key wl-summary-mode-map "j" 'wl-summary-jump-to-current-message)
445 (define-key wl-summary-mode-map "J" 'wl-thread-jump-to-msg)
446 (define-key wl-summary-mode-map "I" 'wl-summary-incorporate)
447 (define-key wl-summary-mode-map "\M-j" 'wl-summary-jump-to-msg-by-message-id)
448 (define-key wl-summary-mode-map "^" 'wl-summary-jump-to-parent-message)
449 (define-key wl-summary-mode-map "!" 'wl-summary-mark-as-unread)
451 (define-key wl-summary-mode-map "s" 'wl-summary-sync)
452 (define-key wl-summary-mode-map "S" 'wl-summary-sort)
453 (define-key wl-summary-mode-map "\M-s" 'wl-summary-stick)
454 (define-key wl-summary-mode-map "T" 'wl-summary-toggle-thread)
456 (define-key wl-summary-mode-map "l" 'wl-summary-toggle-disp-folder)
457 (define-key wl-summary-mode-map "v" 'wl-summary-toggle-disp-msg)
458 (define-key wl-summary-mode-map "V" 'wl-summary-virtual)
460 (define-key wl-summary-mode-map "\C-i" 'wl-summary-goto-last-displayed-msg)
461 (define-key wl-summary-mode-map "?" 'wl-summary-pick)
462 (define-key wl-summary-mode-map "\ee" 'wl-summary-expire)
465 (define-key wl-summary-mode-map "\ew" 'wl-summary-save-current-message)
466 (define-key wl-summary-mode-map "\C-y" 'wl-summary-yank-saved-message)
469 (define-key wl-summary-mode-map "R" 'wl-summary-mark-as-read)
470 (define-key wl-summary-mode-map "i" 'wl-summary-prefetch)
471 (define-key wl-summary-mode-map "x" 'wl-summary-exec)
472 (define-key wl-summary-mode-map "*" 'wl-summary-target-mark)
473 (define-key wl-summary-mode-map "o" 'wl-summary-refile)
474 (define-key wl-summary-mode-map "O" 'wl-summary-copy)
475 (define-key wl-summary-mode-map "\M-o" 'wl-summary-refile-prev-destination)
476 (define-key wl-summary-mode-map "\C-o" 'wl-summary-auto-refile)
477 (define-key wl-summary-mode-map "d" 'wl-summary-dispose)
478 (define-key wl-summary-mode-map "u" 'wl-summary-unmark)
479 (define-key wl-summary-mode-map "U" 'wl-summary-unmark-all)
480 (define-key wl-summary-mode-map "D" 'wl-summary-delete)
481 (define-key wl-summary-mode-map "~" 'wl-summary-resend)
484 (define-key wl-summary-mode-map "t" (make-sparse-keymap))
485 (define-key wl-summary-mode-map "tR" 'wl-thread-mark-as-read)
486 (define-key wl-summary-mode-map "ti" 'wl-thread-prefetch)
487 (define-key wl-summary-mode-map "tx" 'wl-thread-exec)
488 (define-key wl-summary-mode-map "t*" 'wl-thread-target-mark)
489 (define-key wl-summary-mode-map "to" 'wl-thread-refile)
490 (define-key wl-summary-mode-map "tO" 'wl-thread-copy)
491 (define-key wl-summary-mode-map "t\M-o" 'wl-thread-refile-prev-destination)
492 (define-key wl-summary-mode-map "td" 'wl-thread-dispose)
493 (define-key wl-summary-mode-map "tD" 'wl-thread-delete)
494 (define-key wl-summary-mode-map "t~" 'wl-thread-resend)
495 (define-key wl-summary-mode-map "tu" 'wl-thread-unmark)
496 (define-key wl-summary-mode-map "t!" 'wl-thread-mark-as-unread)
497 (define-key wl-summary-mode-map "t$" 'wl-thread-mark-as-important)
498 (define-key wl-summary-mode-map "tF" 'wl-thread-set-flags)
499 (define-key wl-summary-mode-map "t&" 'wl-thread-mark-as-answered)
500 (define-key wl-summary-mode-map "ty" 'wl-thread-save)
501 (define-key wl-summary-mode-map "ts" 'wl-thread-set-parent)
503 ;; target-mark commands
504 (define-key wl-summary-mode-map "m" (make-sparse-keymap))
505 (define-key wl-summary-mode-map "mi" 'wl-summary-target-mark-prefetch)
506 (define-key wl-summary-mode-map "mo" 'wl-summary-target-mark-refile)
507 (define-key wl-summary-mode-map "mO" 'wl-summary-target-mark-copy)
508 (define-key wl-summary-mode-map "m\M-o" 'wl-summary-target-mark-refile-prev-destination)
509 (define-key wl-summary-mode-map "md" 'wl-summary-target-mark-dispose)
510 (define-key wl-summary-mode-map "mD" 'wl-summary-target-mark-delete)
511 (define-key wl-summary-mode-map "m~" 'wl-summary-target-mark-resend)
513 (define-key wl-summary-mode-map "mu" 'wl-summary-delete-all-temp-marks)
515 (define-key wl-summary-mode-map "my" 'wl-summary-target-mark-save)
516 (define-key wl-summary-mode-map "mR" 'wl-summary-target-mark-mark-as-read)
517 (define-key wl-summary-mode-map "m!" 'wl-summary-target-mark-mark-as-unread)
518 (define-key wl-summary-mode-map "m&" 'wl-summary-target-mark-mark-as-answered)
519 (define-key wl-summary-mode-map "m$" 'wl-summary-target-mark-mark-as-important)
520 (define-key wl-summary-mode-map "mF" 'wl-summary-target-mark-set-flags)
521 (define-key wl-summary-mode-map "mU" 'wl-summary-target-mark-uudecode)
522 (define-key wl-summary-mode-map "ma" 'wl-summary-target-mark-all)
523 (define-key wl-summary-mode-map "mt" 'wl-summary-target-mark-thread)
524 (define-key wl-summary-mode-map "mA" 'wl-summary-target-mark-reply-with-citation)
525 (define-key wl-summary-mode-map "mf" 'wl-summary-target-mark-forward)
526 (define-key wl-summary-mode-map "m?" 'wl-summary-target-mark-pick)
527 (define-key wl-summary-mode-map "m#" 'wl-summary-target-mark-print)
528 (define-key wl-summary-mode-map "m|" 'wl-summary-target-mark-pipe)
531 (define-key wl-summary-mode-map "r" (make-sparse-keymap))
532 (define-key wl-summary-mode-map "rR" 'wl-summary-mark-as-read-region)
533 (define-key wl-summary-mode-map "ri" 'wl-summary-prefetch-region)
534 (define-key wl-summary-mode-map "rx" 'wl-summary-exec-region)
535 (define-key wl-summary-mode-map "mr" 'wl-summary-target-mark-region)
536 (define-key wl-summary-mode-map "r*" 'wl-summary-target-mark-region)
537 (define-key wl-summary-mode-map "ro" 'wl-summary-refile-region)
538 (define-key wl-summary-mode-map "rO" 'wl-summary-copy-region)
539 (define-key wl-summary-mode-map "r\M-o" 'wl-summary-refile-prev-destination-region)
540 (define-key wl-summary-mode-map "rd" 'wl-summary-dispose-region)
541 (define-key wl-summary-mode-map "rD" 'wl-summary-delete-region)
542 (define-key wl-summary-mode-map "r~" 'wl-summary-resend-region)
543 (define-key wl-summary-mode-map "ru" 'wl-summary-unmark-region)
544 (define-key wl-summary-mode-map "r!" 'wl-summary-mark-as-unread-region)
545 (define-key wl-summary-mode-map "r$" 'wl-summary-mark-as-important-region)
546 (define-key wl-summary-mode-map "rF" 'wl-summary-set-flags-region)
547 (define-key wl-summary-mode-map "r&" 'wl-summary-mark-as-answered-region)
548 (define-key wl-summary-mode-map "ry" 'wl-summary-save-region)
551 (define-key wl-summary-mode-map "K" 'wl-summary-increase-score)
552 (define-key wl-summary-mode-map "L" 'wl-summary-lower-score)
553 (define-key wl-summary-mode-map "h" (make-sparse-keymap))
554 (define-key wl-summary-mode-map "hR" 'wl-summary-rescore)
555 (define-key wl-summary-mode-map "hc" 'wl-score-change-score-file)
556 (define-key wl-summary-mode-map "he" 'wl-score-edit-current-scores)
557 (define-key wl-summary-mode-map "hf" 'wl-score-edit-file)
558 (define-key wl-summary-mode-map "hF" 'wl-score-flush-cache)
559 (define-key wl-summary-mode-map "hm" 'wl-score-set-mark-below)
560 (define-key wl-summary-mode-map "hx" 'wl-score-set-expunge-below)
563 (define-key wl-summary-mode-map "\C-c\C-f" 'wl-summary-toggle-header-narrowing)
564 (define-key wl-summary-mode-map "\M-t" 'wl-toggle-plugged)
565 (define-key wl-summary-mode-map "\C-t" 'wl-plugged-change)
567 (define-key wl-summary-mode-map "\C-x\C-s" 'wl-summary-save-status)
568 (wl-summary-setup-mouse)
572 "Menu used in Summary mode."
573 wl-summary-mode-menu-spec))
575 (defsubst wl-summary-message-visible-p (number)
576 "Return non-nil if the message with NUMBER is visible."
577 (or (eq wl-summary-buffer-view 'sequence)
578 (not (wl-thread-entity-parent-invisible-p
579 (wl-thread-get-entity number)))))
581 (defun wl-summary-update-mark-and-highlight-window (&optional win beg)
582 "A function to be called as window-scroll-functions."
583 (with-current-buffer (window-buffer win)
584 (when (eq major-mode 'wl-summary-mode)
585 (let ((beg (or beg (window-start win)))
586 (end (condition-case nil
587 (window-end win t) ; old emacsen doesn't support 2nd arg.
588 (error (window-end win))))
592 (while (and (< (point) end) (not (eobp)))
593 (when (null (get-text-property (point) 'face))
594 (setq number (wl-summary-message-number)
595 flags (elmo-message-flags wl-summary-buffer-elmo-folder
597 (let (wl-summary-highlight)
598 (wl-summary-update-persistent-mark number flags))
599 (wl-highlight-summary-current-line number flags))
601 (set-buffer-modified-p nil)))
603 (defun wl-summary-window-scroll-functions ()
604 (cond ((and wl-summary-highlight
605 wl-summary-lazy-highlight
606 wl-summary-lazy-update-mark)
607 (list 'wl-summary-update-mark-and-highlight-window))
608 ((and wl-summary-highlight
609 wl-summary-lazy-highlight)
610 (list 'wl-highlight-summary-window))
611 (wl-summary-lazy-update-mark
612 (list 'wl-summary-update-mark-window))))
614 (defun wl-status-update ()
618 (defun wl-summary-display-top ()
620 (goto-char (point-min))
621 (run-hooks 'wl-summary-buffer-window-scroll-functions)
622 (if wl-summary-buffer-disp-msg
623 (wl-summary-redisplay)))
625 (defun wl-summary-display-bottom ()
627 (goto-char (point-max))
629 (run-hooks 'wl-summary-buffer-window-scroll-functions)
630 (if wl-summary-buffer-disp-msg
631 (wl-summary-redisplay)))
633 (defun wl-summary-count-unread ()
634 (let ((lst (elmo-folder-count-flags wl-summary-buffer-elmo-folder)))
635 (if (eq major-mode 'wl-summary-mode)
636 (setq wl-summary-buffer-new-count (car lst)
637 wl-summary-buffer-unread-count (nth 1 lst)
638 wl-summary-buffer-answered-count (nth 2 lst)))
641 (defun wl-summary-message-string (&optional use-cache)
642 "Return full body string of current message.
643 If optional USE-CACHE is non-nil, use cache if exists."
644 (let ((number (wl-summary-message-number))
645 (folder wl-summary-buffer-elmo-folder))
647 (message "No message.")
649 (elmo-message-fetch folder
651 (elmo-make-fetch-strategy
653 use-cache ; use cache
654 nil ; save cache (should `t'?)
657 (elmo-file-cache-get-path
658 (elmo-message-field folder number 'message-id))))
664 (defun wl-summary-reedit (&optional arg)
665 "Re-edit current message.
666 If ARG is non-nil, Supersedes message"
668 (wl-summary-toggle-disp-msg 'off)
670 ((not (wl-summary-message-number))
671 (message "No message."))
673 (wl-summary-supersedes-message))
674 ((string= (wl-summary-buffer-folder-name) wl-draft-folder)
675 (wl-draft-reedit (wl-summary-message-number))
676 (if (wl-message-news-p)
677 (mail-position-on-field "Newsgroups")
678 (mail-position-on-field "To")))
680 (wl-draft-edit-string (wl-summary-message-string)))))
682 (defun wl-summary-resend-bounced-mail ()
683 "Re-mail the current message.
684 This only makes sense if the current message is a bounce message which
685 contains some mail you have written but has been bounced back to
688 (wl-summary-toggle-disp-msg 'off)
690 (wl-summary-set-message-buffer-or-redisplay)
691 (set-buffer (wl-message-get-original-buffer))
692 (goto-char (point-min))
693 (let ((case-fold-search nil))
697 (concat "^\\($\\|[Cc]ontent-[Tt]ype:[ \t]+multipart/\\(report\\|mixed\\)\\)") nil t)
699 (re-search-forward "boundary=\"\\([^\"]+\\)\"" nil t))
700 (let ((boundary (buffer-substring (match-beginning 1) (match-end 1)))
703 ((and (setq start (re-search-forward
704 (concat "^--" boundary "\n"
705 "\\([Cc]ontent-[Dd]escription:.*\n\\)?"
706 "[Cc]ontent-[Tt]ype:[ \t]+"
707 "\\(message/rfc822\\|text/rfc822-headers\\).*\n"
708 "\\(.+\n\\)*\n") nil t))
710 (concat "\n\\(--" boundary "\\)--\n") nil t))
711 (wl-draft-edit-string (buffer-substring start (match-beginning 1))))
713 (message "Seems no message/rfc822 part.")))))
714 ((let ((case-fold-search t))
715 (re-search-forward wl-rejected-letter-start nil t))
716 (skip-chars-forward " \t\n")
717 (wl-draft-edit-string (buffer-substring (point) (point-max))))
719 (message "Does not appear to be a rejected letter."))))))
721 (defun wl-summary-detect-mark-position ()
722 (let ((column wl-summary-buffer-number-column)
723 (formatter wl-summary-buffer-line-formatter)
724 (dummy-temp (char-to-string 200))
725 ;; bind only for the check.
726 (wl-summary-new-uncached-mark (char-to-string 201))
727 (wl-summary-persistent-mark-priority-list '(new)) ; ditto.
728 (lang wl-summary-buffer-weekday-name-lang)
732 (setq wl-summary-buffer-number-column column
733 wl-summary-buffer-line-formatter formatter
734 wl-summary-buffer-weekday-name-lang lang)
736 (wl-summary-create-line
737 (elmo-msgdb-make-message-entity
738 (luna-make-entity 'modb-entity-handler)
747 (goto-char (point-min))
748 (setq temp (save-excursion
749 (when (search-forward dummy-temp nil t)
753 (when (search-forward wl-summary-new-uncached-mark nil t)
755 (setq wl-summary-buffer-temp-mark-column temp
756 wl-summary-buffer-persistent-mark-column persistent)))
758 (defun wl-summary-buffer-set-folder (folder)
760 (setq folder (wl-folder-get-elmo-folder folder)))
761 (setq wl-summary-buffer-elmo-folder folder)
762 (make-local-variable 'wl-message-buffer)
763 (setq wl-summary-buffer-mime-charset (or (wl-get-assoc-list-value
764 wl-folder-mime-charset-alist
765 (elmo-folder-name-internal folder))
767 (setq wl-summary-buffer-weekday-name-lang
768 (or (wl-get-assoc-list-value
769 wl-folder-weekday-name-lang-alist
770 (elmo-folder-name-internal folder))
771 wl-summary-weekday-name-lang))
772 (setq wl-summary-buffer-thread-indent-set
773 (wl-get-assoc-list-value
774 wl-folder-thread-indent-set-alist
775 (elmo-folder-name-internal folder)))
776 (setq wl-summary-buffer-number-column
777 (or (wl-get-assoc-list-value wl-summary-number-column-alist
778 (wl-summary-buffer-folder-name))
779 wl-summary-default-number-column))
780 (wl-line-formatter-setup
781 wl-summary-buffer-line-formatter
782 (setq wl-summary-buffer-line-format
783 (or (wl-get-assoc-list-value
784 wl-folder-summary-line-format-alist
785 (elmo-folder-name-internal folder))
786 wl-summary-line-format))
787 wl-summary-line-format-spec-alist)
788 (wl-line-formatter-setup
789 wl-summary-buffer-mode-line-formatter
790 wl-summary-mode-line-format
791 wl-summary-mode-line-format-spec-alist)
792 (setq wl-summary-buffer-persistent
793 (wl-folder-persistent-p (elmo-folder-name-internal folder)))
794 (elmo-folder-set-persistent-internal folder wl-summary-buffer-persistent)
795 ;; process duplicates.
796 (elmo-folder-set-process-duplicates-internal
797 folder (cdr (elmo-string-matched-assoc
798 (elmo-folder-name-internal folder)
799 wl-folder-process-duplicates-alist)))
801 wl-thread-indent-level-internal
802 (or (nth 0 wl-summary-buffer-thread-indent-set)
803 wl-thread-indent-level)
804 wl-thread-have-younger-brother-str-internal
805 (or (nth 1 wl-summary-buffer-thread-indent-set)
806 wl-thread-have-younger-brother-str)
807 wl-thread-youngest-child-str-internal
808 (or (nth 2 wl-summary-buffer-thread-indent-set)
809 wl-thread-youngest-child-str)
810 wl-thread-vertical-str-internal
811 (or (nth 3 wl-summary-buffer-thread-indent-set)
812 wl-thread-vertical-str)
813 wl-thread-horizontal-str-internal
814 (or (nth 4 wl-summary-buffer-thread-indent-set)
815 wl-thread-horizontal-str)
816 wl-thread-space-str-internal
817 (or (nth 5 wl-summary-buffer-thread-indent-set)
818 wl-thread-space-str))
819 (run-hooks 'wl-summary-buffer-set-folder-hook))
821 (defun wl-summary-mode ()
822 "Major mode for reading threaded messages.
823 See Info under Wanderlust for full documentation.
826 \\{wl-summary-mode-map}
828 Entering Folder mode calls the value of `wl-summary-mode-hook'."
830 (unless (interactive-p) (kill-all-local-variables))
831 (setq major-mode 'wl-summary-mode)
832 (setq mode-name "Summary")
833 (use-local-map wl-summary-mode-map)
834 ;;;(setq default-directory (or wl-tmp-dir (expand-file-name "~/")))
835 (setq buffer-read-only t)
836 (setq truncate-lines t)
837 ;;;(make-local-variable 'tab-width)
838 ;;;(setq tab-width 1)
839 (buffer-disable-undo (current-buffer))
840 (setq selective-display t
841 selective-display-ellipses nil)
842 (wl-mode-line-buffer-identification '(wl-summary-buffer-mode-line))
843 (easy-menu-add wl-summary-mode-menu)
844 (setq wl-summary-buffer-window-scroll-functions
845 (wl-summary-window-scroll-functions))
846 (when wl-summary-buffer-window-scroll-functions
847 (let ((hook (if wl-on-xemacs 'pre-idle-hook 'window-scroll-functions)))
848 (make-local-hook hook)
849 (dolist (function wl-summary-buffer-window-scroll-functions)
850 (add-hook hook function nil t))))
851 ;; This hook may contain the function `wl-setup-summary' for reasons
852 ;; of system internal to accord facilities for the Emacs variants.
853 (run-hooks 'wl-summary-mode-hook))
856 (defun wl-summary-overview-entity-compare-by-size (x y)
857 "Compare entity X and Y by size."
858 (< (elmo-message-entity-field x 'size)
859 (elmo-message-entity-field y 'size)))
862 (defun wl-summary-overview-entity-compare-by-date (x y)
863 "Compare entity X and Y by date."
866 (timezone-make-date-sortable
867 (elmo-message-entity-field x 'date))
868 (timezone-make-date-sortable
869 (elmo-message-entity-field y 'date)))
870 (error))) ;; ignore error.
872 (defun wl-summary-overview-entity-compare-by-number (x y)
873 "Compare entity X and Y by number."
875 (elmo-message-entity-number x)
876 (elmo-message-entity-number y)))
878 (defun wl-summary-overview-entity-compare-by-from (x y)
879 "Compare entity X and Y by from."
881 (wl-address-header-extract-address
882 (or (elmo-message-entity-field x 'from t)
883 wl-summary-no-from-message))
884 (wl-address-header-extract-address
885 (or (elmo-message-entity-field y 'from t)
886 wl-summary-no-from-message))))
888 (defun wl-summary-overview-entity-compare-by-subject (x y)
889 "Compare entity X and Y by subject."
890 (string< (elmo-message-entity-field x 'subject)
891 (elmo-message-entity-field y 'subject)))
893 (defun wl-summary-get-list-info (entity)
894 "Returns (\"ML-name\" . ML-count) of ENTITY."
895 (let (sequence ml-name ml-count subject return-path delivered-to mailing-list)
896 (setq sequence (elmo-message-entity-field entity 'x-sequence)
897 ml-name (or (elmo-message-entity-field entity 'x-ml-name)
899 (car (split-string sequence " "))))
900 ml-count (or (elmo-message-entity-field entity 'x-mail-count)
901 (elmo-message-entity-field entity 'x-ml-count)
903 (cadr (split-string sequence " ")))))
904 (and (setq subject (elmo-message-entity-field entity 'subject t))
905 (setq subject (elmo-delete-char ?\n subject))
906 (string-match "^\\s(\\(\\S)+\\)[ :]\\([0-9]+\\)\\s)[ \t]*" subject)
908 (or ml-name (setq ml-name (match-string 1 subject)))
909 (or ml-count (setq ml-count (match-string 2 subject)))))
910 (and (setq return-path
911 (elmo-message-entity-field entity 'return-path))
912 (string-match "^<\\([^@>]+\\)-return-\\([0-9]+\\)-" return-path)
914 (or ml-name (setq ml-name (match-string 1 return-path)))
915 (or ml-count (setq ml-count (match-string 2 return-path)))))
916 (and (setq delivered-to
917 (elmo-message-entity-field entity 'delivered-to))
918 (string-match "^mailing list \\([^@]+\\)@" delivered-to)
919 (or ml-name (setq ml-name (match-string 1 delivered-to))))
920 (and (setq mailing-list
921 (elmo-message-entity-field entity 'mailing-list))
922 ;; *-help@, *-owner@, etc.
923 (string-match "\\(^\\|; \\)contact \\([^@]+\\)-[^-@]+@" mailing-list)
924 (or ml-name (setq ml-name (match-string 2 mailing-list))))
925 (cons (and ml-name (car (split-string ml-name " ")))
926 (and ml-count (string-to-int ml-count)))))
928 (defun wl-summary-overview-entity-compare-by-list-info (x y)
929 "Compare entity X and Y by mailing-list info."
930 (let* ((list-info-x (wl-summary-get-list-info x))
931 (list-info-y (wl-summary-get-list-info y)))
932 (if (equal (car list-info-x) (car list-info-y))
933 (if (equal (cdr list-info-x) (cdr list-info-y))
934 (wl-summary-overview-entity-compare-by-date x y)
935 (< (or (cdr list-info-x) 0)
936 (or (cdr list-info-y) 0)))
937 (string< (or (car list-info-x) "")
938 (or (car list-info-y) "")))))
940 (defun wl-summary-sort-by-date ()
942 (wl-summary-rescan "date"))
943 (defun wl-summary-sort-by-number ()
945 (wl-summary-rescan "number"))
946 (defun wl-summary-sort-by-subject ()
948 (wl-summary-rescan "subject"))
949 (defun wl-summary-sort-by-from ()
951 (wl-summary-rescan "from"))
952 (defun wl-summary-sort-by-list-info ()
954 (wl-summary-rescan "list-info"))
956 (defun wl-summary-rescan (&optional sort-by disable-killed disable-thread)
957 "Rescan current folder without updating."
959 (let ((elmo-mime-charset wl-summary-buffer-mime-charset)
963 (inhibit-read-only t)
964 (buffer-read-only nil)
965 (numbers (elmo-folder-list-messages wl-summary-buffer-elmo-folder
966 (not disable-killed) t)) ; in-msgdb
967 (wl-thread-saved-entity-hashtb-internal (and (not disable-thread)
968 wl-thread-entity-hashtb))
969 (wl-summary-search-parent-by-subject-regexp
970 (and disable-thread wl-summary-search-parent-by-subject-regexp))
971 (wl-summary-divide-thread-when-subject-changed
972 (and disable-thread wl-summary-divide-thread-when-subject-changed))
975 (message "Re-scanning...")
978 (message "Sorting by %s..." sort-by)
983 (intern (format "wl-summary-overview-entity-compare-by-%s"
985 (elmo-message-entity wl-summary-buffer-elmo-folder x)
986 (elmo-message-entity wl-summary-buffer-elmo-folder y)))))
987 (message "Sorting by %s...done" sort-by))
988 (setq num (length numbers))
989 (setq wl-thread-entity-hashtb (elmo-make-hash (* num 2))
990 wl-thread-entity-list nil
991 wl-thread-entities nil
992 wl-summary-scored nil
993 wl-summary-buffer-number-list nil
994 wl-summary-buffer-unsync-mark-number-list nil
995 wl-summary-buffer-target-mark-list nil
996 wl-summary-buffer-temp-mark-list nil
997 wl-summary-delayed-update nil)
998 (elmo-kill-buffer wl-summary-search-buf-name)
1000 (setq entity (elmo-message-entity wl-summary-buffer-elmo-folder
1002 (wl-summary-insert-message entity
1003 wl-summary-buffer-elmo-folder
1005 (setq numbers (cdr numbers))
1006 (when (> num elmo-display-progress-threshold)
1008 (if (or (zerop (% i 5)) (= i num))
1009 (elmo-display-progress
1010 'wl-summary-rescan "Constructing summary structure..."
1011 (/ (* i 100) num)))))
1012 (when wl-summary-delayed-update
1013 (while wl-summary-delayed-update
1014 (message "Parent (%d) of message %d is no entity"
1015 (caar wl-summary-delayed-update)
1016 (elmo-message-entity-number
1017 (cdar wl-summary-delayed-update)))
1018 (wl-summary-insert-message
1019 (cdar wl-summary-delayed-update)
1020 wl-summary-buffer-elmo-folder nil t)
1021 (setq wl-summary-delayed-update (cdr wl-summary-delayed-update))))
1022 (message "Constructing summary structure...done")
1023 (if (eq wl-summary-buffer-view 'thread)
1025 (message "Inserting thread...")
1026 (wl-thread-insert-top)
1027 (message "Inserting thread...done")))
1028 (when wl-use-scoring
1029 (wl-summary-score-headers (wl-summary-rescore-msgs
1030 wl-summary-buffer-number-list)
1032 (when (and wl-summary-scored
1033 (setq expunged (wl-summary-score-update-all-lines)))
1034 (message "%d message(s) are expunged by scoring." (length expunged))))
1035 (wl-summary-set-message-modified)
1036 (wl-summary-count-unread)
1037 (wl-summary-update-modeline)
1038 (goto-char (point-max))
1040 (set-buffer-modified-p nil)))
1042 (defun wl-summary-next-folder-or-exit (&optional next-entity upward)
1043 (if (and next-entity
1044 wl-auto-select-next)
1046 (wl-summary-toggle-disp-msg 'off)
1049 (wl-summary-goto-folder-subr next-entity
1055 (wl-folder-set-current-entity-id (wl-folder-get-entity-id next-entity))
1056 (if (and (eq retval 'more-next)
1057 (memq wl-auto-select-next '(unread skip-no-unread))
1058 (memq this-command wl-summary-next-no-unread-command))
1061 t (eq wl-auto-select-next 'skip-no-unread))
1062 (goto-char (point-max))
1065 t (eq wl-auto-select-next 'skip-no-unread))))))
1068 (defun wl-summary-entity-info-msg (entity finfo)
1071 (if (memq 'ask-folder wl-use-folder-petname)
1072 (wl-folder-get-petname entity)
1074 (if (null (car finfo))
1077 " (%d new/%d unread)"
1083 (defun wl-summary-set-message-modified ()
1084 (setq wl-summary-buffer-message-modified t))
1085 (defun wl-summary-message-modified-p ()
1086 wl-summary-buffer-message-modified)
1087 (defun wl-summary-set-thread-modified ()
1088 (setq wl-summary-buffer-thread-modified t))
1089 (defun wl-summary-thread-modified-p ()
1090 wl-summary-buffer-thread-modified)
1092 (defun wl-summary-exec-with-confirmation (&optional message)
1093 (when wl-summary-buffer-temp-mark-list
1094 (if (y-or-n-p (or message
1095 (format "Execute marks in %s? "
1096 (wl-summary-buffer-folder-name))))
1099 (if wl-summary-buffer-temp-mark-list
1100 (error "Some execution was failed")))
1101 ;; temp-mark-list is remained.
1104 (defun wl-summary-cleanup-temp-marks ()
1105 (when wl-summary-buffer-temp-mark-list
1106 (wl-summary-exec-with-confirmation
1107 (format "Execute marks in %s? (answer \"n\" to discard them) "
1108 (wl-summary-buffer-folder-name)))
1109 (wl-summary-delete-all-temp-marks 'no-msg)
1110 (setq wl-summary-scored nil)))
1112 ;; a subroutine for wl-summary-exit/wl-save-status
1113 ;; Note that folder is not commited here.
1114 (defun wl-summary-save-view ()
1115 ;; already in summary buffer.
1116 (when wl-summary-buffer-persistent
1117 ;; save the current summary buffer view.
1118 (if (and wl-summary-cache-use
1119 (or (wl-summary-message-modified-p)
1120 (wl-summary-thread-modified-p)))
1121 (wl-summary-save-view-cache))))
1123 (defun wl-summary-save-status ()
1124 "Save summary view and msgdb."
1126 (if (interactive-p) (message "Saving summary status..."))
1127 (wl-summary-save-view)
1128 (elmo-folder-commit wl-summary-buffer-elmo-folder)
1129 (elmo-folder-check wl-summary-buffer-elmo-folder)
1130 (if wl-use-scoring (wl-score-save))
1131 (if (interactive-p) (message "Saving summary status...done")))
1133 (defun wl-summary-force-exit ()
1134 "Exit current summary. Buffer is deleted even the buffer is sticky."
1136 (wl-summary-exit 'force-exit))
1138 (defun wl-summary-exit (&optional force-exit)
1139 "Exit current summary. if FORCE-EXIT, exits even the summary is sticky."
1141 (let ((summary-buf (current-buffer))
1142 (sticky (wl-summary-sticky-p))
1144 message-buf message-win
1145 folder-buf folder-win)
1146 (run-hooks 'wl-summary-exit-pre-hook)
1147 (if wl-summary-buffer-exit-function
1148 (funcall wl-summary-buffer-exit-function)
1149 (if (or force-exit (not sticky))
1150 (wl-summary-cleanup-temp-marks))
1152 ;; save summary status
1154 (wl-summary-save-view)
1155 (if (or force-exit (not sticky))
1156 (elmo-folder-close wl-summary-buffer-elmo-folder)
1157 (elmo-folder-commit wl-summary-buffer-elmo-folder)
1158 (elmo-folder-check wl-summary-buffer-elmo-folder))
1159 (if wl-use-scoring (wl-score-save)))
1160 ;; for sticky summary
1161 (wl-delete-all-overlays)
1162 (setq wl-summary-buffer-disp-msg nil)
1163 (elmo-kill-buffer wl-summary-search-buf-name)
1164 ;; delete message window if displayed.
1165 (if (and wl-message-buffer (get-buffer-window wl-message-buffer))
1166 (delete-window (get-buffer-window wl-message-buffer)))
1167 (if (and wl-summary-use-frame
1168 (> (length (visible-frame-list)) 1))
1170 (if (setq folder-buf (get-buffer wl-folder-buffer-name))
1171 (if wl-summary-use-frame
1173 (save-selected-window
1174 (dolist (frame (visible-frame-list))
1175 (select-frame frame)
1176 (if (get-buffer-window folder-buf)
1177 (setq select-frame frame))))
1179 (select-frame select-frame)
1180 (switch-to-buffer folder-buf)))
1181 (if (setq folder-win (get-buffer-window folder-buf))
1182 ;; folder win is already displayed.
1183 (select-window folder-win)
1184 ;; folder win is not displayed.
1185 (switch-to-buffer folder-buf)))
1186 ;; currently no folder buffer
1188 (and wl-folder-move-cur-folder
1189 wl-folder-buffer-cur-point
1190 (goto-char wl-folder-buffer-cur-point))
1191 (setq wl-folder-buffer-cur-path nil)
1192 (setq wl-folder-buffer-last-visited-entity-id wl-folder-buffer-cur-entity-id)
1193 (setq wl-folder-buffer-cur-entity-id nil)
1194 (wl-delete-all-overlays)
1195 (if wl-summary-exit-next-move
1196 (wl-folder-next-unsync t)
1197 (beginning-of-line))
1198 (if (setq summary-win (get-buffer-window summary-buf))
1199 (delete-window summary-win))
1203 (set-buffer summary-buf)
1204 (kill-buffer summary-buf)))
1205 (run-hooks 'wl-summary-exit-hook)))))
1207 (defun wl-summary-suspend ()
1210 (wl-folder-suspend))
1212 (defun wl-summary-sync-force-update (&optional unset-cursor no-check)
1214 (wl-summary-sync-update unset-cursor nil nil no-check))
1216 (defsubst wl-summary-sync-all-init ()
1217 (wl-summary-cleanup-temp-marks)
1219 (wl-summary-set-message-modified)
1220 (setq wl-thread-entity-hashtb (elmo-make-hash
1221 (* (elmo-folder-length
1222 wl-summary-buffer-elmo-folder)
1224 (setq wl-thread-entity-list nil)
1225 (setq wl-thread-entities nil)
1226 (setq wl-summary-buffer-number-list nil)
1227 (setq wl-summary-buffer-target-mark-list nil)
1228 (setq wl-summary-buffer-temp-mark-list nil))
1230 (defun wl-summary-sync (&optional unset-cursor force-range)
1232 (let* ((folder wl-summary-buffer-elmo-folder)
1233 (inhibit-read-only t)
1234 (buffer-read-only nil)
1235 (msgdb-dir (elmo-folder-msgdb-path folder))
1236 (range (or force-range (wl-summary-input-range
1237 (elmo-folder-name-internal folder)))))
1238 (cond ((string-match "rescan" range)
1239 (let ((msg (wl-summary-message-number))
1240 (wl-use-scoring (if (string-match "noscore" range)
1243 (wl-summary-rescan nil
1244 (string-match "noscore" range)
1245 (string-match "thread" range))
1246 (and msg (wl-summary-jump-to-msg msg))))
1247 ((string= range "mark")
1248 (let ((msg (wl-summary-message-number)))
1249 (call-interactively 'wl-summary-sync-marks)
1250 (and msg (wl-summary-jump-to-msg msg))))
1251 ((string= range "cache-status")
1252 (let ((msg (wl-summary-message-number)))
1253 (wl-summary-resume-cache-status)
1254 (and msg (wl-summary-jump-to-msg msg))))
1255 ((string= range "no-sync"))
1256 ((or (string-match "^last:" range)
1257 (string-match "^first:" range))
1258 (wl-summary-goto-folder-subr (concat "/" range "/"
1259 (elmo-folder-name-internal
1261 'force-update nil nil t))
1263 (wl-summary-sync-update unset-cursor
1264 (string-match "entirely" range)
1265 (string-match "all" range))))))
1267 (defvar wl-summary-edit-addresses-candidate-fields
1268 ;; First element becomes default.
1269 '("from" "to" "cc"))
1271 (defun wl-summary-edit-addresses-collect-candidate-fields (mime-charset)
1272 (let ((fields wl-summary-edit-addresses-candidate-fields)
1273 body candidates components)
1276 (mapconcat 'identity (elmo-multiple-field-body (car fields))
1278 (setq body (wl-parse-addresses body))
1279 (if body (setq candidates (append candidates body)))
1280 (setq fields (cdr fields)))
1281 (setq candidates (elmo-uniq-list candidates))
1283 (set-buffer-multibyte default-enable-multibyte-characters)
1286 (setq components (std11-extract-address-components x))
1287 (cons (nth 1 components)
1288 (and (car components)
1289 (eword-decode-string
1290 (decode-mime-charset-string
1295 (defun wl-summary-edit-addresses-subr (the-email name-in-addr)
1296 ;; returns nil if there's no change.
1297 (if (elmo-get-hash-val (downcase the-email) wl-address-petname-hash)
1299 (message "'%s' already exists. (e)dit/(d)elete/(c)ancel?"
1301 (while (not (or (eq (setq char (read-char)) ?\r)
1308 "Please answer `e' or `d' or `c'. (e)dit/(d)elete/(c)ancel?"))
1315 (wl-address-add-or-change
1317 (wl-address-header-extract-realname
1319 (let ((completion-ignore-case t) comp)
1321 (try-completion the-email wl-address-completion-list))
1322 (if (equal comp t) the-email comp))
1323 wl-address-completion-list))))
1327 (if (y-or-n-p (format "Delete '%s'? "
1330 (wl-address-delete the-email)
1337 (wl-address-add-or-change the-email name-in-addr)
1340 (defun wl-summary-edit-addresses (&optional addr-str)
1341 "Edit address book interactively.
1342 Optional argument ADDR-STR is used as a target address if specified."
1343 (interactive (if current-prefix-arg
1344 (list (read-from-minibuffer "Target address: "))))
1345 (if (null (wl-summary-message-number))
1346 (message "No message.")
1348 (let* ((charset wl-summary-buffer-mime-charset)
1350 (with-current-buffer (wl-summary-get-original-buffer)
1351 (wl-summary-edit-addresses-collect-candidate-fields
1353 address pair result)
1355 (setq address addr-str)
1357 (setq address (car (car candidates)))
1360 (format "Target address (%s): " address)
1362 (function (lambda (x) (cons (car x) (car x))))
1364 nil nil nil nil address))))
1366 (setq pair (assoc address candidates))
1368 (setq pair (cons address nil)))
1369 (when (setq result (wl-summary-edit-addresses-subr (car pair) (cdr pair)))
1372 (setq address (assoc (car pair) wl-address-list))
1374 (message "%s, %s, <%s> is %s."
1379 ;;; i'd like to update summary-buffer, but...
1380 ;;; (wl-summary-rescan)
1381 (run-hooks 'wl-summary-edit-addresses-hook))))))
1383 (defun wl-summary-incorporate (&optional arg)
1384 "Check and prefetch all uncached messages.
1385 If ARG is non-nil, checking is omitted."
1389 (wl-summary-sync-force-update)))
1390 (wl-summary-prefetch-region-no-mark (point-min) (point-max)
1391 wl-summary-incorporate-marks))
1393 (defun wl-summary-prefetch-msg (number &optional arg)
1394 "Prefetch message and return non-nil value. If skipped, return nil."
1395 ;; prefetching procedure.
1397 (let* ((size (elmo-message-field wl-summary-buffer-elmo-folder
1399 (file-cached (elmo-file-cache-exists-p
1400 (elmo-message-field wl-summary-buffer-elmo-folder
1401 number 'message-id)))
1402 (force-read (and size
1404 (and (null wl-prefetch-confirm) arg)
1405 (null wl-prefetch-threshold)
1406 (< size wl-prefetch-threshold))))
1409 (when (and (or arg (not file-cached))
1410 size (not force-read) wl-prefetch-confirm)
1411 (let ((wl-message-entity (elmo-message-entity
1412 wl-summary-buffer-elmo-folder
1419 "Message from %s has %d bytes. Prefetch it? "
1423 (wl-set-string-width
1426 wl-summary-from-function
1430 (elmo-message-entity-field
1436 (message ""))) ; flush.
1441 (if (or arg (not file-cached))
1442 (elmo-message-encache
1443 wl-summary-buffer-elmo-folder
1445 (elmo-message-set-cached wl-summary-buffer-elmo-folder
1447 (when (and (wl-summary-jump-to-msg number)
1448 (wl-summary-update-persistent-mark))
1450 (wl-summary-count-unread)
1451 (wl-summary-update-modeline)
1452 (wl-folder-update-unread
1453 (wl-summary-buffer-folder-name)
1454 (+ wl-summary-buffer-unread-count
1455 wl-summary-buffer-new-count))))
1459 (defsubst wl-summary-narrow-to-region (beg end)
1467 (if (eq (current-column) 0) (beginning-of-line) (end-of-line))
1470 (defun wl-summary-prefetch-region-no-mark (beg end &optional prefetch-marks)
1478 (setq start-pos (point))
1480 (wl-summary-narrow-to-region beg end)
1481 ;; collect prefetch targets.
1482 (message "Collecting marks...")
1483 (goto-char (point-min))
1485 (setq mark (wl-summary-persistent-mark)
1486 msg (wl-summary-message-number))
1487 (if (or (and (null prefetch-marks)
1489 (null (elmo-file-cache-exists-p
1491 wl-summary-buffer-elmo-folder
1494 (member mark prefetch-marks))
1495 (setq targets (nconc targets (list msg))))
1496 (setq entity (wl-thread-get-entity msg))
1497 (if (or (not (eq wl-summary-buffer-view 'thread))
1498 (wl-thread-entity-get-opened entity))
1499 (); opened. no hidden children.
1500 (setq targets (nconc
1502 (wl-thread-get-children-msgs-uncached
1503 msg prefetch-marks))))
1505 (setq length (length targets))
1506 (message "Prefetching...")
1508 (when (if (not (wl-thread-entity-parent-invisible-p
1509 (wl-thread-get-entity (car targets))))
1511 (wl-summary-jump-to-msg (car targets))
1512 (wl-summary-prefetch-msg
1513 (wl-summary-message-number)))
1514 (wl-summary-prefetch-msg (car targets)))
1515 (message "Prefetching... %d/%d message(s)"
1516 (setq count (+ 1 count)) length))
1517 (setq targets (cdr targets)))
1518 (message "Prefetched %d/%d message(s)" count length)
1519 (cons count length)))))
1521 (defun wl-summary-delete-marks-on-buffer (marks)
1523 (wl-summary-unmark (pop marks))))
1525 (defun wl-summary-delete-copy-marks-on-buffer (copies)
1526 (wl-summary-delete-marks-on-buffer copies))
1529 (defun wl-summary-delete-all-target-marks ()
1530 (wl-summary-delete-marks-on-buffer wl-summary-buffer-target-mark-list))
1532 (defun wl-summary-mark-as-read-region (beg end)
1536 (wl-summary-narrow-to-region beg end)
1537 (goto-char (point-min))
1538 (if (eq wl-summary-buffer-view 'thread)
1541 (let* ((number (wl-summary-message-number))
1542 (entity (wl-thread-get-entity number)))
1543 (if (wl-thread-entity-get-opened entity)
1544 (setq number-list (append number-list (list number)))
1547 (wl-thread-get-children-msgs number))))
1549 (wl-summary-mark-as-read number-list))
1553 (append number-list (list (wl-summary-message-number))))
1555 (wl-summary-mark-as-read number-list))))))
1557 (defun wl-summary-mark-as-unread-region (beg end)
1561 (wl-summary-narrow-to-region beg end)
1562 (goto-char (point-min))
1563 (if (eq wl-summary-buffer-view 'thread)
1566 (let* ((number (wl-summary-message-number))
1567 (entity (wl-thread-get-entity number)))
1568 (if (wl-thread-entity-get-opened entity)
1569 (setq number-list (append number-list (list number)))
1572 (wl-thread-get-children-msgs number))))
1574 (wl-summary-mark-as-unread number-list))
1578 (append number-list (list (wl-summary-message-number))))
1580 (wl-summary-mark-as-unread number-list))))))
1582 (defun wl-summary-set-flags-region (beg end)
1586 (wl-summary-narrow-to-region beg end)
1587 (goto-char (point-min))
1589 (if (eq wl-summary-buffer-view 'thread)
1591 (let* ((number (wl-summary-message-number))
1592 (entity (wl-thread-get-entity number))
1594 (if (wl-thread-entity-get-opened entity)
1595 ;; opened...mark line.
1596 ;; Crossposts are not processed
1597 (setq flags (wl-summary-set-flags-internal
1601 (setq flags (wl-summary-set-flags-internal
1602 (wl-thread-get-children-msgs number)
1606 (setq flags (wl-summary-set-flags-internal
1607 (wl-summary-message-number) flags))
1608 (forward-line 1))))))
1609 (wl-summary-count-unread)
1610 (wl-summary-update-modeline))
1612 (defun wl-summary-mark-as-answered-region (beg end)
1616 (wl-summary-narrow-to-region beg end)
1617 (goto-char (point-min))
1618 (let ((inverse (elmo-message-flagged-p wl-summary-buffer-elmo-folder
1619 (wl-summary-message-number)
1621 (if (eq wl-summary-buffer-view 'thread)
1623 (let* ((number (wl-summary-message-number))
1624 (entity (wl-thread-get-entity number))
1626 (if (wl-thread-entity-get-opened entity)
1627 ;; opened...mark line.
1628 ;; Crossposts are not processed
1629 (wl-summary-mark-as-answered-internal inverse)
1631 (wl-summary-mark-as-answered-internal
1633 (wl-thread-get-children-msgs number)))
1636 (wl-summary-mark-as-answered-internal inverse)
1637 (forward-line 1))))))
1638 (wl-summary-count-unread)
1639 (wl-summary-update-modeline))
1641 (defun wl-summary-mark-as-important-region (beg end)
1645 (wl-summary-narrow-to-region beg end)
1646 (goto-char (point-min))
1647 (let ((inverse (elmo-message-flagged-p wl-summary-buffer-elmo-folder
1648 (wl-summary-message-number)
1650 (if (eq wl-summary-buffer-view 'thread)
1652 (let* ((number (wl-summary-message-number))
1653 (entity (wl-thread-get-entity number))
1655 (if (wl-thread-entity-get-opened entity)
1656 ;; opened...mark line.
1657 ;; Crossposts are not processed
1658 (wl-summary-mark-as-important-internal inverse)
1660 (wl-summary-mark-as-important-internal
1662 (wl-thread-get-children-msgs number)))
1665 (wl-summary-mark-as-important-internal inverse)
1666 (forward-line 1))))))
1667 (wl-summary-count-unread)
1668 (wl-summary-update-modeline))
1670 (defun wl-summary-mark-as-read-all ()
1672 (if (or (not (interactive-p))
1673 (y-or-n-p "Mark all messages as read? "))
1674 (let ((folder wl-summary-buffer-elmo-folder)
1675 (cur-buf (current-buffer)))
1676 (message "Setting all msgs as read...")
1677 (elmo-folder-set-flag
1679 (elmo-folder-list-flagged folder 'unread 'in-msgdb)
1682 (goto-char (point-min))
1684 (wl-summary-update-persistent-mark)
1686 (wl-folder-update-unread (wl-summary-buffer-folder-name) 0)
1687 (setq wl-summary-buffer-unread-count 0)
1688 (setq wl-summary-buffer-new-count 0)
1689 (wl-summary-update-modeline)
1690 (message "Setting all msgs as read...done"))))
1692 (defun wl-summary-delete-cache ()
1693 "Delete cache of current message."
1696 (let* ((folder wl-summary-buffer-elmo-folder)
1698 (setq number (wl-summary-message-number))
1699 (elmo-message-set-cached folder number nil)
1700 (when (wl-summary-update-persistent-mark)
1701 (elmo-file-cache-delete
1702 (elmo-file-cache-get-path
1703 (elmo-message-field wl-summary-buffer-elmo-folder
1707 (defun wl-summary-resume-cache-status ()
1708 "Resume the cache status of all messages in the current folder."
1710 (let ((folder wl-summary-buffer-elmo-folder)
1712 (message "Resuming cache status...")
1714 (goto-char (point-min))
1716 (setq number (wl-summary-message-number))
1717 (setq msgid (elmo-message-field folder number 'message-id))
1718 (elmo-message-set-cached folder number
1719 (elmo-file-cache-exists-p msgid))
1720 (wl-summary-update-persistent-mark)
1722 (wl-summary-count-unread)
1723 (wl-summary-update-modeline)
1724 (message "Resuming cache status...done"))))
1726 (defun wl-summary-delete-messages-on-buffer (msgs &optional deleting-info)
1729 (let ((inhibit-read-only t)
1730 (buffer-read-only nil)
1734 ;(deleting-info (or deleting-info "Deleting..."))
1736 (elmo-kill-buffer wl-summary-search-buf-name)
1738 (if (eq wl-summary-buffer-view 'thread)
1740 ;; don't use wl-append(nconc), because list is broken. ...why?
1743 (wl-thread-delete-message (car msgs))))
1744 (setq update-list (delq (car msgs) update-list)))
1745 (goto-char (point-min))
1746 (if (wl-summary-jump-to-msg (car msgs))
1748 (delete-region (point-at-bol) (point-at-eol))
1749 (delete-char 1) ; delete '\n'
1750 (setq wl-summary-buffer-number-list
1751 (delq (car msgs) wl-summary-buffer-number-list)))))
1752 ; (when (> len elmo-display-progress-threshold)
1754 ; (if (or (zerop (% i 5)) (= i len))
1755 ; (elmo-display-progress
1756 ; 'wl-summary-delete-messages-on-buffer deleting-info
1757 ; (/ (* i 100) len))))
1758 (setq msgs (cdr msgs)))
1759 (when (eq wl-summary-buffer-view 'thread)
1760 (wl-thread-update-line-msgs (elmo-uniq-list update-list))
1761 (wl-thread-cleanup-symbols msgs2))
1762 ;;(message (concat deleting-info "done"))
1763 (wl-summary-count-unread)
1764 (wl-summary-update-modeline)
1765 (wl-summary-folder-info-update))))
1767 (defun wl-summary-update-status-marks (beg end &optional check)
1768 "Synchronize status marks on current buffer to the msgdb."
1772 (while (and (< (point) end) (not (eobp)))
1773 (when (or (not check)
1774 (let ((number (wl-summary-message-number)))
1775 (when (memq number wl-summary-buffer-unsync-mark-number-list)
1776 (setq wl-summary-buffer-unsync-mark-number-list
1778 wl-summary-buffer-unsync-mark-number-list))
1780 (wl-summary-update-persistent-mark))
1783 (defun wl-summary-update-mark-window (&optional win beg)
1784 "Update persistent mark in visible summary window.
1785 This function is defined for `window-scroll-functions'"
1786 (with-current-buffer (window-buffer win)
1787 (when (eq major-mode 'wl-summary-mode)
1788 (let ((start (window-start win))
1789 (end (condition-case nil
1790 (window-end win t) ; old emacsen doesn't support 2nd arg.
1791 (error (window-end win)))))
1792 (wl-summary-update-status-marks start end 'check)))))
1794 (defun wl-summary-insert-message (&rest args)
1795 (if (eq wl-summary-buffer-view 'thread)
1796 (apply 'wl-summary-insert-thread args)
1797 (apply 'wl-summary-insert-sequential args)))
1799 (defun wl-summary-sort ()
1803 (format "Sort by (%s): " (symbol-name wl-summary-default-sort-spec))
1804 (mapcar (lambda (spec)
1805 (list (symbol-name spec)))
1806 wl-summary-sort-specs)
1807 nil t nil nil (symbol-name wl-summary-default-sort-spec))))
1809 (defun wl-summary-sync-marks ()
1810 "Update persistent marks in summary."
1812 (let ((mes "Updated ")
1814 ;; synchronize marks.
1815 (when (not (eq (elmo-folder-type-internal
1816 wl-summary-buffer-elmo-folder)
1819 (message "Updating marks...")
1820 (dolist (flag elmo-global-flag-list)
1821 (unless (memq flag '(answered cached new unread))
1822 (setq diff (elmo-list-diff (elmo-folder-list-flagged
1823 wl-summary-buffer-elmo-folder
1825 (elmo-folder-list-flagged
1826 wl-summary-buffer-elmo-folder
1828 (setq diffs (cadr diff)) ; deletes
1829 (setq mes (concat mes (format "-%d" (length diffs))))
1831 (wl-summary-remove-flags-internal (car diffs)
1832 (list flag) 'no-server)
1833 (setq diffs (cdr diffs)))
1834 (setq diffs (car diff)) ; appends
1835 (setq mes (concat mes (format "/+%d %s," (length diffs) flag)))
1837 (wl-summary-add-flags-internal (car diffs)
1838 (list flag) 'no-server)
1839 (setq diffs (cdr diffs)))))
1841 (setq diff (elmo-list-diff (elmo-folder-list-flagged
1842 wl-summary-buffer-elmo-folder
1844 (elmo-folder-list-flagged
1845 wl-summary-buffer-elmo-folder
1846 'answered 'in-msgdb)))
1847 (setq diffs (cadr diff))
1848 (setq mes (concat mes (format "-%d" (length diffs))))
1850 (wl-summary-mark-as-unanswered (car diffs) 'no-modeline)
1851 (setq diffs (cdr diffs)))
1852 (setq diffs (car diff)) ; unread-appends
1853 (setq mes (concat mes (format "/+%d answered," (length diffs))))
1855 (wl-summary-mark-as-answered (car diffs) 'no-modeline)
1856 (setq diffs (cdr diffs)))
1858 (setq diff (elmo-list-diff (elmo-folder-list-flagged
1859 wl-summary-buffer-elmo-folder
1861 (elmo-folder-list-flagged
1862 wl-summary-buffer-elmo-folder
1863 'unread 'in-msgdb)))
1864 (setq diffs (cadr diff))
1865 (setq mes (concat mes (format "-%d" (length diffs))))
1867 (wl-summary-mark-as-read (car diffs) 'no-folder 'no-modeline)
1868 (setq diffs (cdr diffs)))
1869 (setq diffs (car diff)) ; unread-appends
1870 (setq mes (concat mes (format "/+%d unread." (length diffs))))
1872 (wl-summary-mark-as-unread (car diffs) 'no-folder 'no-modeline)
1873 (setq diffs (cdr diffs)))
1874 (if (interactive-p) (message "%s" mes)))))
1876 (defun wl-summary-sync-update (&optional unset-cursor
1880 "Update the summary view to the newest folder status."
1882 (let* ((folder wl-summary-buffer-elmo-folder)
1883 (elmo-mime-charset wl-summary-buffer-mime-charset)
1884 (inhibit-read-only t)
1885 (buffer-read-only nil)
1889 append-list delete-list crossed
1890 update-thread update-top-list
1891 expunged mes entity)
1894 (unless wl-summary-buffer-elmo-folder
1895 (error "(Internal error) Folder is not set:%s" (buffer-name
1897 ;; Flush pending append operations (disconnected operation).
1899 ;;(wl-summary-flush-pending-append-operations seen-list))
1900 (goto-char (point-max))
1901 (wl-folder-confirm-existence folder (elmo-folder-plugged-p folder))
1902 (setq crossed (elmo-folder-synchronize folder
1907 (let ((wl-summary-highlight
1908 (and wl-summary-highlight
1909 (not wl-summary-lazy-highlight))))
1911 (if sync-all (wl-summary-sync-all-init))
1912 (setq diff (elmo-list-diff (elmo-folder-list-messages
1914 (not disable-killed)
1916 wl-summary-buffer-number-list))
1917 (setq append-list (car diff))
1918 (setq delete-list (cadr diff))
1921 (wl-summary-delete-messages-on-buffer delete-list))
1922 (unless wl-summary-lazy-update-mark
1923 (wl-summary-update-status-marks (point-min) (point-max)))
1924 (when (and wl-summary-lazy-highlight
1925 wl-summary-lazy-update-mark)
1926 (let (buffer-read-only)
1927 (put-text-property (point-min) (point-max) 'face nil)))
1928 (setq num (length append-list))
1930 (setq wl-summary-delayed-update nil)
1931 (elmo-kill-buffer wl-summary-search-buf-name)
1932 (dolist (number append-list)
1933 (setq entity (elmo-message-entity folder number))
1934 (when (setq update-thread
1935 (wl-summary-insert-message
1938 (wl-append update-top-list update-thread))
1939 (if elmo-use-database
1940 (elmo-database-msgid-put
1941 (car entity) (elmo-folder-name-internal folder)
1942 (elmo-message-entity-number entity)))
1943 (when (> num elmo-display-progress-threshold)
1945 (if (or (zerop (% i 5)) (= i num))
1946 (elmo-display-progress
1947 'wl-summary-sync-update
1948 (if (eq wl-summary-buffer-view 'thread)
1950 "Inserting message...")
1951 (/ (* i 100) num)))))
1952 (when wl-summary-delayed-update
1953 (while wl-summary-delayed-update
1954 (message "Parent (%d) of message %d is no entity"
1955 (caar wl-summary-delayed-update)
1956 (elmo-message-entity-number
1957 (cdar wl-summary-delayed-update)))
1958 (when (setq update-thread
1959 (wl-summary-insert-message
1960 (cdar wl-summary-delayed-update)
1961 wl-summary-buffer-elmo-folder
1963 (wl-append update-top-list update-thread))
1964 (setq wl-summary-delayed-update
1965 (cdr wl-summary-delayed-update))))
1966 (when (and (eq wl-summary-buffer-view 'thread)
1968 (wl-thread-update-indent-string-thread
1969 (elmo-uniq-list update-top-list)))
1970 (message (if (eq wl-summary-buffer-view 'thread)
1971 "Making thread...done"
1972 "Inserting message...done"))
1973 (when (or delete-list append-list)
1974 (wl-summary-set-message-modified))
1975 (when (and sync-all (eq wl-summary-buffer-view 'thread))
1976 (elmo-kill-buffer wl-summary-search-buf-name)
1977 (message "Inserting message...")
1978 (wl-thread-insert-top)
1979 (message "Inserting message...done"))
1980 (if elmo-use-database
1981 (elmo-database-close))
1982 (run-hooks 'wl-summary-sync-updated-hook)
1984 (if (and (eq (length delete-list) 0)
1987 "No updates for \"%s\"" (elmo-folder-name-internal
1989 (format "Updated (-%d/+%d) message(s)"
1990 (length delete-list) num))))
1991 (setq mes "Quit updating")))
1992 ;; synchronize marks.
1993 (if (and crossed wl-summary-auto-sync-marks)
1994 (wl-summary-sync-marks))
1996 (when wl-use-scoring
1997 (setq wl-summary-scored nil)
1998 (wl-summary-score-headers (and sync-all
1999 (wl-summary-rescore-msgs
2000 wl-summary-buffer-number-list))
2002 (when (and wl-summary-scored
2003 (setq expunged (wl-summary-score-update-all-lines)))
2004 (setq mes (concat mes
2005 (format " (%d expunged)"
2006 (length expunged))))))
2007 (if (and crossed (> crossed 0))
2011 (format " (%d crosspost)" crossed))
2012 (format "%d crosspost message(s)" crossed)))
2013 (and mes (setq mes (concat mes "."))))
2014 ;; Update Folder mode
2015 (wl-folder-set-folder-updated
2016 (elmo-folder-name-internal folder)
2018 (let ((lst (wl-summary-count-unread)))
2019 (+ (car lst) (nth 1 lst)))
2020 (elmo-folder-length folder)))
2021 (wl-summary-update-modeline)
2023 (unless unset-cursor
2024 (goto-char (point-min))
2025 (if (not (wl-summary-cursor-down t))
2027 (goto-char (point-max))
2029 (when (and wl-summary-highlight
2030 (not wl-summary-lazy-highlight)
2031 (not (get-text-property (point) 'face)))
2035 wl-summary-partial-highlight-above-lines
2036 wl-summary-highlight-partial-threshold)))
2037 (wl-highlight-summary (point) (point-max))))))
2038 (wl-delete-all-overlays)
2039 (run-hooks 'wl-summary-buffer-window-scroll-functions)
2040 (set-buffer-modified-p nil)
2041 (if mes (message "%s" mes)))))
2043 (defun wl-summary-set-score-mark (mark)
2046 (let ((cur-mark (wl-summary-temp-mark)))
2047 (when (member cur-mark (list " "
2048 wl-summary-score-below-mark
2049 wl-summary-score-over-mark))
2050 (wl-summary-put-temp-mark mark)
2051 (if wl-summary-highlight
2052 (wl-highlight-summary-current-line))
2053 (set-buffer-modified-p nil)))))
2055 (defun wl-summary-get-score-mark (msg-num)
2056 (let ((score (cdr (assq msg-num wl-summary-scored))))
2058 (cond ((< score wl-summary-default-score)
2060 ((> score wl-summary-default-score)
2063 (defun wl-summary-update-modeline ()
2064 (setq wl-summary-buffer-mode-line
2065 (funcall wl-summary-buffer-mode-line-formatter)))
2067 (defun wl-summary-jump-to-msg (&optional number)
2069 (let ((num (or number
2071 (read-from-minibuffer "Jump to Message(No.): ")))))
2072 (setq num (int-to-string num))
2074 (if (or (and (re-search-forward (concat "\r" num "[^0-9]") nil t)
2075 (progn (backward-char 1) t))
2076 (re-search-backward (concat "\r" num "[^0-9]") nil t))
2077 (progn (beginning-of-line) t)
2080 (defun wl-summary-highlight-msgs (msgs)
2082 (let ((len (length msgs))
2084 (message "Hilighting...")
2087 (if (wl-summary-jump-to-msg (car msgs))
2088 (wl-highlight-summary-current-line))
2089 (setq msgs (cdr msgs))
2090 (when (> len elmo-display-progress-threshold)
2092 (if (or (zerop (% i 5)) (= i len))
2093 (elmo-display-progress
2094 'wl-summary-highlight-msgs "Highlighting..."
2095 (/ (* i 100) len)))))
2096 (message "Highlighting...done"))))
2098 (defun wl-summary-message-number ()
2101 (if (or (re-search-forward "\r\\(-?[0-9]+\\)" (point-at-eol) t)
2102 (re-search-forward "^ *\\(-?[0-9]+\\)" (point-at-eol) t))
2103 (string-to-int (wl-match-buffer 1))
2106 (defun wl-summary-delete-all-msgs ()
2108 (let ((cur-buf (current-buffer))
2109 (dels (elmo-folder-list-messages wl-summary-buffer-elmo-folder)))
2110 (set-buffer cur-buf)
2112 (message "No message to delete.")
2113 (if (y-or-n-p (format "%s has %d message(s). Delete all? "
2114 (wl-summary-buffer-folder-name)
2117 (message "Deleting...")
2118 (elmo-folder-move-messages wl-summary-buffer-elmo-folder dels
2120 (wl-summary-set-message-modified)
2121 (wl-folder-set-folder-updated (wl-summary-buffer-folder-name)
2124 ;;; (setq wl-thread-top-entity '(nil t nil nil))
2125 (setq wl-summary-buffer-unread-count 0)
2126 (setq wl-summary-buffer-new-count 0)
2127 (wl-summary-update-modeline)
2128 (set-buffer cur-buf)
2129 (let ((inhibit-read-only t)
2130 (buffer-read-only nil))
2132 ;;; (if wl-summary-cache-use (wl-summary-save-view-cache))
2133 (message "Deleting...done")
2137 (defun wl-summary-toggle-thread (&optional arg)
2138 "Toggle thread status (T)hread and (S)equential.
2139 If ARG, without confirm."
2142 (y-or-n-p (format "Toggle threading? (y=%s): "
2143 (if (eq wl-summary-buffer-view 'thread)
2144 "\"off\"" "\"on\""))))
2145 (if (eq wl-summary-buffer-view 'thread)
2146 (setq wl-summary-buffer-view 'sequence)
2147 (setq wl-summary-buffer-view 'thread))
2148 (wl-summary-update-modeline)
2149 (force-mode-line-update)
2150 (wl-summary-rescan nil nil t)))
2152 (defun wl-summary-load-file-object (filename)
2153 "Load lisp object from dir."
2155 (let ((tmp-buffer (get-buffer-create " *wl-summary-load-file-object*"))
2156 insert-file-contents-pre-hook ; To avoid autoconv-xmas...
2157 insert-file-contents-post-hook
2159 (if (not (file-readable-p filename))
2161 (set-buffer tmp-buffer)
2162 (as-binary-input-file (insert-file-contents filename))
2165 (read (current-buffer))
2166 (error (error "Reading failed")))))
2167 (kill-buffer tmp-buffer)
2170 (defun wl-summary-goto-folder (&optional arg)
2172 (wl-summary-goto-folder-subr nil nil nil nil t nil arg))
2174 (defun wl-summary-goto-folder-sticky ()
2176 (wl-summary-goto-folder-subr nil nil nil t t))
2178 (defun wl-summary-goto-last-visited-folder ()
2181 (wl-folder-search-entity-by-name wl-summary-last-visited-folder
2184 (if entity (wl-folder-set-current-entity-id
2185 (wl-folder-get-entity-id entity))))
2186 (wl-summary-goto-folder-subr wl-summary-last-visited-folder nil nil nil t))
2188 (defun wl-summary-sticky-p (&optional folder)
2190 (get-buffer (wl-summary-sticky-buffer-name
2191 (elmo-folder-name-internal folder)))
2192 (not (string= wl-summary-buffer-name (buffer-name)))))
2194 (defun wl-summary-always-sticky-folder-p (folder)
2195 (or (eq t wl-summary-always-sticky-folder-list)
2196 (wl-string-match-member
2197 (elmo-folder-name-internal folder)
2198 wl-summary-always-sticky-folder-list)))
2200 (defun wl-summary-stick (&optional force)
2201 "Make current summary buffer sticky."
2203 (if (wl-summary-sticky-p)
2204 (message "Current summary buffer is already sticky.")
2205 (when (or force (y-or-n-p "Stick current summary buffer? "))
2206 (wl-summary-toggle-disp-msg 'off)
2207 (wl-summary-switch-to-clone-buffer
2208 (wl-summary-sticky-buffer-name
2209 (wl-summary-buffer-folder-name)))
2211 ;;; (rename-buffer (wl-summary-sticky-buffer-name
2212 ;;; (wl-summary-buffer-folder-name))))
2213 (message "Folder `%s' is now sticky." (wl-summary-buffer-folder-name)))))
2215 (defun wl-summary-switch-to-clone-buffer (buffer-name)
2216 (let ((cur-buf (current-buffer))
2217 (msg (wl-summary-message-number))
2218 (buf (get-buffer-create buffer-name))
2219 (folder wl-summary-buffer-elmo-folder)
2221 (append '(wl-summary-buffer-view
2222 wl-summary-buffer-temp-mark-list
2223 wl-summary-buffer-target-mark-list
2224 wl-summary-buffer-elmo-folder
2225 wl-summary-buffer-number-column
2226 wl-summary-buffer-temp-mark-column
2227 wl-summary-buffer-persistent-mark-column
2228 wl-summary-buffer-message-modified
2229 wl-summary-buffer-thread-modified
2230 wl-summary-buffer-number-list
2231 wl-summary-buffer-unsync-mark-number-list
2232 wl-summary-buffer-folder-name
2233 wl-summary-buffer-line-formatter)
2234 (and (eq wl-summary-buffer-view 'thread)
2235 '(wl-thread-entity-hashtb
2237 wl-thread-entity-list))
2240 wl-summary-default-score
2241 wl-summary-important-above
2242 wl-summary-target-above
2243 wl-summary-mark-below
2244 wl-summary-expunge-below))
2245 (and (featurep 'wl-score)
2246 '(wl-current-score-file
2250 (wl-summary-buffer-set-folder folder)
2251 (let ((buffer-read-only nil))
2252 (insert-buffer cur-buf))
2253 (set-buffer-modified-p nil)
2254 (while copy-variables
2255 (set (car copy-variables)
2257 (set-buffer cur-buf)
2258 (symbol-value (car copy-variables))))
2259 (setq copy-variables (cdr copy-variables)))
2260 (switch-to-buffer buf)
2261 (kill-buffer cur-buf)
2262 (wl-summary-count-unread)
2263 (wl-summary-update-modeline)
2265 (if (eq wl-summary-buffer-view 'thread)
2266 (wl-thread-jump-to-msg msg)
2267 (wl-summary-jump-to-msg msg))
2268 (goto-char (point-max))
2269 (beginning-of-line))))
2271 (defun wl-summary-get-buffer (folder)
2273 (get-buffer (wl-summary-sticky-buffer-name folder)))
2274 (get-buffer wl-summary-buffer-name)))
2276 (defun wl-summary-get-buffer-create (name &optional force-sticky)
2279 (wl-summary-sticky-buffer-name name))
2280 (or (get-buffer (wl-summary-sticky-buffer-name name))
2281 (get-buffer-create wl-summary-buffer-name))))
2283 (defun wl-summary-make-number-list ()
2285 (goto-char (point-min))
2286 (setq wl-summary-buffer-number-list nil)
2288 (setq wl-summary-buffer-number-list
2289 (cons (wl-summary-message-number)
2290 wl-summary-buffer-number-list))
2292 (setq wl-summary-buffer-number-list
2293 (nreverse wl-summary-buffer-number-list))))
2295 (defun wl-summary-auto-select-msg-p (unread-msg)
2297 (not (elmo-message-has-global-flag-p
2298 wl-summary-buffer-elmo-folder unread-msg))))
2300 (defsubst wl-summary-open-folder (folder)
2302 (let ((elmo-mime-charset wl-summary-buffer-mime-charset))
2304 (elmo-folder-open folder 'load-msgdb)
2305 ;; For compatibility
2306 (setq wl-summary-buffer-folder-name (elmo-folder-name-internal
2309 (defun wl-summary-goto-folder-subr (&optional name scan-type other-window
2310 sticky interactive scoring
2312 "Display target folder on summary."
2314 (let* ((keep-cursor (memq this-command
2315 wl-summary-keep-cursor-command))
2316 (name (or name (wl-summary-read-folder wl-default-folder)))
2317 (cur-fld wl-summary-buffer-elmo-folder)
2318 folder buf mes hilit reuse-buf
2320 (if (string= name "")
2321 (setq name wl-default-folder))
2322 (setq folder (wl-folder-get-elmo-folder name))
2323 (when (and (not (string=
2324 (and cur-fld (elmo-folder-name-internal cur-fld))
2325 (elmo-folder-name-internal folder))) ; folder is moved.
2326 (eq major-mode 'wl-summary-mode)) ; called in summary.
2327 (setq wl-summary-last-visited-folder (wl-summary-buffer-folder-name))
2328 (run-hooks 'wl-summary-exit-pre-hook)
2329 (if (or force-exit (not (wl-summary-sticky-p)))
2330 (wl-summary-cleanup-temp-marks))
2331 (wl-summary-save-view)
2332 (elmo-folder-commit wl-summary-buffer-elmo-folder)
2333 (if (and (wl-summary-sticky-p) force-exit)
2334 (kill-buffer (current-buffer))))
2335 (setq buf (wl-summary-get-buffer-create (elmo-folder-name-internal folder)
2340 (string= (elmo-folder-name-internal folder)
2341 (wl-summary-buffer-folder-name))))
2345 (switch-to-buffer buf)
2348 (delete-other-windows))
2350 (unless (eq major-mode 'wl-summary-mode)
2352 (wl-summary-buffer-set-folder folder)
2353 (setq wl-summary-buffer-disp-msg nil)
2354 (setq wl-summary-buffer-last-displayed-msg nil)
2355 (setq wl-summary-buffer-current-msg nil)
2356 (let ((inhibit-read-only t)
2357 (buffer-read-only nil))
2359 ;; Resume summary view
2360 (if wl-summary-cache-use
2361 (let* ((dir (elmo-folder-msgdb-path folder))
2362 (cache (expand-file-name wl-summary-cache-file dir))
2363 (view (expand-file-name wl-summary-view-file dir)))
2364 (when (file-exists-p cache)
2365 (insert-file-contents-as-binary cache)
2366 (set-buffer-multibyte
2367 default-enable-multibyte-characters)
2368 (decode-mime-charset-region
2369 (point-min)(point-max)
2370 wl-summary-buffer-mime-charset 'LF))
2371 (if (file-exists-p view)
2372 (setq wl-summary-buffer-view
2373 (wl-summary-load-file-object view))
2374 (setq wl-summary-buffer-view
2375 (or (wl-get-assoc-list-value
2376 wl-summary-default-view-alist
2377 (elmo-folder-name-internal folder))
2378 wl-summary-default-view)))
2379 (wl-thread-resume-entity folder)
2380 (wl-summary-open-folder folder)
2381 (wl-summary-detect-mark-position))
2382 (setq wl-summary-buffer-view
2383 (wl-summary-load-file-object
2384 (expand-file-name wl-summary-view-file
2385 (elmo-folder-msgdb-path folder))))
2386 (wl-summary-open-folder folder)
2387 (wl-summary-detect-mark-position)
2388 (wl-summary-rescan))
2389 (wl-summary-count-unread)
2390 (wl-summary-update-modeline)))
2391 (unless (eq wl-summary-buffer-view 'thread)
2392 (wl-summary-make-number-list))
2393 (setq wl-summary-buffer-unsync-mark-number-list
2394 (copy-sequence wl-summary-buffer-number-list))
2395 (when (and wl-summary-cache-use
2396 (or (and wl-summary-check-line-format
2397 (wl-summary-line-format-changed-p))
2398 (wl-summary-view-old-p)))
2399 (wl-summary-rescan))
2400 (wl-summary-toggle-disp-msg (if wl-summary-buffer-disp-msg 'on 'off))
2401 (unless (and reuse-buf keep-cursor)
2403 (let ((wl-use-scoring
2404 (if (or scoring interactive) wl-use-scoring)))
2405 (if (and (not scan-type)
2408 (setq scan-type (wl-summary-get-sync-range folder)))
2411 (wl-summary-sync 'unset-cursor))
2412 ((eq scan-type 'all)
2413 (wl-summary-sync 'unset-cursor "all"))
2414 ((eq scan-type 'no-sync))
2415 ((eq scan-type 'rescan)
2416 (wl-summary-rescan))
2417 ((or (eq scan-type 'force-update)
2418 (eq scan-type 'update))
2419 (setq mes (wl-summary-sync-force-update
2422 (switch-to-buffer buf)
2424 ;; stick always-sticky-folder
2425 (when (wl-summary-always-sticky-folder-p folder)
2426 (or (wl-summary-sticky-p) (wl-summary-stick t)))
2427 (run-hooks 'wl-summary-prepared-pre-hook)
2428 (set-buffer-modified-p nil)
2429 (goto-char (point-min))
2430 (if (wl-summary-cursor-down t)
2431 (let ((unreadp (wl-summary-next-message
2432 (wl-summary-message-number)
2434 (cond ((and wl-auto-select-first
2435 (wl-summary-auto-select-msg-p unreadp))
2436 ;; wl-auto-select-first is non-nil and
2437 ;; unreadp is non-nil but not flagged
2438 (setq retval 'disp-msg))
2439 ((and wl-auto-prefetch-first
2440 (wl-summary-auto-select-msg-p unreadp))
2441 ;; wl-auto-select-first is non-nil and
2442 ;; unreadp is non-nil but not flagged
2443 (setq retval 'prefetch-msg))
2444 ((not (wl-summary-auto-select-msg-p unreadp))
2445 ;; unreadp is nil or flagged
2446 (setq retval 'more-next))))
2447 (goto-char (point-max))
2448 (if (elmo-folder-plugged-p folder)
2451 (setq retval 'more-next))
2452 (if (and wl-summary-highlight
2453 (not wl-summary-lazy-highlight)
2455 (if (and wl-summary-highlight-partial-threshold
2456 (> (count-lines (point-min) (point-max))
2457 wl-summary-highlight-partial-threshold))
2462 wl-summary-partial-highlight-above-lines
2463 wl-summary-highlight-partial-threshold)))
2464 (wl-highlight-summary (point) (point-max)))
2465 (wl-highlight-summary (point-min) (point-max))))
2466 (if (eq retval 'disp-msg)
2467 (wl-summary-redisplay))
2468 (if (eq retval 'prefetch-msg)
2469 (wl-message-buffer-prefetch
2471 (wl-summary-message-number)
2472 wl-message-buffer-prefetch-depth
2474 wl-summary-buffer-mime-charset))
2475 (if mes (message "%s" mes))
2476 (if (and interactive wl-summary-recenter)
2477 (recenter (/ (- (window-height) 2) 2))))))
2478 ;; set current entity-id
2481 (wl-folder-search-entity-by-name
2482 (elmo-folder-name-internal folder)
2485 ;; entity-id is unknown.
2486 (wl-folder-set-current-entity-id
2487 (wl-folder-get-entity-id entity)))
2488 (when (and wl-summary-buffer-window-scroll-functions
2492 (run-hooks 'wl-summary-prepared-hook)
2493 (set-buffer-modified-p nil))
2496 (defun wl-summary-goto-previous-message-beginning ()
2498 (re-search-backward "\r\\(-?[0-9]+\\)" nil t)
2499 (beginning-of-line))
2501 (defun wl-summary-goto-top-of-current-thread ()
2502 (wl-summary-jump-to-msg
2503 (wl-thread-entity-get-number
2504 (wl-thread-entity-get-top-entity (wl-thread-get-entity
2505 (wl-summary-message-number))))))
2507 (defun wl-summary-goto-bottom-of-sub-thread (&optional depth)
2509 (let ((depth (or depth
2510 (wl-thread-get-depth-of-current-line))))
2512 (while (and (not (eobp))
2513 (>= (wl-thread-get-depth-of-current-line)
2516 (beginning-of-line)))
2518 (defun wl-summary-insert-line (line)
2519 "Insert LINE in the Summary."
2520 (if wl-use-highlight-mouse-line
2521 ;; remove 'mouse-face of current line.
2523 (save-excursion (beginning-of-line)(point))
2524 (save-excursion (end-of-line)(point))
2527 (if wl-use-highlight-mouse-line
2528 ;; remove 'mouse-face of current line.
2530 (save-excursion (beginning-of-line)(point))
2531 (save-excursion (end-of-line)(point))
2534 (run-hooks 'wl-summary-line-inserted-hook)))
2536 (defun wl-summary-insert-sequential (entity folder &rest args)
2538 (let ((inhibit-read-only t)
2539 (number (elmo-message-entity-number entity))
2541 (goto-char (point-max))
2542 (wl-summary-insert-line
2543 (wl-summary-create-line entity nil nil
2545 wl-summary-buffer-elmo-folder
2547 (elmo-message-cached-p
2548 wl-summary-buffer-elmo-folder
2550 (setq wl-summary-buffer-number-list
2551 (wl-append wl-summary-buffer-number-list
2552 (list (elmo-message-entity-number entity))))
2555 (defun wl-summary-default-subject-filter (subject)
2556 (setq subject (elmo-replace-in-string subject "[ \t]*\\(re\\|was\\)[:>]" ""))
2557 (setq subject (elmo-replace-in-string subject "[ \t]" ""))
2558 (elmo-replace-in-string subject "^\\[.*\\]" ""))
2560 (defun wl-summary-subject-equal (subject1 subject2)
2561 (string= (funcall wl-summary-subject-filter-function subject1)
2562 (funcall wl-summary-subject-filter-function subject2)))
2564 (defmacro wl-summary-put-alike (alike)
2565 (` (elmo-set-hash-val (format "#%d" (wl-count-lines))
2567 wl-summary-alike-hashtb)))
2569 (defmacro wl-summary-get-alike ()
2570 (` (elmo-get-hash-val (format "#%d" (wl-count-lines))
2571 wl-summary-alike-hashtb)))
2573 (defun wl-summary-insert-headers (folder func mime-decode)
2574 (let ((numbers (elmo-folder-list-messages folder 'visible t))
2576 (buffer-disable-undo (current-buffer))
2577 (make-local-variable 'wl-summary-alike-hashtb)
2578 (setq wl-summary-alike-hashtb (elmo-make-hash (* (length numbers) 2)))
2580 (set-buffer-multibyte default-enable-multibyte-characters))
2581 (while (setq ov (elmo-message-entity folder (pop numbers)))
2582 (setq this (funcall func ov))
2583 (and this (setq this (std11-unfold-string this)))
2584 (if (equal last this)
2585 (setq alike (cons ov alike))
2587 (wl-summary-put-alike alike)
2589 (setq alike (list ov)
2592 (wl-summary-put-alike alike)
2595 (decode-mime-charset-region (point-min) (point-max)
2597 (when (eq mime-decode 'mime)
2598 (eword-decode-region (point-min) (point-max))))
2599 (run-hooks 'wl-summary-insert-headers-hook)))
2601 (defun wl-summary-search-by-subject (entity folder)
2602 (let ((summary-buf (current-buffer))
2603 (buf (get-buffer-create wl-summary-search-buf-name))
2604 (folder-name (wl-summary-buffer-folder-name))
2605 match founds result)
2606 (with-current-buffer buf
2607 (let ((case-fold-search t))
2608 (when (or (not (string= wl-summary-search-buf-folder-name folder-name))
2609 (zerop (buffer-size)))
2610 (setq wl-summary-search-buf-folder-name folder-name)
2611 (message "Creating subject cache...")
2612 (wl-summary-insert-headers
2616 (funcall wl-summary-subject-filter-function
2617 (elmo-message-entity-field x 'subject))))
2619 (message "Creating subject cache...done"))
2620 (setq match (funcall wl-summary-subject-filter-function
2621 (elmo-message-entity-field entity 'subject
2623 (if (string= match "")
2625 (goto-char (point-max))
2626 (while (and (null result)
2627 (not (= (point) (point-min)))
2628 (search-backward match nil t))
2629 ;; check exactly match
2630 (when (and (bolp) (= (point-at-eol)(match-end 0)))
2631 (setq founds (wl-summary-get-alike))
2632 (with-current-buffer summary-buf
2635 ;; the first element of found-entity list exists on
2637 (wl-thread-get-entity
2638 (elmo-message-entity-number (car founds)))
2639 ;; message id is not same as myself.
2641 (elmo-message-entity-field entity 'message-id)
2642 (elmo-message-entity-field (car founds)
2644 ;; not a descendant.
2645 (not (wl-thread-descendant-p
2646 (elmo-message-entity-number entity)
2647 (elmo-message-entity-number (car founds)))))
2648 (setq result (car founds)
2650 (setq founds (cdr founds))))))
2653 (defun wl-summary-insert-thread (entity folder update
2654 &optional force-insert)
2656 this-id parent-entity parent-number
2657 number cur-entity linked retval delayed-entity
2658 update-list entity-stack thread-entity)
2660 (setq this-id (elmo-message-entity-field entity 'message-id)
2661 number (elmo-message-entity-number entity))
2662 (if (and wl-thread-saved-entity-hashtb-internal
2665 (format "#%d" (elmo-message-entity-number entity))
2666 wl-thread-saved-entity-hashtb-internal)))
2668 (elmo-message-entity
2670 (wl-thread-entity-get-parent thread-entity))
2671 linked (wl-thread-entity-get-linked thread-entity))
2672 (setq parent-entity (elmo-message-entity-parent folder entity)
2674 (setq parent-number (and parent-entity
2675 (elmo-message-entity-number parent-entity)))
2676 ;; If thread loop detected, set parent as nil.
2681 (elmo-message-entity-number
2682 (setq cur (elmo-message-entity-parent folder cur))))
2683 (if (memq anumber relatives)
2684 (setq parent-number nil
2686 (setq relatives (cons anumber relatives)))))
2687 (if (and parent-number
2688 (not (wl-thread-get-entity parent-number))
2690 ;; parent exists in overview, but not in wl-thread-entities
2692 (wl-append wl-summary-delayed-update
2693 (list (cons parent-number entity)))
2694 (setq entity nil)) ;; exit loop
2695 ;; Search parent by subject.
2696 (when (and (null parent-number)
2697 wl-summary-search-parent-by-subject-regexp
2699 wl-summary-search-parent-by-subject-regexp
2700 (elmo-message-entity-field entity 'subject)))
2701 (let ((found (wl-summary-search-by-subject entity folder)))
2703 (not (member found wl-summary-delayed-update)))
2704 (setq parent-entity found)
2706 (elmo-message-entity-number parent-entity))
2708 ;; If subject is change, divide thread.
2709 (if (and parent-number
2710 wl-summary-divide-thread-when-subject-changed
2711 (not (wl-summary-subject-equal
2712 (or (elmo-message-entity-field entity
2714 (or (elmo-message-entity-field parent-entity
2716 (setq parent-number nil))
2718 (wl-thread-insert-message entity
2719 number parent-number update linked))
2721 (wl-append update-list (list retval)))
2722 (setq entity nil) ; exit loop
2723 (while (setq delayed-entity (assq number wl-summary-delayed-update))
2724 (setq wl-summary-delayed-update
2725 (delq delayed-entity wl-summary-delayed-update))
2726 ;; update delayed message
2727 (wl-append entity-stack (list (cdr delayed-entity)))))
2728 (if (and (not entity)
2730 (setq entity (pop entity-stack))))
2733 (defun wl-summary-update-thread (entity
2736 (let* ((this-id (elmo-message-entity-field entity 'message-id))
2737 (overview-entity entity)
2738 (parent-id (elmo-message-entity-field parent-entity 'message-id))
2739 (number (elmo-message-entity-number entity))
2740 (parent-number (elmo-message-entity-number parent-entity))
2743 ((or (not parent-id)
2744 (string= this-id parent-id))
2745 (goto-char (point-max))
2747 (setq insert-line t))
2748 ;; parent already exists in buffer.
2749 ((wl-summary-jump-to-msg parent-number)
2750 (wl-thread-goto-bottom-of-sub-thread)
2751 (setq insert-line t)))
2753 (let (buffer-read-only)
2754 (wl-summary-insert-line
2755 (wl-summary-create-line
2759 (elmo-message-flags wl-summary-buffer-elmo-folder number)
2760 (elmo-message-cached-p wl-summary-buffer-elmo-folder number)
2761 (wl-thread-maybe-get-children-num number)
2762 (wl-thread-make-indent-string thr-entity)
2763 (wl-thread-entity-get-linked thr-entity)))))))
2765 (defun wl-summary-target-mark-msgs (msgs)
2766 "Return the number of marked messages."
2768 (dolist (number msgs)
2769 (when (wl-summary-target-mark number)
2773 (defun wl-summary-pick (&optional from-list delete-marks)
2776 (let* ((condition (car (elmo-parse-search-condition
2777 (elmo-read-search-condition
2778 wl-summary-pick-field-default))))
2779 (result (elmo-folder-search wl-summary-buffer-elmo-folder
2784 (let ((mlist wl-summary-buffer-target-mark-list))
2786 (when (wl-summary-jump-to-msg (car mlist))
2787 (wl-summary-unmark))
2788 (setq mlist (cdr mlist)))
2789 (setq wl-summary-buffer-target-mark-list nil)))
2791 (setq num (wl-summary-target-mark-msgs result))
2793 (if (= num (length result))
2794 (message "%d message(s) are picked." num)
2795 (message "%d(%d) message(s) are picked." num
2796 (- (length result) num)))
2797 (message "No message was picked.")))))
2799 (defun wl-summary-unvirtual ()
2800 "Exit from current virtual folder."
2803 (elmo-folder-type-internal wl-summary-buffer-elmo-folder))
2804 (wl-summary-goto-folder-subr
2805 (elmo-folder-name-internal
2806 (elmo-filter-folder-target-internal
2807 wl-summary-buffer-elmo-folder))
2809 (error "This folder is not filtered")))
2811 (defun wl-summary-virtual (&optional arg)
2812 "Goto virtual folder.
2813 If ARG, exit virtual folder."
2816 (wl-summary-unvirtual)
2817 (wl-summary-goto-folder-subr (concat "/"
2818 (elmo-read-search-condition
2819 wl-summary-pick-field-default)
2821 (wl-summary-buffer-folder-name))
2823 (run-hooks 'wl-summary-virtual-hook)))
2825 (defun wl-summary-delete-all-target-marks ()
2826 (let (wl-summary-buffer-temp-mark-list)
2827 (wl-summary-delete-all-temp-marks)))
2829 (defun wl-summary-delete-all-temp-marks (&optional no-msg force)
2830 "Erase all temp marks from buffer."
2832 (when (or wl-summary-buffer-target-mark-list
2833 wl-summary-buffer-temp-mark-list
2836 (goto-char (point-min))
2838 (message "Unmarking..."))
2840 (wl-summary-unset-mark nil nil force)
2843 (message "Unmarking...done"))
2844 (setq wl-summary-buffer-target-mark-list nil)
2845 (setq wl-summary-buffer-temp-mark-list nil))))
2847 (defsubst wl-summary-temp-mark (&optional number)
2848 "Return temp-mark string of current line."
2849 (let ((number (or number (wl-summary-message-number)))
2851 (or (and (wl-summary-have-target-mark-p number)
2853 (and (setq info (wl-summary-registered-temp-mark number))
2855 (wl-summary-get-score-mark number)
2858 (defsubst wl-summary-persistent-mark-string (folder flags cached)
2859 "Return the persistent mark string.
2860 The mark is decided according to the FOLDER, FLAGS and CACHED."
2861 (let ((priorities wl-summary-persistent-mark-priority-list)
2863 (while (and (null mark) priorities)
2864 (if (and (eq (car priorities) 'flag)
2865 (elmo-get-global-flags flags 'ignore-preserved))
2866 (let ((specs wl-summary-flag-alist)
2868 (while (setq spec (car specs))
2869 (if (memq (car spec) flags)
2870 (setq mark (or (nth 2 spec) wl-summary-flag-mark)
2872 (setq specs (cdr specs))))
2874 (setq mark wl-summary-flag-mark)))
2875 (when (memq (car priorities) flags)
2877 (or (case (car priorities)
2880 wl-summary-new-cached-mark
2881 wl-summary-new-uncached-mark))
2884 wl-summary-answered-cached-mark
2885 wl-summary-answered-uncached-mark))
2888 wl-summary-unread-cached-mark
2889 wl-summary-unread-uncached-mark)))))))
2890 (setq priorities (cdr priorities)))
2892 (if (or cached (elmo-folder-local-p folder))
2894 wl-summary-read-uncached-mark))))
2896 (defsubst wl-summary-message-mark (folder number &optional flags)
2897 "Return mark of the message."
2899 (wl-summary-persistent-mark-string
2901 (or flags (setq flags (elmo-message-flags folder number)))
2902 (memq 'cached flags) ; XXX for speed-up.
2905 (defsubst wl-summary-persistent-mark (&optional number flags)
2906 "Return persistent-mark string of current line."
2907 (or (wl-summary-message-mark wl-summary-buffer-elmo-folder
2908 (or number (wl-summary-message-number))
2912 (defun wl-summary-put-temp-mark (mark)
2913 "Put temp MARK on current line."
2914 (when wl-summary-buffer-temp-mark-column
2917 (let ((inhibit-read-only t)
2918 (buffer-read-only nil))
2919 (move-to-column wl-summary-buffer-temp-mark-column)
2920 (delete-backward-char 1)
2923 (defun wl-summary-next-buffer ()
2924 "Switch to next summary buffer."
2926 (let ((buffers (sort (wl-collect-summary)
2927 (lambda (buffer1 buffer2)
2928 (string-lessp (buffer-name buffer1)
2929 (buffer-name buffer2))))))
2931 (or (cadr (memq (current-buffer) buffers))
2934 (defun wl-summary-previous-buffer ()
2935 "Switch to previous summary buffer."
2937 (let ((buffers (sort (wl-collect-summary)
2938 (lambda (buffer1 buffer2)
2939 (not (string-lessp (buffer-name buffer1)
2940 (buffer-name buffer2)))))))
2942 (or (cadr (memq (current-buffer) buffers))
2945 (defun wl-summary-target-mark-mark-as-read ()
2948 (goto-char (point-min))
2949 (let ((inhibit-read-only t)
2950 (buffer-read-only nil)
2951 wl-summary-buffer-disp-msg)
2952 (wl-summary-mark-as-read wl-summary-buffer-target-mark-list)
2953 (dolist (number wl-summary-buffer-target-mark-list)
2954 (wl-summary-unset-mark number)))))
2956 (defun wl-summary-target-mark-mark-as-unread ()
2959 (goto-char (point-min))
2960 (let ((inhibit-read-only t)
2961 (buffer-read-only nil)
2962 wl-summary-buffer-disp-msg)
2963 (wl-summary-mark-as-unread wl-summary-buffer-target-mark-list)
2964 (dolist (number wl-summary-buffer-target-mark-list)
2965 (wl-summary-unset-mark number)))))
2967 (defun wl-summary-target-mark-operation (flag)
2969 (goto-char (point-min))
2970 (let ((inhibit-read-only t)
2971 (buffer-read-only nil)
2972 wl-summary-buffer-disp-msg)
2974 (intern (format "wl-summary-mark-as-%s-internal" flag))
2976 wl-summary-buffer-target-mark-list)
2977 (dolist (number wl-summary-buffer-target-mark-list)
2978 (wl-summary-unset-mark number)))))
2980 (defun wl-summary-target-mark-mark-as-important ()
2982 (wl-summary-target-mark-operation 'important))
2984 (defun wl-summary-target-mark-mark-as-answered ()
2986 (wl-summary-target-mark-operation 'answered))
2988 (defun wl-summary-target-mark-set-flags ()
2991 (let ((inhibit-read-only t)
2992 (buffer-read-only nil)
2993 wl-summary-buffer-disp-msg
2995 (dolist (number wl-summary-buffer-target-mark-list)
2996 (setq flags (wl-summary-set-flags-internal number flags)))
2997 (wl-summary-delete-all-target-marks)
2998 (wl-summary-count-unread)
2999 (wl-summary-update-modeline))))
3001 (defun wl-summary-target-mark-save ()
3004 (wl-read-directory-name "Save to directory: "
3005 wl-temporary-file-directory))
3007 (if (null (file-exists-p wl-save-dir))
3008 (make-directory wl-save-dir))
3009 (while (setq number (car wl-summary-buffer-target-mark-list))
3010 (wl-thread-jump-to-msg number)
3011 (wl-summary-save t wl-save-dir)
3012 (wl-summary-unmark))))
3014 (defun wl-summary-target-mark-pick ()
3016 (wl-summary-pick wl-summary-buffer-target-mark-list 'delete))
3018 (defun wl-summary-update-persistent-mark (&optional number flags)
3019 "Synch up persistent mark of current line with msgdb's.
3020 Return non-nil if the mark is updated"
3022 (when wl-summary-buffer-persistent-mark-column
3024 (move-to-column wl-summary-buffer-persistent-mark-column)
3025 (let ((inhibit-read-only t)
3026 (buffer-read-only nil)
3027 (mark (buffer-substring (- (point) 1) (point)))
3028 (new-mark (wl-summary-persistent-mark number flags)))
3029 (unless (string= new-mark mark)
3030 (delete-backward-char 1)
3032 (wl-summary-set-message-modified)
3034 (when wl-summary-highlight
3035 (wl-highlight-summary-current-line))
3036 (set-buffer-modified-p nil)))
3038 (defsubst wl-summary-mark-as-read-internal (inverse
3043 (let ((folder wl-summary-buffer-elmo-folder)
3044 unread-message number
3045 number-list visible)
3046 (setq number-list (cond ((numberp number-or-numbers)
3047 (setq unread-message
3048 (elmo-message-flagged-p
3052 (list number-or-numbers))
3053 ((and (not (null number-or-numbers))
3054 (listp number-or-numbers))
3056 ((setq number (wl-summary-message-number))
3058 (setq unread-message
3059 (elmo-message-flagged-p
3064 (if (null number-list)
3065 (message "No message.")
3067 (elmo-folder-unset-flag folder number-list 'read no-folder-mark)
3068 (elmo-folder-set-flag folder number-list 'read no-folder-mark))
3069 (dolist (number number-list)
3070 (setq visible (wl-summary-jump-to-msg number))
3072 (when unread-message
3073 (run-hooks 'wl-summary-unread-message-hook)))
3074 ;; set mark on buffer
3076 (wl-summary-update-persistent-mark)))
3077 (unless no-modeline-update
3078 ;; Update unread numbers.
3079 (wl-summary-count-unread)
3080 (wl-summary-update-modeline)
3081 (wl-folder-update-unread
3082 (wl-summary-buffer-folder-name)
3083 (+ wl-summary-buffer-unread-count
3084 wl-summary-buffer-new-count)))))))
3086 (defun wl-summary-mark-as-read (&optional number-or-numbers
3090 (wl-summary-mark-as-read-internal nil
3093 no-modeline-update))
3095 (defun wl-summary-mark-as-unread (&optional number-or-numbers
3099 (wl-summary-mark-as-read-internal 'inverse
3102 no-modeline-update))
3104 (defsubst wl-summary-mark-as-answered-internal (inverse
3109 (let ((folder wl-summary-buffer-elmo-folder)
3110 number number-list visible)
3111 (setq number-list (cond ((numberp number-or-numbers)
3112 (list number-or-numbers))
3113 ((and (not (null number-or-numbers))
3114 (listp number-or-numbers))
3116 ((setq number (wl-summary-message-number))
3119 (if (null number-list)
3120 (message "No message.")
3122 (elmo-folder-unset-flag folder number-list 'answered)
3123 (elmo-folder-set-flag folder number-list 'answered))
3124 (dolist (number number-list)
3125 (setq visible (wl-summary-jump-to-msg number))
3126 ;; set mark on buffer
3128 (wl-summary-update-persistent-mark)))
3129 (unless no-modeline-update
3130 ;; Update unread numbers.
3131 ;; should elmo-flag-mark-as-read return unread numbers?
3132 (wl-summary-count-unread)
3133 (wl-summary-update-modeline)
3134 (wl-folder-update-unread
3135 (wl-summary-buffer-folder-name)
3136 (+ wl-summary-buffer-unread-count
3137 wl-summary-buffer-new-count)))))))
3139 (defun wl-summary-mark-as-answered (&optional number-or-numbers
3142 (wl-summary-mark-as-answered-internal
3143 (and (interactive-p)
3144 (elmo-message-flagged-p wl-summary-buffer-elmo-folder
3145 (wl-summary-message-number)
3148 no-modeline-update))
3150 (defun wl-summary-mark-as-unanswered (&optional number-or-numbers
3152 (wl-summary-mark-as-answered-internal 'inverse
3154 no-modeline-update))
3156 (defun wl-summary-decide-flag (folder number)
3157 (let ((flags (elmo-get-global-flags (elmo-message-flags
3159 (completion-ignore-case t)
3165 (and (> (length flag) 0)
3166 (intern (downcase flag))))
3167 (wl-completing-read-multiple
3169 (mapcar (lambda (flag)
3170 (list (capitalize (symbol-name flag))))
3171 elmo-global-flag-list)
3172 nil nil (mapconcat (lambda (flag)
3173 (capitalize (symbol-name flag)))
3176 (dolist (flag new-flags)
3177 (unless (memq flag elmo-global-flag-list)
3178 (if (y-or-n-p (format "Flag `%s' does not exist yet. Create?"
3179 (capitalize (symbol-name flag))))
3180 (setq elmo-global-flag-list (append
3181 elmo-global-flag-list
3183 (error "Stopped"))))
3186 (defsubst wl-summary-set-flags-internal (&optional
3192 (let ((folder wl-summary-buffer-elmo-folder)
3193 number number-list visible)
3194 (setq number-list (cond ((numberp number-or-numbers)
3195 (list number-or-numbers))
3196 ((and (not (null number-or-numbers))
3197 (listp number-or-numbers))
3199 ((setq number (wl-summary-message-number))
3205 (setq flags (wl-summary-decide-flag folder (car number-list)))))
3206 (if (null number-list)
3207 (message "No message.")
3208 (dolist (number number-list)
3209 (elmo-message-set-global-flags folder number flags local)
3210 (setq visible (wl-summary-jump-to-msg number))
3211 ;; set mark on buffer
3213 (wl-summary-update-persistent-mark))))
3216 (defsubst wl-summary-add-flags-internal (&optional
3221 (let ((folder wl-summary-buffer-elmo-folder)
3222 set-flags msg number-list visible)
3223 (setq number-list (cond ((numberp number-or-numbers)
3224 (list number-or-numbers))
3225 ((and (not (null number-or-numbers))
3226 (listp number-or-numbers))
3228 ((setq msg (wl-summary-message-number))
3231 (if (null number-list)
3232 (message "No message.")
3233 (dolist (number number-list)
3235 (elmo-get-global-flags
3236 (elmo-message-flags folder number)))
3237 (setq set-flags (nconc flags set-flags))
3238 (elmo-message-set-global-flags folder number set-flags local)
3239 (setq visible (wl-summary-jump-to-msg number))
3240 ;; set mark on buffer
3242 (wl-summary-update-persistent-mark)))))))
3244 (defsubst wl-summary-remove-flags-internal (&optional
3249 (let ((folder wl-summary-buffer-elmo-folder)
3250 set-flags msg number-list visible)
3251 (setq number-list (cond ((numberp number-or-numbers)
3252 (list number-or-numbers))
3253 ((and (not (null number-or-numbers))
3254 (listp number-or-numbers))
3256 ((setq msg (wl-summary-message-number))
3259 (if (null number-list)
3260 (message "No message.")
3261 (dolist (number number-list)
3262 (setq set-flags (elmo-get-global-flags
3263 (elmo-message-flags folder number)))
3264 (dolist (flag flags)
3265 (setq set-flags (delq flag set-flags)))
3266 (elmo-message-set-global-flags folder number set-flags local)
3267 (setq visible (wl-summary-jump-to-msg number))
3268 ;; set mark on buffer
3270 (wl-summary-update-persistent-mark)))))))
3272 (defun wl-summary-set-flags (&optional remove)
3274 (if (eq 'flag (elmo-folder-type-internal wl-summary-buffer-elmo-folder))
3275 (error "Cannot process flags in this folder"))
3276 (wl-summary-set-flags-internal nil nil nil remove))
3278 (defun wl-summary-mark-as-important-internal (inverse
3279 &optional number-or-numbers)
3281 (wl-summary-remove-flags-internal number-or-numbers '(important))
3282 (wl-summary-add-flags-internal number-or-numbers '(important))))
3284 (defun wl-summary-mark-as-important (&optional prompt)
3286 (if (eq 'flag (elmo-folder-type-internal wl-summary-buffer-elmo-folder))
3287 (error "Cannot process flags in this folder"))
3289 (wl-summary-set-flags-internal)
3290 (wl-summary-mark-as-important-internal
3291 (and (interactive-p)
3292 (elmo-message-flagged-p wl-summary-buffer-elmo-folder
3293 (wl-summary-message-number)
3297 (defvar wl-summary-line-formatter nil)
3299 (defun wl-summary-view-old-p ()
3300 "Return non-nil when summary view cache has old format."
3302 (goto-char (point-min))
3303 (and wl-summary-buffer-number-list
3304 (not (re-search-forward "\r-?[0-9]+" (point-at-eol) t)))))
3306 (defun wl-summary-line-format-changed-p ()
3307 "Return non-nil when summary line format is changed."
3309 wl-summary-buffer-line-format
3310 (or (elmo-object-load (expand-file-name
3311 wl-summary-line-format-file
3312 (elmo-folder-msgdb-path
3313 wl-summary-buffer-elmo-folder))
3314 wl-summary-buffer-mime-charset)
3315 wl-summary-buffer-line-format))))
3317 (defun wl-summary-line-format-save ()
3318 "Save current summary line format."
3320 (expand-file-name wl-summary-line-format-file
3321 (elmo-folder-msgdb-path
3322 wl-summary-buffer-elmo-folder))
3323 wl-summary-buffer-line-format
3324 wl-summary-buffer-mime-charset))
3326 (defun wl-summary-line-number ()
3327 (wl-set-string-width
3328 (- wl-summary-buffer-number-column)
3330 (elmo-message-entity-number wl-message-entity))))
3332 (defun wl-summary-line-year ()
3333 (aref wl-datevec 0))
3334 (defun wl-summary-line-month ()
3335 (format "%02d" (aref wl-datevec 1)))
3336 (defun wl-summary-line-day ()
3337 (format "%02d" (aref wl-datevec 2)))
3338 (defun wl-summary-line-day-of-week ()
3340 (elmo-date-get-week (aref wl-datevec 0)
3342 (aref wl-datevec 2))
3344 (defun wl-summary-line-hour ()
3345 (format "%02d" (aref wl-datevec 3)))
3346 (defun wl-summary-line-minute ()
3347 (format "%02d" (aref wl-datevec 4)))
3349 (defun wl-summary-line-size ()
3350 (let ((size (elmo-message-entity-field wl-message-entity 'size)))
3353 ((<= 1 (/ size 1048576))
3354 (format "%.0fM" (/ size 1048576.0)))
3355 ((<= 1 (/ size 1024))
3356 (format "%.0fK" (/ size 1024.0)))
3357 (t (format "%dB" size)))
3360 (defun wl-summary-line-subject ()
3361 (let (no-parent subject parent-raw-subject parent-subject)
3362 (if (string= wl-thr-indent-string "")
3363 (setq no-parent t)) ; no parent
3365 (elmo-delete-char ?\n
3366 (or (elmo-message-entity-field
3369 wl-summary-no-subject-message)))
3370 (setq parent-raw-subject
3371 (elmo-message-entity-field wl-parent-message-entity
3373 (setq parent-subject
3374 (if parent-raw-subject
3375 (elmo-delete-char ?\n parent-raw-subject)))
3377 (null parent-subject)
3378 (not (wl-summary-subject-equal
3379 subject parent-subject)))
3380 (funcall wl-summary-subject-function subject)
3383 (defun wl-summary-line-from ()
3384 (elmo-delete-char ?\n
3385 (funcall wl-summary-from-function
3386 (elmo-message-entity-field
3390 (defun wl-summary-line-list-info ()
3391 (let ((list-info (wl-summary-get-list-info wl-message-entity)))
3393 (format (if (cdr list-info) "(%s %05.0f)" "(%s)")
3394 (car list-info) (cdr list-info))
3397 (defun wl-summary-line-list-count ()
3398 (let ((ml-count (cdr (wl-summary-get-list-info wl-message-entity))))
3400 (format "%.0f" ml-count)
3403 (defun wl-summary-line-attached ()
3404 (let ((content-type (elmo-message-entity-field
3405 wl-message-entity 'content-type))
3406 (case-fold-search t))
3407 (if (and content-type
3408 (string-match "multipart/mixed" content-type))
3413 ;;(defun wl-summary-line-cached ()
3414 ;; (if (elmo-message-cached-p wl-summary-buffer-elmo-folder
3415 ;; (elmo-message-entity-number wl-message-entity))
3419 (defun wl-summary-create-line (wl-message-entity
3420 wl-parent-message-entity
3425 wl-thr-children-number
3426 wl-thr-indent-string
3428 "Create a summary line."
3429 (let ((wl-mime-charset wl-summary-buffer-mime-charset)
3430 (wl-persistent-mark (wl-summary-persistent-mark-string
3431 wl-summary-buffer-elmo-folder
3434 (elmo-mime-charset wl-summary-buffer-mime-charset)
3435 (elmo-lang wl-summary-buffer-weekday-name-lang)
3436 (wl-datevec (or (ignore-errors (timezone-fix-time
3437 (elmo-message-entity-field
3441 wl-summary-fix-timezone))
3443 (entity wl-message-entity) ; backward compatibility.
3445 (if (and wl-thr-indent-string
3446 wl-summary-indent-length-limit
3447 (< wl-summary-indent-length-limit
3448 (string-width wl-thr-indent-string)))
3449 (setq wl-thr-indent-string (wl-set-string-width
3450 wl-summary-indent-length-limit
3451 wl-thr-indent-string)))
3452 (setq line (funcall wl-summary-buffer-line-formatter))
3453 (if wl-summary-width (setq line
3454 (wl-set-string-width
3455 (- wl-summary-width 1) line nil
3457 (setq line (concat line
3460 (elmo-message-entity-number
3461 wl-message-entity))))
3462 (if wl-summary-highlight
3463 (wl-highlight-summary-line-string
3464 (elmo-message-entity-number wl-message-entity)
3468 wl-thr-indent-string))
3471 (defsubst wl-summary-proc-wday (wday-str year month mday)
3473 (if (string-match "\\([A-Z][a-z][a-z]\\).*" wday-str)
3474 (wl-match-string 1 wday-str)
3475 (elmo-date-get-week year month mday))))
3477 (defvar wl-summary-move-spec-alist
3482 (unread . ((t . nil)
3486 (defsubst wl-summary-next-message (num direction hereto)
3487 (if wl-summary-buffer-next-message-function
3488 (funcall wl-summary-buffer-next-message-function num direction hereto)
3489 (let ((cur-spec (cdr (assq wl-summary-move-order
3490 wl-summary-move-spec-alist)))
3491 (nums (memq num (if (eq direction 'up)
3492 (reverse wl-summary-buffer-number-list)
3493 wl-summary-buffer-number-list)))
3495 (unless hereto (setq nums (cdr nums)))
3501 (cond ((eq (car (car cur-spec)) 'p)
3502 (if (setq flagged-list
3503 (elmo-folder-list-flagged
3504 wl-summary-buffer-elmo-folder
3505 (cdr (car cur-spec)) t))
3507 (if (and (memq (car nums) flagged-list)
3508 (elmo-message-accessible-p
3509 wl-summary-buffer-elmo-folder
3511 (throw 'done (car nums)))
3512 (setq nums (cdr nums)))))
3513 ((eq (car (car cur-spec)) 't)
3514 (if wl-summary-buffer-target-mark-list
3516 (if (memq (car nums)
3517 wl-summary-buffer-target-mark-list)
3518 (throw 'done (car nums)))
3519 (setq nums (cdr nums))))))
3520 (setq cur-spec (cdr cur-spec))))
3523 (defsubst wl-summary-cursor-move (direction hereto)
3524 (when (and (eq direction 'up)
3529 (when (setq num (wl-summary-next-message (wl-summary-message-number)
3532 (wl-thread-jump-to-msg num))
3535 ;; Goto unread or global flag message
3536 ;; returns t if next message exists in this folder.
3537 (defun wl-summary-cursor-down (&optional hereto)
3539 (wl-summary-cursor-move 'down hereto))
3541 (defun wl-summary-cursor-up (&optional hereto)
3543 (wl-summary-cursor-move 'up hereto))
3545 (defun wl-summary-save-view-cache ()
3547 (let* ((dir (elmo-folder-msgdb-path wl-summary-buffer-elmo-folder))
3548 (cache (expand-file-name wl-summary-cache-file dir))
3549 (view (expand-file-name wl-summary-view-file dir))
3550 (save-view wl-summary-buffer-view)
3551 (mark-list (copy-sequence wl-summary-buffer-target-mark-list))
3552 (temp-list (copy-sequence wl-summary-buffer-temp-mark-list))
3553 (tmp-buffer (get-buffer-create " *wl-summary-save-view-cache*"))
3554 (temp-column wl-summary-buffer-temp-mark-column)
3555 (charset wl-summary-buffer-mime-charset))
3557 (if (file-directory-p dir)
3559 (if (file-exists-p dir)
3560 (error "File %s already exists" dir)
3561 (elmo-make-directory dir)))
3562 (if (eq save-view 'thread)
3563 (wl-thread-save-entity dir))
3564 (when wl-summary-check-line-format
3565 (wl-summary-line-format-save))
3568 (when (file-writable-p cache)
3569 (copy-to-buffer tmp-buffer (point-min) (point-max))
3570 (with-current-buffer tmp-buffer
3572 (make-local-variable 'wl-summary-highlight)
3573 (setq wl-summary-highlight nil
3574 wl-summary-buffer-target-mark-list mark-list
3575 wl-summary-buffer-temp-mark-list temp-list
3576 wl-summary-buffer-temp-mark-column temp-column)
3577 (wl-summary-delete-all-temp-marks 'no-msg 'force)
3578 (encode-coding-region
3579 (point-min) (point-max)
3581 ;; one in mcs-ltn1(apel<10.4) cannot take 2 arg.
3582 (mime-charset-to-coding-system charset 'LF))
3583 ;; Mule 2 doesn't have `*ctext*unix'.
3584 (mime-charset-to-coding-system charset)))
3585 (write-region-as-binary (point-min)(point-max)
3586 cache nil 'no-msg)))
3587 (when (file-writable-p view) ; 'thread or 'sequence
3589 (set-buffer tmp-buffer)
3591 (prin1 save-view tmp-buffer)
3592 (princ "\n" tmp-buffer)
3593 (write-region (point-min) (point-max) view nil 'no-msg))))
3595 (kill-buffer tmp-buffer))))))
3597 (defsubst wl-summary-get-sync-range (folder)
3599 (elmo-folder-plugged-p folder)
3600 (wl-get-assoc-list-value
3601 wl-folder-sync-range-alist
3602 (elmo-folder-name-internal folder)
3604 wl-default-sync-range)))
3606 ;; redefined for wl-summary-sync-update
3607 (defun wl-summary-input-range (folder)
3608 "returns update or all or rescan."
3609 ;; for the case when parts are expanded in the bottom of the folder
3610 (let ((input-range-list '("no-sync"
3622 (default (or (wl-get-assoc-list-value
3623 wl-folder-sync-range-alist
3626 wl-default-sync-range))
3629 (completing-read (format "Range (%s): " default)
3631 (function (lambda (x) (cons x x)))
3633 (if (string= range "")
3637 (defun wl-summary-toggle-disp-folder (&optional arg)
3639 (let ((cur-buf (current-buffer))
3640 (summary-win (get-buffer-window (current-buffer)))
3644 (setq wl-summary-buffer-disp-folder t)
3645 ;; hide your folder window
3646 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
3647 (if (setq fld-win (get-buffer-window fld-buf))
3648 (delete-window fld-win))))
3650 (setq wl-summary-buffer-disp-folder nil)
3651 ;; hide your wl-message window!
3652 (when (buffer-live-p wl-message-buffer)
3653 (wl-message-select-buffer wl-message-buffer)
3655 (select-window (get-buffer-window cur-buf))
3656 ;; display wl-folder window!!
3657 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
3658 (if (setq fld-win (get-buffer-window fld-buf))
3659 ;; folder win is already displayed.
3660 (select-window fld-win)
3661 ;; folder win is not displayed.
3662 (switch-to-buffer fld-buf))
3665 ;; temporarily delete summary-win.
3667 (delete-window summary-win))
3668 (split-window-horizontally wl-folder-window-width)
3670 (switch-to-buffer cur-buf))
3672 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
3673 (if (setq fld-win (get-buffer-window fld-buf))
3674 (setq wl-summary-buffer-disp-folder nil)
3675 (setq wl-summary-buffer-disp-folder t)))
3676 (if (not wl-summary-buffer-disp-folder)
3677 ;; hide message window
3678 (let ((mes-win (and wl-message-buffer
3679 (get-buffer-window wl-message-buffer)))
3680 (wl-stay-folder-window t))
3681 (if mes-win (delete-window mes-win))
3682 ;; hide your folder window
3683 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
3684 (if (setq fld-win (get-buffer-window fld-buf))
3686 (delete-window (get-buffer-window cur-buf))
3687 (select-window fld-win)
3688 (switch-to-buffer cur-buf))))
3689 (run-hooks 'wl-summary-toggle-disp-folder-off-hook)
3690 ;; resume message window.
3692 (wl-message-select-buffer wl-message-buffer)
3693 (run-hooks 'wl-summary-toggle-disp-folder-message-resumed-hook)
3694 (select-window (get-buffer-window cur-buf))))
3695 ;; hide message window
3696 (let ((wl-stay-folder-window t)
3697 (mes-win (and wl-message-buffer
3698 (get-buffer-window wl-message-buffer))))
3699 (if mes-win (delete-window mes-win))
3700 (select-window (get-buffer-window cur-buf))
3701 ;; display wl-folder window!!
3702 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
3703 (if (setq fld-win (get-buffer-window fld-buf))
3704 ;; folder win is already displayed.
3705 (select-window fld-win)
3706 ;; folder win is not displayed...occupy all.
3707 (switch-to-buffer fld-buf))
3710 (split-window-horizontally wl-folder-window-width)
3712 (switch-to-buffer cur-buf)
3713 ;; resume message window.
3714 (run-hooks 'wl-summary-toggle-disp-folder-on-hook)
3716 (wl-message-select-buffer wl-message-buffer)
3717 (run-hooks 'wl-summary-toggle-disp-folder-message-resumed-hook)
3718 (select-window (get-buffer-window cur-buf))))))))
3719 (run-hooks 'wl-summary-toggle-disp-folder-hook))
3721 (defun wl-summary-toggle-disp-msg (&optional arg)
3723 (let ((cur-buf (current-buffer))
3728 (setq wl-summary-buffer-disp-msg t)
3730 ;; hide your folder window
3731 (if (and (not wl-stay-folder-window)
3732 (setq fld-buf (get-buffer wl-folder-buffer-name)))
3733 (if (setq fld-win (get-buffer-window fld-buf))
3734 (unless (one-window-p fld-win)
3735 (delete-window fld-win))))))
3737 (wl-delete-all-overlays)
3738 (setq wl-summary-buffer-disp-msg nil)
3740 (when (buffer-live-p wl-message-buffer)
3741 (wl-message-select-buffer wl-message-buffer)
3743 (and (get-buffer-window cur-buf)
3744 (select-window (get-buffer-window cur-buf))))
3745 (run-hooks 'wl-summary-toggle-disp-off-hook)))
3747 (if (and wl-message-buffer
3748 (get-buffer-window wl-message-buffer)) ; already displayed
3749 (setq wl-summary-buffer-disp-msg nil)
3750 (setq wl-summary-buffer-disp-msg t))
3751 (if wl-summary-buffer-disp-msg
3753 (wl-summary-redisplay)
3754 ;;; hide your folder window
3755 ;;; (setq fld-buf (get-buffer wl-folder-buffer-name))
3756 ;;; (if (setq fld-win (get-buffer-window fld-buf))
3757 ;;; (delete-window fld-win)))
3758 (run-hooks 'wl-summary-toggle-disp-on-hook))
3759 (wl-delete-all-overlays)
3761 (wl-message-select-buffer wl-message-buffer)
3763 (select-window (get-buffer-window cur-buf))
3764 (setq wl-message-buffer nil)
3765 (run-hooks 'wl-summary-toggle-disp-off-hook))
3766 ;;; (switch-to-buffer cur-buf)
3768 (run-hooks 'wl-summary-buffer-window-scroll-functions)))
3770 (defun wl-summary-next-line-content ()
3771 "Show next line of the message."
3773 (let ((cur-buf (current-buffer)))
3774 (wl-summary-toggle-disp-msg 'on)
3775 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
3776 (set-buffer cur-buf)
3777 (wl-message-next-page 1))))
3779 (defun wl-summary-prev-line-content ()
3781 (let ((cur-buf (current-buffer)))
3782 (wl-summary-toggle-disp-msg 'on)
3783 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
3784 (set-buffer cur-buf)
3785 (wl-message-prev-page 1))))
3787 (defun wl-summary-next-page ()
3789 (let ((cur-buf (current-buffer)))
3790 (wl-summary-toggle-disp-msg 'on)
3791 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
3792 (set-buffer cur-buf)
3793 (wl-message-next-page))))
3795 (defun wl-summary-prev-page ()
3797 (let ((cur-buf (current-buffer)))
3798 (wl-summary-toggle-disp-msg 'on)
3799 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
3800 (set-buffer cur-buf)
3801 (wl-message-prev-page))))
3803 (defsubst wl-summary-no-mime-p (folder)
3804 (wl-string-match-member (elmo-folder-name-internal folder)
3805 wl-summary-no-mime-folder-list))
3807 (defun wl-summary-set-message-buffer-or-redisplay (&rest args)
3808 "Set message buffer.
3809 If message is not displayed yet, display it.
3810 Return t if message exists."
3811 (let ((folder wl-summary-buffer-elmo-folder)
3812 (number (wl-summary-message-number))
3813 cur-folder cur-number message-last-pos)
3814 (when (buffer-live-p wl-message-buffer)
3815 (save-window-excursion
3816 (wl-message-select-buffer wl-message-buffer)
3817 (setq cur-folder wl-message-buffer-cur-folder)
3818 (setq cur-number wl-message-buffer-cur-number)))
3819 (if (and (string= (elmo-folder-name-internal folder) (or cur-folder ""))
3820 (eq number (or cur-number 0)))
3822 (set-buffer wl-message-buffer)
3824 (if (wl-summary-no-mime-p folder)
3825 (wl-summary-redisplay-no-mime-internal folder number)
3826 (wl-summary-redisplay-internal folder number))
3827 (when (buffer-live-p wl-message-buffer)
3828 (set-buffer wl-message-buffer))
3831 (defun wl-summary-target-mark-forward (&optional arg)
3833 (let ((mlist (nreverse (copy-sequence wl-summary-buffer-target-mark-list)))
3834 (summary-buf (current-buffer))
3835 (wl-draft-forward t)
3838 (wl-summary-jump-to-msg (car mlist))
3839 (wl-summary-forward t)
3840 (setq start-point (point))
3841 (setq draft-buf (current-buffer))
3842 (setq mlist (cdr mlist))
3843 (save-window-excursion
3846 (set-buffer summary-buf)
3847 (wl-summary-jump-to-msg (car mlist))
3848 (wl-summary-redisplay)
3849 (set-buffer draft-buf)
3850 (goto-char (point-max))
3851 (wl-draft-insert-message)
3852 (setq mlist (cdr mlist)))
3853 (wl-draft-body-goto-top)
3854 (wl-draft-enclose-digest-region (point) (point-max)))
3855 (goto-char start-point)
3857 (set-buffer summary-buf)
3858 (wl-summary-delete-all-target-marks)))
3859 (run-hooks 'wl-mail-setup-hook)))
3861 (defun wl-summary-target-mark-reply-with-citation (&optional arg)
3863 (let ((mlist (nreverse (copy-sequence wl-summary-buffer-target-mark-list)))
3864 (summary-buf (current-buffer))
3865 change-major-mode-hook
3868 (wl-summary-jump-to-msg (car mlist))
3869 (when (wl-summary-reply arg t)
3870 (goto-char (point-max))
3871 (setq start-point (point-marker))
3872 (setq draft-buf (current-buffer))
3873 (save-window-excursion
3875 (set-buffer summary-buf)
3876 (delete-other-windows)
3877 (wl-summary-jump-to-msg (car mlist))
3878 (wl-summary-redisplay)
3879 (set-buffer draft-buf)
3880 (goto-char (point-max))
3881 (wl-draft-yank-original)
3882 (setq mlist (cdr mlist)))
3883 (goto-char start-point)
3885 (set-buffer summary-buf)
3886 (wl-summary-delete-all-target-marks)))
3887 (wl-draft-reply-position wl-draft-reply-default-position)
3888 (run-hooks 'wl-mail-setup-hook))))
3890 (defun wl-summary-reply-with-citation (&optional arg)
3892 (when (wl-summary-reply arg t)
3893 (goto-char (point-max))
3894 (wl-draft-yank-original)
3895 (wl-draft-reply-position wl-draft-reply-default-position)
3896 (run-hooks 'wl-mail-setup-hook)))
3898 (defun wl-summary-jump-to-msg-by-message-id (&optional id)
3900 (let* ((original (wl-summary-message-number))
3901 (msgid (elmo-string (or id (read-from-minibuffer "Message-ID: "))))
3902 (entity (elmo-message-entity wl-summary-buffer-elmo-folder msgid))
3904 (errmsg (format "No message with id \"%s\" in the folder." msgid)))
3905 (if (setq msg (elmo-message-entity-number entity))
3907 (wl-thread-jump-to-msg msg)
3910 (if (and elmo-use-database
3913 "No message with id \"%s\" in the database." msgid))
3914 (setq otherfld (elmo-database-msgid-get msgid)))
3915 (if (cdr (wl-summary-jump-to-msg-internal
3916 (car otherfld) (nth 1 otherfld) 'no-sync))
3918 ;; Back to original.
3919 (wl-summary-jump-to-msg-internal
3920 (wl-summary-buffer-folder-name) original 'no-sync))
3921 (cond ((eq wl-summary-search-via-nntp 'confirm)
3922 (require 'elmo-nntp)
3923 (message "Search message in nntp server \"%s\" <y/n/s(elect)>? "
3924 elmo-nntp-default-server)
3925 (setq schar (let ((cursor-in-echo-area t)) (read-char)))
3926 (cond ((eq schar ?y)
3927 (wl-summary-jump-to-msg-by-message-id-via-nntp msgid))
3929 (wl-summary-jump-to-msg-by-message-id-via-nntp
3931 (read-from-minibuffer "NNTP Server: ")))
3933 (message "%s" errmsg)
3935 ((or (eq wl-summary-search-via-nntp 'force)
3937 (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
3939 wl-summary-search-via-nntp))
3940 (wl-summary-jump-to-msg-by-message-id-via-nntp msgid))
3942 (message "%s" errmsg)
3945 (defun wl-summary-jump-to-msg-by-message-id-via-nntp (&optional id server-spec)
3947 (let* ((msgid (elmo-string (or id (read-from-minibuffer "Message-ID: "))))
3948 newsgroups folder ret
3949 user server port type spec)
3951 (if (string-match "^-" server-spec)
3952 (setq spec (wl-folder-get-elmo-folder server-spec)
3953 user (elmo-net-folder-user-internal spec)
3954 server (elmo-net-folder-server-internal spec)
3955 port (elmo-net-folder-port-internal spec)
3956 type (elmo-net-folder-stream-type-internal spec))
3957 (setq server server-spec)))
3958 (when (setq ret (elmo-nntp-get-newsgroup-by-msgid
3960 (or server elmo-nntp-default-server)
3961 (or user elmo-nntp-default-user)
3962 (or port elmo-nntp-default-port)
3963 (or type elmo-nntp-default-stream-type)))
3964 (setq newsgroups (elmo-nntp-parse-newsgroups ret))
3965 (setq folder (concat "-" (car newsgroups)
3966 (elmo-nntp-folder-postfix user server port type)))
3969 (if (wl-folder-entity-exists-p (car newsgroups)
3970 wl-folder-newsgroups-hashtb)
3972 (setq folder (concat "-" (car newsgroups)
3973 (elmo-nntp-folder-postfix
3974 user server port type)))))
3975 (setq newsgroups (cdr newsgroups)))))
3977 (wl-summary-jump-to-msg-internal folder nil 'update msgid)
3978 (message "No message id \"%s\" in nntp server \"%s\"."
3979 msgid (or server elmo-nntp-default-server))
3982 (defun wl-summary-jump-to-msg-internal (folder msg scan-type &optional msgid)
3983 (let (wl-auto-select-first entity)
3984 (if (or (string= folder (wl-summary-buffer-folder-name))
3987 "Message was found in the folder \"%s\". Jump to it? "
3991 (wl-summary-goto-folder-subr
3992 folder scan-type nil nil t)
3995 (elmo-message-entity-number
3996 (elmo-message-entity
3997 wl-summary-buffer-elmo-folder
3999 (setq entity (wl-folder-search-entity-by-name folder
4003 (wl-folder-set-current-entity-id
4004 (wl-folder-get-entity-id entity))))
4006 (message "Message was not found currently in this folder.")
4007 (setq msg (and (wl-thread-jump-to-msg msg) msg)))
4008 (cons folder msg)))))
4010 (defun wl-summary-jump-to-parent-message (arg)
4012 (let ((cur-buf (current-buffer))
4013 (disp-msg wl-summary-buffer-disp-msg)
4014 (number (wl-summary-message-number))
4015 (regexp "\\(<[^<>]*>\\)[ \t]*$")
4017 msg-id msg-num ref-list ref irt)
4019 (message "No message.")
4020 (when (eq wl-summary-buffer-view 'thread)
4021 (cond ((and arg (not (numberp arg)))
4023 (wl-thread-entity-get-number
4024 (wl-thread-entity-get-top-entity
4025 (wl-thread-get-entity number)))))
4026 ((and arg (numberp arg))
4028 (setq msg-num number)
4031 (wl-thread-entity-get-number
4032 (wl-thread-entity-get-parent-entity
4033 (wl-thread-get-entity msg-num))))
4036 (wl-thread-entity-get-number
4037 (wl-thread-entity-get-parent-entity
4038 (wl-thread-get-entity number)))))))
4039 (when (null msg-num)
4040 (wl-summary-set-message-buffer-or-redisplay)
4041 (set-buffer (wl-message-get-original-buffer))
4042 (message "Searching parent message...")
4043 (setq ref (std11-field-body "References")
4044 irt (std11-field-body "In-Reply-To"))
4046 ((and arg (not (numberp arg)) ref (not (string= ref ""))
4047 (string-match regexp ref))
4048 ;; The first message of the thread.
4049 (setq msg-id (wl-match-string 1 ref)))
4050 ;; "In-Reply-To:" has only one msg-id.
4051 ((and (null arg) irt (not (string= irt ""))
4052 (string-match regexp irt))
4053 (setq msg-id (wl-match-string 1 irt)))
4054 ((and (or (null arg) (numberp arg)) ref (not (string= ref ""))
4055 (string-match regexp ref))
4056 ;; "^" searching parent, "C-u 2 ^" looking for grandparent.
4057 (while (string-match regexp ref)
4060 (wl-match-string 1 ref))
4062 (setq ref (substring ref (match-end 0)))
4065 (if (null arg) (nth 0 ref-list) ;; previous
4066 (if (<= arg i) (nth (1- arg) ref-list)
4067 (nth i ref-list))))))
4068 (set-buffer cur-buf)
4069 (or disp-msg (wl-summary-toggle-disp-msg 'off)))
4070 (cond ((and (null msg-id) (null msg-num))
4071 (message "No parent message!")
4073 ((and msg-id (wl-summary-jump-to-msg-by-message-id msg-id))
4074 (if wl-summary-buffer-disp-msg (wl-summary-redisplay))
4075 (message "Searching parent message...done")
4077 ((and msg-num (wl-summary-jump-to-msg msg-num))
4078 (if wl-summary-buffer-disp-msg (wl-summary-redisplay))
4079 (message "Searching parent message...done")
4082 (message "Parent message was not found.")
4085 (defun wl-summary-reply (&optional arg without-setup-hook)
4086 "Reply to current message. Default is \"wide\" reply.
4087 Reply to author if invoked with ARG."
4089 (let ((folder wl-summary-buffer-elmo-folder)
4090 (number (wl-summary-message-number))
4091 (summary-buf (current-buffer))
4092 (winconf (current-window-configuration))
4096 (wl-summary-set-message-buffer-or-redisplay))
4097 (setq mes-buf wl-message-buffer)
4098 (wl-message-select-buffer wl-message-buffer)
4099 (set-buffer mes-buf)
4101 (when (setq mes-buf (wl-message-get-original-buffer))
4102 (wl-draft-reply mes-buf arg summary-buf number)
4103 (wl-draft-reply-position wl-draft-reply-default-position)
4104 (unless without-setup-hook
4105 (run-hooks 'wl-mail-setup-hook)))
4106 (error (set-window-configuration winconf)
4107 (signal (car err)(cdr err))))
4108 (with-current-buffer summary-buf
4109 (elmo-folder-set-flag folder (list number) 'answered)
4110 (wl-summary-update-persistent-mark))
4113 (defun wl-summary-write ()
4114 "Write a new draft from Summary."
4116 (wl-draft (list (cons 'To ""))
4117 nil nil nil nil (wl-summary-buffer-folder-name))
4118 (run-hooks 'wl-mail-setup-hook)
4119 (mail-position-on-field "To"))
4121 (defvar wl-summary-write-current-folder-functions
4122 '(wl-folder-get-newsgroups
4123 wl-folder-guess-mailing-list-by-refile-rule
4124 wl-folder-guess-mailing-list-by-folder-name)
4125 "Newsgroups or Mailing List address guess functions list.
4126 Call from `wl-summary-write-current-folder'.
4127 When guess function return nil, challenge next guess-function.")
4129 (defun wl-summary-write-current-folder (&optional folder)
4130 "Write message to current FOLDER's newsgroup or mailing-list.
4131 Use function list is `wl-summary-write-current-folder-functions'."
4133 ;; default FOLDER is current buffer folder
4134 (setq folder (or folder (wl-summary-buffer-folder-name)))
4135 (let ((func-list wl-summary-write-current-folder-functions)
4136 guess-list guess-func)
4138 (setq guess-list (funcall (car func-list) folder))
4139 (if (null guess-list)
4140 (setq func-list (cdr func-list))
4141 (setq guess-func (car func-list))
4142 (setq func-list nil)))
4143 (if (null guess-func)
4145 (unless (or (stringp (nth 0 guess-list))
4146 (stringp (nth 1 guess-list))
4147 (stringp (nth 2 guess-list)))
4148 (error "Invalid value return guess function `%s'"
4149 (symbol-name guess-func)))
4150 (wl-draft (list (cons 'To (nth 0 guess-list))
4151 (cons 'Cc (nth 1 guess-list))
4152 (cons 'Newsgroups (nth 2 guess-list)))
4153 nil nil nil nil folder)
4154 (run-hooks 'wl-mail-setup-hook)
4155 (mail-position-on-field "Subject"))))
4157 (defun wl-summary-forward (&optional without-setup-hook)
4160 (let ((folder wl-summary-buffer-elmo-folder)
4161 (number (wl-summary-message-number))
4162 (summary-buf (current-buffer))
4163 (wl-draft-forward t)
4167 (message "No message.")
4168 (if (and (elmo-message-use-cache-p folder number)
4169 (eq (elmo-file-cache-status
4170 (elmo-file-cache-get
4171 (elmo-message-field folder number 'message-id)))
4174 (wl-summary-redisplay-internal nil nil 'force-reload)
4175 (wl-summary-redisplay-internal folder number))
4176 (setq mes-buf wl-message-buffer)
4177 (wl-message-select-buffer mes-buf)
4178 ;; get original subject.
4181 (set-buffer summary-buf)
4183 (or (elmo-message-entity-field
4184 (elmo-message-entity folder number) 'subject 'decode)
4186 (set-buffer mes-buf)
4187 (wl-draft-forward subject summary-buf)
4188 (unless without-setup-hook
4189 (run-hooks 'wl-mail-setup-hook)))))
4191 (defun wl-summary-click (e)
4196 (defun wl-summary-read ()
4197 "Proceed reading message in the summary buffer."
4199 (let ((cur-buf (current-buffer)))
4200 (wl-summary-toggle-disp-msg 'on)
4201 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
4202 (set-buffer cur-buf)
4203 (if (wl-message-next-page)
4204 (wl-summary-down t)))))
4206 (defsubst wl-summary-cursor-move-surface (downward interactive)
4207 (if wl-summary-move-direction-toggle
4208 (setq wl-summary-move-direction-downward downward))
4209 (let ((start (point))
4210 (skip-tmark-regexp (wl-regexp-opt wl-summary-skip-mark-list))
4212 (column (current-column))
4213 goto-next next-entity finfo)
4216 (not (if downward (eobp) (bobp))))
4220 (setq skip (or (string-match skip-tmark-regexp
4221 (wl-summary-temp-mark))
4222 (not (and (wl-summary-message-number)
4223 (elmo-message-accessible-p
4224 wl-summary-buffer-elmo-folder
4225 (wl-summary-message-number)))))))
4226 (if (if downward (eobp) (and (bobp) skip)) (setq goto-next t))
4227 (if (or (eobp) (and (bobp) skip))
4229 (move-to-column column)
4232 (if wl-summary-buffer-disp-msg
4233 (wl-summary-redisplay))
4236 ((and (not downward) wl-summary-buffer-prev-folder-function)
4237 (funcall wl-summary-buffer-prev-folder-function))
4238 ((and downward wl-summary-buffer-next-folder-function)
4239 (funcall wl-summary-buffer-next-folder-function))
4241 (when wl-auto-select-next
4244 (wl-summary-get-next-folder)
4245 (wl-summary-get-prev-folder)))
4247 (setq finfo (wl-folder-get-entity-info next-entity))))
4249 '(lambda () (wl-summary-next-folder-or-exit next-entity))
4251 "No more messages. Type SPC to go to %s."
4252 (wl-summary-entity-info-msg next-entity finfo)))))))))
4254 (defun wl-summary-prev (&optional interactive)
4256 (wl-summary-cursor-move-surface nil (or interactive (interactive-p))))
4258 (defun wl-summary-next (&optional interactive)
4260 (wl-summary-cursor-move-surface t (or interactive (interactive-p))))
4262 (defun wl-summary-up (&optional interactive skip-no-unread)
4265 (if wl-summary-move-direction-toggle
4266 (setq wl-summary-move-direction-downward nil))
4267 (if (wl-summary-cursor-up)
4268 (if wl-summary-buffer-disp-msg
4269 (wl-summary-redisplay))
4272 (if wl-summary-buffer-prev-folder-function
4273 (funcall wl-summary-buffer-prev-folder-function)
4274 (let (next-entity finfo)
4275 (when wl-auto-select-next
4277 (setq next-entity (wl-summary-get-prev-unread-folder))
4279 (setq finfo (wl-folder-get-entity-info next-entity)))))
4280 (if (and skip-no-unread
4281 (eq wl-auto-select-next 'skip-no-unread))
4282 (wl-summary-next-folder-or-exit next-entity t)
4284 '(lambda () (wl-summary-next-folder-or-exit next-entity t))
4286 "No more unread messages. Type SPC to go to %s."
4287 (wl-summary-entity-info-msg next-entity finfo)))))))))
4289 (defun wl-summary-get-prev-folder ()
4290 (let ((folder-buf (get-buffer wl-folder-buffer-name))
4293 (setq cur-id (save-excursion (set-buffer folder-buf)
4294 wl-folder-buffer-cur-entity-id))
4295 (wl-folder-get-prev-folder cur-id))))
4297 (defun wl-summary-get-next-folder ()
4298 (let ((folder-buf (get-buffer wl-folder-buffer-name))
4301 (setq cur-id (save-excursion (set-buffer folder-buf)
4302 wl-folder-buffer-cur-entity-id))
4303 (wl-folder-get-next-folder cur-id))))
4305 (defun wl-summary-get-next-unread-folder ()
4306 (let ((folder-buf (get-buffer wl-folder-buffer-name))
4309 (setq cur-id (save-excursion (set-buffer folder-buf)
4310 wl-folder-buffer-cur-entity-id))
4311 (wl-folder-get-next-folder cur-id 'unread))))
4313 (defun wl-summary-get-prev-unread-folder ()
4314 (let ((folder-buf (get-buffer wl-folder-buffer-name))
4317 (setq cur-id (save-excursion (set-buffer folder-buf)
4318 wl-folder-buffer-cur-entity-id))
4319 (wl-folder-get-prev-folder cur-id 'unread))))
4321 (defun wl-summary-down (&optional interactive skip-no-unread)
4323 (if wl-summary-move-direction-toggle
4324 (setq wl-summary-move-direction-downward t))
4325 (if (wl-summary-cursor-down)
4326 (if wl-summary-buffer-disp-msg
4327 (wl-summary-redisplay))
4330 (if wl-summary-buffer-next-folder-function
4331 (funcall wl-summary-buffer-next-folder-function)
4332 (let (next-entity finfo)
4333 (when wl-auto-select-next
4334 (setq next-entity (wl-summary-get-next-unread-folder)))
4336 (setq finfo (wl-folder-get-entity-info next-entity)))
4337 (if (and skip-no-unread
4338 (eq wl-auto-select-next 'skip-no-unread))
4339 (wl-summary-next-folder-or-exit next-entity)
4341 '(lambda () (wl-summary-next-folder-or-exit next-entity))
4343 "No more unread messages. Type SPC to go to %s."
4344 (wl-summary-entity-info-msg next-entity finfo)))))))))
4346 (defun wl-summary-goto-last-displayed-msg ()
4348 (unless wl-summary-buffer-last-displayed-msg
4349 (setq wl-summary-buffer-last-displayed-msg
4350 wl-summary-buffer-current-msg))
4351 (if wl-summary-buffer-last-displayed-msg
4353 (wl-summary-jump-to-msg wl-summary-buffer-last-displayed-msg)
4354 (if wl-summary-buffer-disp-msg
4355 (wl-summary-redisplay)))
4356 (message "No last message.")))
4358 (defun wl-summary-redisplay (&optional arg)
4361 (wl-summary-no-mime-p wl-summary-buffer-elmo-folder))
4362 (wl-summary-redisplay-no-mime)
4363 (wl-summary-redisplay-internal nil nil arg)))
4365 (defsubst wl-summary-redisplay-internal (&optional folder number force-reload)
4367 (let* ((folder (or folder wl-summary-buffer-elmo-folder))
4368 (num (or number (wl-summary-message-number)))
4369 (wl-mime-charset wl-summary-buffer-mime-charset)
4370 (default-mime-charset wl-summary-buffer-mime-charset)
4371 no-folder-mark fld-buf fld-win thr-entity)
4372 (if (and wl-thread-open-reading-thread
4373 (eq wl-summary-buffer-view 'thread)
4374 (not (wl-thread-entity-get-opened
4375 (setq thr-entity (wl-thread-get-entity
4377 (wl-thread-entity-get-children thr-entity))
4378 (wl-thread-force-open))
4381 (setq wl-summary-buffer-disp-msg t)
4382 (setq wl-summary-buffer-last-displayed-msg
4383 wl-summary-buffer-current-msg)
4384 ;; hide folder window
4385 (if (and (not wl-stay-folder-window)
4386 (setq fld-buf (get-buffer wl-folder-buffer-name)))
4387 (if (setq fld-win (get-buffer-window fld-buf))
4388 (delete-window fld-win)))
4389 (setq wl-current-summary-buffer (current-buffer))
4390 (setq no-folder-mark
4391 ;; If cache is used, change folder-mark.
4392 (if (wl-message-redisplay folder num
4396 (string= (elmo-folder-name-internal
4400 ;; plugged, then leave folder-mark.
4401 (if (and (not (elmo-folder-local-p
4402 wl-summary-buffer-elmo-folder))
4403 (elmo-folder-plugged-p
4404 wl-summary-buffer-elmo-folder))
4406 (when (elmo-message-use-cache-p folder num)
4407 (elmo-message-set-cached folder num t))
4409 (if (elmo-message-flagged-p wl-summary-buffer-elmo-folder
4412 (wl-summary-mark-as-read num no-folder-mark)
4413 (wl-summary-update-persistent-mark)))
4414 (setq wl-summary-buffer-current-msg num)
4415 (when wl-summary-recenter
4416 (recenter (/ (- (window-height) 2) 2))
4417 (if (not wl-summary-indent-length-limit)
4418 (wl-horizontal-recenter)))
4419 (wl-highlight-summary-displaying)
4420 (wl-message-buffer-prefetch-next folder num
4421 wl-message-buffer-prefetch-depth
4423 wl-summary-buffer-mime-charset)
4424 (run-hooks 'wl-summary-redisplay-hook))
4425 (message "No message to display."))))
4427 (defun wl-summary-redisplay-no-mime (&optional ask-coding)
4428 "Display message without MIME decoding.
4429 If ASK-CODING is non-nil, coding-system for the message is asked."
4431 (let ((elmo-mime-display-as-is-coding-system
4433 (or (read-coding-system "Coding system: ")
4434 elmo-mime-display-as-is-coding-system)
4435 elmo-mime-display-as-is-coding-system)))
4436 (wl-summary-redisplay-no-mime-internal)))
4438 (defun wl-summary-redisplay-no-mime-internal (&optional folder number)
4439 (let* ((fld (or folder wl-summary-buffer-elmo-folder))
4440 (num (or number (wl-summary-message-number)))
4444 (setq wl-summary-buffer-disp-msg t)
4445 (setq wl-summary-buffer-last-displayed-msg
4446 wl-summary-buffer-current-msg)
4447 (setq wl-current-summary-buffer (current-buffer))
4448 (wl-message-redisplay fld num 'as-is
4449 (string= (elmo-folder-name-internal fld)
4451 (when (elmo-message-use-cache-p fld num)
4452 (elmo-message-set-cached fld num t))
4454 (if (elmo-message-flagged-p fld num 'unread)
4455 (wl-summary-mark-as-read num); no-folder-mark)
4456 (wl-summary-update-persistent-mark)))
4457 (setq wl-summary-buffer-current-msg num)
4458 (when wl-summary-recenter
4459 (recenter (/ (- (window-height) 2) 2))
4460 (if (not wl-summary-indent-length-limit)
4461 (wl-horizontal-recenter)))
4462 (wl-highlight-summary-displaying)
4463 (run-hooks 'wl-summary-redisplay-hook))
4464 (message "No message to display.")
4465 (wl-ask-folder 'wl-summary-exit
4466 "No more messages. Type SPC to go to folder mode."))))
4468 (defun wl-summary-redisplay-all-header (&optional folder number)
4470 (let* ((fld (or folder wl-summary-buffer-elmo-folder))
4471 (num (or number (wl-summary-message-number)))
4472 (wl-mime-charset wl-summary-buffer-mime-charset)
4473 (default-mime-charset wl-summary-buffer-mime-charset))
4476 (setq wl-summary-buffer-disp-msg t)
4477 (setq wl-summary-buffer-last-displayed-msg
4478 wl-summary-buffer-current-msg)
4479 (setq wl-current-summary-buffer (current-buffer))
4480 (when (elmo-message-use-cache-p fld num)
4481 (elmo-message-set-cached fld num t))
4482 (if (wl-message-redisplay fld num 'all-header
4483 (string= (elmo-folder-name-internal fld)
4485 (wl-summary-mark-as-read num))
4486 (setq wl-summary-buffer-current-msg num)
4487 (when wl-summary-recenter
4488 (recenter (/ (- (window-height) 2) 2))
4489 (if (not wl-summary-indent-length-limit)
4490 (wl-horizontal-recenter)))
4491 (wl-highlight-summary-displaying)
4492 (run-hooks 'wl-summary-redisplay-hook))
4493 (message "No message to display."))))
4495 (defun wl-summary-jump-to-current-message ()
4496 "Jump into Message buffer."
4498 (let (message-buf message-win)
4499 (if (setq message-buf wl-message-buffer)
4500 (if (setq message-win (get-buffer-window message-buf))
4501 (select-window message-win)
4502 (wl-message-select-buffer wl-message-buffer))
4503 (wl-summary-redisplay)
4504 (wl-message-select-buffer wl-message-buffer))))
4506 (defun wl-summary-cancel-message ()
4507 "Cancel an article on news."
4509 (if (null (wl-summary-message-number))
4510 (message "No message.")
4511 (let ((summary-buf (current-buffer))
4513 (wl-summary-set-message-buffer-or-redisplay)
4514 (if (setq message-buf (wl-message-get-original-buffer))
4515 (set-buffer message-buf))
4516 (unless (wl-message-news-p)
4517 (set-buffer summary-buf)
4518 (if (and (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
4520 (y-or-n-p "Cannot get Newsgroups. Fetch again? "))
4522 (wl-summary-redisplay t)
4523 (wl-summary-supersedes-message))
4524 (error "This is not a news article; supersedes is impossible")))
4525 (when (yes-or-no-p "Do you really want to cancel this article? ")
4526 (let (from newsgroups message-id distribution buf)
4528 (setq from (std11-field-body "from")
4529 newsgroups (std11-field-body "newsgroups")
4530 message-id (std11-field-body "message-id")
4531 distribution (std11-field-body "distribution"))
4532 ;; Make sure that this article was written by the user.
4533 (unless (wl-address-user-mail-address-p
4534 (wl-address-header-extract-address
4535 (car (wl-parse-addresses from))))
4536 (error "This article is not yours"))
4537 ;; Make control message.
4538 (setq buf (set-buffer (get-buffer-create " *message cancel*")))
4539 (setq wl-draft-buffer-cur-summary-buffer summary-buf)
4540 (buffer-disable-undo (current-buffer))
4542 (insert "Newsgroups: " newsgroups "\n"
4543 "From: " (wl-address-header-extract-address
4545 "Subject: cmsg cancel " message-id "\n"
4546 "Control: cancel " message-id "\n"
4548 (concat "Distribution: " distribution "\n")
4550 mail-header-separator "\n"
4551 wl-summary-cancel-message)
4552 (message "Canceling your message...")
4553 (wl-draft-raw-send t t) ; kill when done, force-pre-hooks.
4554 (message "Canceling your message...done")))))))
4556 (defun wl-summary-supersedes-message ()
4557 "Supersede current message."
4559 (wl-summary-toggle-disp-msg 'off)
4560 (let ((summary-buf (current-buffer))
4562 (wl-summary-set-message-buffer-or-redisplay)
4563 (if (setq message-buf (wl-message-get-original-buffer))
4564 (set-buffer message-buf))
4565 (unless (wl-message-news-p)
4566 (set-buffer summary-buf)
4567 (if (and (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
4569 (y-or-n-p "Cannot get Newsgroups. Fetch again? "))
4571 (wl-summary-redisplay t)
4572 (wl-summary-supersedes-message))
4573 (error "This is not a news article; supersedes is impossible")))
4575 (setq from (std11-field-body "from"))
4576 ;; Make sure that this article was written by the user.
4577 (unless (wl-address-user-mail-address-p
4578 (wl-address-header-extract-address
4579 (car (wl-parse-addresses from))))
4580 (error "This article is not yours"))
4581 (let* ((message-id (std11-field-body "message-id"))
4582 (followup-to (std11-field-body "followup-to"))
4583 (mail-default-headers
4584 (concat mail-default-headers
4585 "Supersedes: " message-id "\n"
4587 (concat "Followup-To: " followup-to "\n")))))
4588 (if message-buf (set-buffer message-buf))
4589 (wl-draft-edit-string (buffer-substring (point-min) (point-max)))))))
4591 (defun wl-summary-save (&optional arg wl-save-dir)
4592 "Save current message to disk."
4595 (num (wl-summary-message-number)))
4596 (if (null wl-save-dir)
4597 (setq wl-save-dir wl-temporary-file-directory))
4600 (setq filename (expand-file-name
4601 (concat (int-to-string num)
4602 wl-summary-save-file-suffix)
4605 (null (file-exists-p filename))))
4607 (read-file-name "Save to file: " filename)))
4609 (wl-summary-set-message-buffer-or-redisplay)
4610 (set-buffer (wl-message-get-original-buffer))
4611 (if (and (null arg) (file-exists-p filename))
4612 (if (y-or-n-p "File already exists. override it? ")
4613 (write-region (point-min) (point-max) filename))
4614 (write-region (point-min) (point-max) filename)))
4615 (message "No message to save."))
4618 (defun wl-summary-save-region (beg end)
4622 (wl-summary-narrow-to-region beg end)
4623 (goto-char (point-min))
4625 (wl-read-directory-name "Save to directory: "
4626 wl-temporary-file-directory)))
4627 (if (null (file-exists-p wl-save-dir))
4628 (make-directory wl-save-dir))
4629 (if (eq wl-summary-buffer-view 'thread)
4632 (let* ((number (wl-summary-message-number))
4633 (entity (wl-thread-get-entity number)))
4634 (if (wl-thread-entity-get-opened entity)
4635 (wl-summary-save t wl-save-dir)
4637 (wl-summary-save t wl-save-dir))
4640 (wl-summary-save t wl-save-dir)
4641 (forward-line 1)))))))
4643 ;; mew-summary-pipe-message()
4644 (defun wl-summary-pipe-message (prefix command)
4645 "Send this message via pipe."
4646 (interactive (list current-prefix-arg nil))
4647 (if (null (wl-summary-message-number))
4648 (message "No message.")
4649 (setq command (read-string "Shell command on message: "
4650 wl-summary-shell-command-last))
4651 (if (y-or-n-p "Send this message to pipe? ")
4652 (wl-summary-pipe-message-subr prefix command))))
4654 (defun wl-summary-target-mark-pipe (prefix command)
4655 "Send each marked messages via pipe."
4656 (interactive (list current-prefix-arg nil))
4657 (if (null wl-summary-buffer-target-mark-list)
4658 (message "No marked message.")
4659 (setq command (read-string "Shell command on each marked message: "
4660 wl-summary-shell-command-last))
4661 (when (y-or-n-p "Send each marked message to pipe? ")
4662 (while (car wl-summary-buffer-target-mark-list)
4663 (let ((num (car wl-summary-buffer-target-mark-list)))
4664 (wl-thread-jump-to-msg num)
4665 (wl-summary-pipe-message-subr prefix command)
4666 (wl-summary-unmark))))))
4668 (defun wl-summary-pipe-message-subr (prefix command)
4670 (wl-summary-set-message-buffer-or-redisplay)
4671 (set-buffer (wl-message-get-original-buffer))
4672 (if (string= command "")
4673 (setq command wl-summary-shell-command-last))
4674 (goto-char (point-min)) ; perhaps this line won't be necessary
4676 (search-forward "\n\n"))
4677 (shell-command-on-region (point) (point-max) command nil)
4678 (setq wl-summary-shell-command-last command)))
4680 (defun wl-summary-print-message (&optional arg)
4682 (if (null (wl-summary-message-number))
4683 (message "No message.")
4685 (wl-summary-set-message-buffer-or-redisplay)
4686 (if (or (not (interactive-p))
4687 (y-or-n-p "Print ok? "))
4689 (let ((buffer (generate-new-buffer " *print*")))
4690 (copy-to-buffer buffer (point-min) (point-max))
4692 (funcall wl-print-buffer-function)
4693 (kill-buffer buffer)))
4696 (defun wl-summary-print-message-with-ps-print (&optional filename)
4697 "Print message via ps-print."
4699 (if (null (wl-summary-message-number))
4700 (message "No message.")
4701 (setq filename (ps-print-preprint current-prefix-arg))
4702 (if (or (not (interactive-p))
4703 (y-or-n-p "Print ok? "))
4704 (let ((summary-buffer (current-buffer))
4707 (wl-summary-set-message-buffer-or-redisplay)
4708 ;; (wl-summary-redisplay-internal)
4709 (let* ((buffer (generate-new-buffer " *print*"))
4711 (set-buffer summary-buffer)
4712 (elmo-message-entity
4713 wl-summary-buffer-elmo-folder
4714 (wl-summary-message-number))))
4717 (or (elmo-message-entity-field entity 'subject t)
4721 (or (elmo-message-entity-field entity 'from t) "")))
4724 (or (elmo-message-entity-field entity 'date) ""))))
4725 (run-hooks 'wl-ps-preprint-hook)
4726 (set-buffer wl-message-buffer)
4727 (copy-to-buffer buffer (point-min) (point-max))
4730 (let ((ps-left-header
4731 (list (concat "(" wl-ps-subject ")")
4732 (concat "(" wl-ps-from ")")))
4734 (list "/pagenumberstring load"
4735 (concat "(" wl-ps-date ")"))))
4736 (run-hooks 'wl-ps-print-hook)
4737 (funcall wl-ps-print-buffer-function filename))
4738 (kill-buffer buffer)))))
4741 (if (featurep 'ps-print) ; ps-print is available.
4742 (fset 'wl-summary-print-message 'wl-summary-print-message-with-ps-print))
4744 (defun wl-summary-target-mark-print ()
4746 (if (null wl-summary-buffer-target-mark-list)
4747 (message "No marked message.")
4748 (when (y-or-n-p "Print all marked messages. OK? ")
4749 (while (car wl-summary-buffer-target-mark-list)
4750 (let ((num (car wl-summary-buffer-target-mark-list)))
4751 (wl-thread-jump-to-msg num)
4752 (wl-summary-print-message)
4753 (wl-summary-unmark))))))
4755 (defun wl-summary-folder-info-update ()
4756 (wl-folder-set-folder-updated
4757 (elmo-string (wl-summary-buffer-folder-name))
4759 (+ wl-summary-buffer-unread-count
4760 wl-summary-buffer-new-count)
4762 wl-summary-buffer-elmo-folder))))
4764 (defun wl-summary-get-original-buffer ()
4765 "Get original buffer for the current summary."
4767 (wl-summary-set-message-buffer-or-redisplay)
4768 (wl-message-get-original-buffer)))
4770 (defun wl-summary-pack-number (&optional arg)
4772 (elmo-folder-pack-numbers wl-summary-buffer-elmo-folder)
4773 (let (wl-use-scoring)
4774 (wl-summary-rescan nil nil t)))
4776 (defun wl-summary-target-mark-uudecode ()
4778 (let ((mlist (reverse wl-summary-buffer-target-mark-list))
4779 (summary-buf (current-buffer))
4780 (tmp-buf (get-buffer-create "*WL UUENCODE*"))
4781 orig-buf i k filename rc errmsg)
4783 (setq k (length mlist))
4784 (set-buffer tmp-buf)
4786 (save-window-excursion
4788 (set-buffer summary-buf)
4789 (wl-summary-jump-to-msg (car mlist))
4790 (wl-summary-redisplay)
4791 (set-buffer (setq orig-buf (wl-summary-get-original-buffer)))
4792 (goto-char (point-min))
4793 (cond ((= i 1) ; first
4794 (if (setq filename (wl-message-uu-substring
4798 (error "Can't find begin line")))
4800 (wl-message-uu-substring orig-buf tmp-buf))
4802 (wl-message-uu-substring orig-buf tmp-buf nil t)))
4804 (setq mlist (cdr mlist)))
4805 (set-buffer tmp-buf)
4806 (message "Exec %s..." wl-prog-uudecode)
4808 (let ((decode-dir wl-temporary-file-directory))
4809 (if (not wl-prog-uudecode-no-stdout-option)
4810 (setq filename (read-file-name "Save to file: "
4812 (elmo-safe-filename filename)
4813 wl-temporary-file-directory)))
4815 (wl-read-directory-name "Save to directory: "
4816 wl-temporary-file-directory))
4817 (setq filename (expand-file-name filename decode-dir)))
4818 (if (file-exists-p filename)
4819 (or (yes-or-no-p (format "File %s exists. Save anyway? "
4822 (elmo-bind-directory
4826 (apply 'call-process-region (point-min) (point-max)
4827 wl-prog-uudecode t (current-buffer) nil
4828 wl-prog-uudecode-arg))))
4829 (when (not (= 0 rc))
4830 (setq errmsg (buffer-substring (point-min)(point-max)))
4831 (error "Uudecode error: %s" errmsg))
4832 (if (not wl-prog-uudecode-no-stdout-option)
4833 (let (file-name-handler-alist) ;; void jka-compr
4834 (as-binary-output-file
4835 (write-region (point-min) (point-max)
4836 filename nil 'no-msg))))
4838 (set-buffer summary-buf)
4839 (wl-summary-delete-all-target-marks))
4840 (if (file-exists-p filename)
4841 (message "Saved as %s" filename)))
4842 (kill-buffer tmp-buf)))))
4845 ;; (defun wl-summary-drop-unsync ()
4846 ;; "Drop all unsync messages."
4848 ;; (if (elmo-folder-pipe-p (wl-summary-buffer-folder-name))
4849 ;; (error "You cannot drop unsync messages in this folder"))
4850 ;; (if (or (not (interactive-p))
4851 ;; (y-or-n-p "Drop all unsync messages? "))
4852 ;; (let* ((folder-list (elmo-folder-get-primitive-folder-list
4853 ;; (wl-summary-buffer-folder-name)))
4854 ;; (is-multi (elmo-multi-p (wl-summary-buffer-folder-name)))
4858 ;; (message "Dropping...")
4859 ;; (while folder-list
4860 ;; (setq pair (elmo-folder-message-numbers (car folder-list)))
4861 ;; (when is-multi ;; dirty hack...
4863 ;; (setcar pair (+ (* multi-num elmo-multi-divide-number)
4865 ;; (elmo-msgdb-set-number-alist
4866 ;; (wl-summary-buffer-msgdb)
4868 ;; (elmo-msgdb-get-number-alist (wl-summary-buffer-msgdb))
4869 ;; (list (cons (car pair) nil))))
4870 ;; (setq sum (+ sum (cdr pair)))
4871 ;; (setq folder-list (cdr folder-list)))
4872 ;; (wl-summary-set-message-modified)
4873 ;; (wl-folder-set-folder-updated (wl-summary-buffer-folder-name)
4875 ;; (+ wl-summary-buffer-unread-count
4876 ;; wl-summary-buffer-new-count)
4878 ;; (message "Dropping...done"))))
4880 (defun wl-summary-default-get-next-msg (msg)
4881 (or (wl-summary-next-message msg
4882 (if wl-summary-move-direction-downward 'down
4885 (cadr (memq msg (if wl-summary-move-direction-downward
4886 wl-summary-buffer-number-list
4887 (reverse wl-summary-buffer-number-list))))))
4889 (defun wl-summary-save-current-message ()
4890 "Save current message for `wl-summary-yank-saved-message'."
4892 (let ((number (wl-summary-message-number)))
4893 (setq wl-summary-buffer-saved-message number)
4894 (and number (message "No: %s is saved." number))))
4896 (defun wl-summary-yank-saved-message ()
4897 "Set current message as a parent of the saved message."
4899 (if wl-summary-buffer-saved-message
4900 (let ((number (wl-summary-message-number)))
4901 (if (eq wl-summary-buffer-saved-message number)
4902 (message "Cannot set itself as a parent.")
4904 (wl-thread-jump-to-msg wl-summary-buffer-saved-message)
4905 (wl-thread-set-parent number)
4906 (wl-summary-set-thread-modified))
4907 (setq wl-summary-buffer-saved-message nil)))
4908 (message "There's no saved message.")))
4910 (defun wl-summary-toggle-header-narrowing ()
4911 "Toggle message header narrowing."
4913 (when wl-message-use-header-narrowing
4914 (save-selected-window
4915 (let* ((mbuf wl-message-buffer)
4916 (mwin (when mbuf (get-buffer-window mbuf)))
4917 (wpos (when mwin (window-start mwin))))
4920 (wl-message-header-narrowing-toggle)
4921 (and wpos (set-window-start mwin wpos)))))))
4923 (autoload 'elmo-folder-list-global-flag-messages "elmo-flag")
4926 (product-provide (provide 'wl-summary) (require 'wl-version))
4928 ;;; wl-summary.el ends here