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))))
590 wl-summary-highlight)
593 (while (and (< (point) end) (not (eobp)))
594 (when (null (get-text-property (point) 'face))
595 (setq number (wl-summary-message-number)
596 flags (elmo-message-flags wl-summary-buffer-elmo-folder
598 (setq wl-summary-highlight nil)
599 (wl-summary-update-persistent-mark number flags)
600 (setq wl-summary-highlight t)
601 (wl-highlight-summary-current-line number flags))
603 (set-buffer-modified-p nil)))
605 (defun wl-summary-window-scroll-functions ()
606 (cond ((and wl-summary-lazy-highlight
607 wl-summary-lazy-update-mark)
608 (list 'wl-summary-update-mark-and-highlight-window))
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 (defsubst wl-summary-cleanup-temp-marks (&optional sticky)
1093 (when wl-summary-buffer-temp-mark-list
1094 (if (y-or-n-p (format "Execute remaining marks in %s? "
1095 (wl-summary-buffer-folder-name)))
1098 (if wl-summary-buffer-temp-mark-list
1099 (error "Some execution was failed")))
1100 ;; temp-mark-list is remained.
1102 (wl-summary-delete-all-temp-marks 'no-msg)
1103 (setq wl-summary-scored nil))
1105 ;; a subroutine for wl-summary-exit/wl-save-status
1106 ;; Note that folder is not commited here.
1107 (defun wl-summary-save-view ()
1108 ;; already in summary buffer.
1109 (when wl-summary-buffer-persistent
1110 ;; save the current summary buffer view.
1111 (if (and wl-summary-cache-use
1112 (or (wl-summary-message-modified-p)
1113 (wl-summary-thread-modified-p)))
1114 (wl-summary-save-view-cache))))
1116 (defun wl-summary-save-status ()
1117 "Save summary view and msgdb."
1119 (if (interactive-p) (message "Saving summary status..."))
1120 (wl-summary-save-view)
1121 (elmo-folder-commit wl-summary-buffer-elmo-folder)
1122 (elmo-folder-check wl-summary-buffer-elmo-folder)
1123 (if wl-use-scoring (wl-score-save))
1124 (if (interactive-p) (message "Saving summary status...done")))
1126 (defun wl-summary-force-exit ()
1127 "Exit current summary. Buffer is deleted even the buffer is sticky."
1129 (wl-summary-exit 'force-exit))
1131 (defun wl-summary-exit (&optional force-exit)
1132 "Exit current summary. if FORCE-EXIT, exits even the summary is sticky."
1134 (let ((summary-buf (current-buffer))
1135 (sticky (wl-summary-sticky-p))
1137 message-buf message-win
1138 folder-buf folder-win)
1139 (run-hooks 'wl-summary-exit-pre-hook)
1140 (if wl-summary-buffer-exit-function
1141 (funcall wl-summary-buffer-exit-function)
1142 (if (or force-exit (not sticky))
1143 (wl-summary-cleanup-temp-marks sticky))
1145 ;; save summary status
1147 (wl-summary-save-view)
1148 (if (or force-exit (not sticky))
1149 (elmo-folder-close wl-summary-buffer-elmo-folder)
1150 (elmo-folder-commit wl-summary-buffer-elmo-folder)
1151 (elmo-folder-check wl-summary-buffer-elmo-folder))
1152 (if wl-use-scoring (wl-score-save)))
1153 ;; for sticky summary
1154 (wl-delete-all-overlays)
1155 (setq wl-summary-buffer-disp-msg nil)
1156 (elmo-kill-buffer wl-summary-search-buf-name)
1157 ;; delete message window if displayed.
1158 (if (and wl-message-buffer (get-buffer-window wl-message-buffer))
1159 (delete-window (get-buffer-window wl-message-buffer)))
1160 (if (and wl-summary-use-frame
1161 (> (length (visible-frame-list)) 1))
1163 (if (setq folder-buf (get-buffer wl-folder-buffer-name))
1164 (if wl-summary-use-frame
1166 (save-selected-window
1167 (dolist (frame (visible-frame-list))
1168 (select-frame frame)
1169 (if (get-buffer-window folder-buf)
1170 (setq select-frame frame))))
1172 (select-frame select-frame)
1173 (switch-to-buffer folder-buf)))
1174 (if (setq folder-win (get-buffer-window folder-buf))
1175 ;; folder win is already displayed.
1176 (select-window folder-win)
1177 ;; folder win is not displayed.
1178 (switch-to-buffer folder-buf)))
1179 ;; currently no folder buffer
1181 (and wl-folder-move-cur-folder
1182 wl-folder-buffer-cur-point
1183 (goto-char wl-folder-buffer-cur-point))
1184 (setq wl-folder-buffer-cur-path nil)
1185 (setq wl-folder-buffer-last-visited-entity-id wl-folder-buffer-cur-entity-id)
1186 (setq wl-folder-buffer-cur-entity-id nil)
1187 (wl-delete-all-overlays)
1188 (if wl-summary-exit-next-move
1189 (wl-folder-next-unsync t)
1190 (beginning-of-line))
1191 (if (setq summary-win (get-buffer-window summary-buf))
1192 (delete-window summary-win))
1196 (set-buffer summary-buf)
1197 (kill-buffer summary-buf)))
1198 (run-hooks 'wl-summary-exit-hook)))))
1200 (defun wl-summary-suspend ()
1203 (wl-folder-suspend))
1205 (defun wl-summary-sync-force-update (&optional unset-cursor no-check)
1207 (wl-summary-sync-update unset-cursor nil nil no-check))
1209 (defsubst wl-summary-sync-all-init ()
1210 (wl-summary-cleanup-temp-marks)
1212 (wl-summary-set-message-modified)
1213 (setq wl-thread-entity-hashtb (elmo-make-hash
1214 (* (elmo-folder-length
1215 wl-summary-buffer-elmo-folder)
1217 (setq wl-thread-entity-list nil)
1218 (setq wl-thread-entities nil)
1219 (setq wl-summary-buffer-number-list nil)
1220 (setq wl-summary-buffer-target-mark-list nil)
1221 (setq wl-summary-buffer-temp-mark-list nil))
1223 (defun wl-summary-sync (&optional unset-cursor force-range)
1225 (let* ((folder wl-summary-buffer-elmo-folder)
1226 (inhibit-read-only t)
1227 (buffer-read-only nil)
1228 (msgdb-dir (elmo-folder-msgdb-path folder))
1229 (range (or force-range (wl-summary-input-range
1230 (elmo-folder-name-internal folder)))))
1231 (cond ((string-match "rescan" range)
1232 (let ((msg (wl-summary-message-number))
1233 (wl-use-scoring (if (string-match "noscore" range)
1236 (wl-summary-rescan nil
1237 (string-match "noscore" range)
1238 (string-match "thread" range))
1239 (and msg (wl-summary-jump-to-msg msg))))
1240 ((string= range "mark")
1241 (let ((msg (wl-summary-message-number)))
1242 (call-interactively 'wl-summary-sync-marks)
1243 (and msg (wl-summary-jump-to-msg msg))))
1244 ((string= range "cache-status")
1245 (let ((msg (wl-summary-message-number)))
1246 (wl-summary-resume-cache-status)
1247 (and msg (wl-summary-jump-to-msg msg))))
1248 ((string= range "no-sync"))
1249 ((or (string-match "^last:" range)
1250 (string-match "^first:" range))
1251 (wl-summary-goto-folder-subr (concat "/" range "/"
1252 (elmo-folder-name-internal
1254 'force-update nil nil t))
1256 (wl-summary-sync-update unset-cursor
1257 (string-match "entirely" range)
1258 (string-match "all" range))))))
1260 (defvar wl-summary-edit-addresses-candidate-fields
1261 ;; First element becomes default.
1262 '("from" "to" "cc"))
1264 (defun wl-summary-edit-addresses-collect-candidate-fields (mime-charset)
1265 (let ((fields wl-summary-edit-addresses-candidate-fields)
1266 body candidates components)
1269 (mapconcat 'identity (elmo-multiple-field-body (car fields))
1271 (setq body (wl-parse-addresses body))
1272 (if body (setq candidates (append candidates body)))
1273 (setq fields (cdr fields)))
1274 (setq candidates (elmo-uniq-list candidates))
1276 (set-buffer-multibyte default-enable-multibyte-characters)
1279 (setq components (std11-extract-address-components x))
1280 (cons (nth 1 components)
1281 (and (car components)
1282 (eword-decode-string
1283 (decode-mime-charset-string
1288 (defun wl-summary-edit-addresses-subr (the-email name-in-addr)
1289 ;; returns nil if there's no change.
1290 (if (elmo-get-hash-val (downcase the-email) wl-address-petname-hash)
1292 (message "'%s' already exists. (e)dit/(d)elete/(c)ancel?"
1294 (while (not (or (eq (setq char (read-char)) ?\r)
1301 "Please answer `e' or `d' or `c'. (e)dit/(d)elete/(c)ancel?"))
1308 (wl-address-add-or-change
1310 (wl-address-header-extract-realname
1312 (let ((completion-ignore-case t) comp)
1314 (try-completion the-email wl-address-completion-list))
1315 (if (equal comp t) the-email comp))
1316 wl-address-completion-list))))
1320 (if (y-or-n-p (format "Delete '%s'? "
1323 (wl-address-delete the-email)
1330 (wl-address-add-or-change the-email name-in-addr)
1333 (defun wl-summary-edit-addresses (&optional addr-str)
1334 "Edit address book interactively.
1335 Optional argument ADDR-STR is used as a target address if specified."
1336 (interactive (if current-prefix-arg
1337 (list (read-from-minibuffer "Target address: "))))
1338 (if (null (wl-summary-message-number))
1339 (message "No message.")
1341 (let* ((charset wl-summary-buffer-mime-charset)
1343 (with-current-buffer (wl-summary-get-original-buffer)
1344 (wl-summary-edit-addresses-collect-candidate-fields
1346 address pair result)
1348 (setq address addr-str)
1350 (setq address (car (car candidates)))
1353 (format "Target address (%s): " address)
1355 (function (lambda (x) (cons (car x) (car x))))
1357 nil nil nil nil address))))
1359 (setq pair (assoc address candidates))
1361 (setq pair (cons address nil)))
1362 (when (setq result (wl-summary-edit-addresses-subr (car pair) (cdr pair)))
1365 (setq address (assoc (car pair) wl-address-list))
1367 (message "%s, %s, <%s> is %s."
1372 ;;; i'd like to update summary-buffer, but...
1373 ;;; (wl-summary-rescan)
1374 (run-hooks 'wl-summary-edit-addresses-hook))))))
1376 (defun wl-summary-incorporate (&optional arg)
1377 "Check and prefetch all uncached messages.
1378 If ARG is non-nil, checking is omitted."
1382 (wl-summary-sync-force-update)))
1383 (wl-summary-prefetch-region-no-mark (point-min) (point-max)
1384 wl-summary-incorporate-marks))
1386 (defun wl-summary-prefetch-msg (number &optional arg)
1387 "Prefetch message and return non-nil value. If skipped, return nil."
1388 ;; prefetching procedure.
1390 (let* ((size (elmo-message-field wl-summary-buffer-elmo-folder
1392 (file-cached (elmo-file-cache-exists-p
1393 (elmo-message-field wl-summary-buffer-elmo-folder
1394 number 'message-id)))
1395 (force-read (and size
1397 (and (null wl-prefetch-confirm) arg)
1398 (null wl-prefetch-threshold)
1399 (< size wl-prefetch-threshold))))
1402 (when (and (or arg (not file-cached))
1403 size (not force-read) wl-prefetch-confirm)
1404 (let ((wl-message-entity (elmo-message-entity
1405 wl-summary-buffer-elmo-folder
1412 "Message from %s has %d bytes. Prefetch it? "
1416 (wl-set-string-width
1419 wl-summary-from-function
1423 (elmo-message-entity-field
1429 (message ""))) ; flush.
1434 (if (or arg (not file-cached))
1435 (elmo-message-encache
1436 wl-summary-buffer-elmo-folder
1438 (elmo-message-set-cached wl-summary-buffer-elmo-folder
1440 (when (and (wl-summary-jump-to-msg number)
1441 (wl-summary-update-persistent-mark))
1443 (wl-summary-count-unread)
1444 (wl-summary-update-modeline)
1445 (wl-folder-update-unread
1446 (wl-summary-buffer-folder-name)
1447 (+ wl-summary-buffer-unread-count
1448 wl-summary-buffer-new-count))))
1452 (defsubst wl-summary-narrow-to-region (beg end)
1460 (if (eq (current-column) 0) (beginning-of-line) (end-of-line))
1463 (defun wl-summary-prefetch-region-no-mark (beg end &optional prefetch-marks)
1471 (setq start-pos (point))
1473 (wl-summary-narrow-to-region beg end)
1474 ;; collect prefetch targets.
1475 (message "Collecting marks...")
1476 (goto-char (point-min))
1478 (setq mark (wl-summary-persistent-mark)
1479 msg (wl-summary-message-number))
1480 (if (or (and (null prefetch-marks)
1482 (null (elmo-file-cache-exists-p
1484 wl-summary-buffer-elmo-folder
1487 (member mark prefetch-marks))
1488 (setq targets (nconc targets (list msg))))
1489 (setq entity (wl-thread-get-entity msg))
1490 (if (or (not (eq wl-summary-buffer-view 'thread))
1491 (wl-thread-entity-get-opened entity))
1492 (); opened. no hidden children.
1493 (setq targets (nconc
1495 (wl-thread-get-children-msgs-uncached
1496 msg prefetch-marks))))
1498 (setq length (length targets))
1499 (message "Prefetching...")
1501 (when (if (not (wl-thread-entity-parent-invisible-p
1502 (wl-thread-get-entity (car targets))))
1504 (wl-summary-jump-to-msg (car targets))
1505 (wl-summary-prefetch-msg
1506 (wl-summary-message-number)))
1507 (wl-summary-prefetch-msg (car targets)))
1508 (message "Prefetching... %d/%d message(s)"
1509 (setq count (+ 1 count)) length))
1510 (setq targets (cdr targets)))
1511 (message "Prefetched %d/%d message(s)" count length)
1512 (cons count length)))))
1514 (defun wl-summary-delete-marks-on-buffer (marks)
1516 (wl-summary-unmark (pop marks))))
1518 (defun wl-summary-delete-copy-marks-on-buffer (copies)
1519 (wl-summary-delete-marks-on-buffer copies))
1522 (defun wl-summary-delete-all-target-marks ()
1523 (wl-summary-delete-marks-on-buffer wl-summary-buffer-target-mark-list))
1525 (defun wl-summary-mark-as-read-region (beg end)
1529 (wl-summary-narrow-to-region beg end)
1530 (goto-char (point-min))
1531 (if (eq wl-summary-buffer-view 'thread)
1534 (let* ((number (wl-summary-message-number))
1535 (entity (wl-thread-get-entity number)))
1536 (if (wl-thread-entity-get-opened entity)
1537 (setq number-list (append number-list (list number)))
1540 (wl-thread-get-children-msgs number))))
1542 (wl-summary-mark-as-read number-list))
1546 (append number-list (list (wl-summary-message-number))))
1548 (wl-summary-mark-as-read number-list))))))
1550 (defun wl-summary-mark-as-unread-region (beg end)
1554 (wl-summary-narrow-to-region beg end)
1555 (goto-char (point-min))
1556 (if (eq wl-summary-buffer-view 'thread)
1559 (let* ((number (wl-summary-message-number))
1560 (entity (wl-thread-get-entity number)))
1561 (if (wl-thread-entity-get-opened entity)
1562 (setq number-list (append number-list (list number)))
1565 (wl-thread-get-children-msgs number))))
1567 (wl-summary-mark-as-unread number-list))
1571 (append number-list (list (wl-summary-message-number))))
1573 (wl-summary-mark-as-unread number-list))))))
1575 (defun wl-summary-set-flags-region (beg end)
1579 (wl-summary-narrow-to-region beg end)
1580 (goto-char (point-min))
1582 (if (eq wl-summary-buffer-view 'thread)
1584 (let* ((number (wl-summary-message-number))
1585 (entity (wl-thread-get-entity number))
1587 (if (wl-thread-entity-get-opened entity)
1588 ;; opened...mark line.
1589 ;; Crossposts are not processed
1590 (setq flags (wl-summary-set-flags-internal
1594 (setq flags (wl-summary-set-flags-internal
1595 (wl-thread-get-children-msgs number)
1599 (setq flags (wl-summary-set-flags-internal
1600 (wl-summary-message-number) flags))
1601 (forward-line 1))))))
1602 (wl-summary-count-unread)
1603 (wl-summary-update-modeline))
1605 (defun wl-summary-mark-as-answered-region (beg end)
1609 (wl-summary-narrow-to-region beg end)
1610 (goto-char (point-min))
1611 (let ((inverse (elmo-message-flagged-p wl-summary-buffer-elmo-folder
1612 (wl-summary-message-number)
1614 (if (eq wl-summary-buffer-view 'thread)
1616 (let* ((number (wl-summary-message-number))
1617 (entity (wl-thread-get-entity number))
1619 (if (wl-thread-entity-get-opened entity)
1620 ;; opened...mark line.
1621 ;; Crossposts are not processed
1622 (wl-summary-mark-as-answered-internal inverse)
1624 (wl-summary-mark-as-answered-internal
1626 (wl-thread-get-children-msgs number)))
1629 (wl-summary-mark-as-answered-internal inverse)
1630 (forward-line 1))))))
1631 (wl-summary-count-unread)
1632 (wl-summary-update-modeline))
1634 (defun wl-summary-mark-as-important-region (beg end)
1638 (wl-summary-narrow-to-region beg end)
1639 (goto-char (point-min))
1640 (let ((inverse (elmo-message-flagged-p wl-summary-buffer-elmo-folder
1641 (wl-summary-message-number)
1643 (if (eq wl-summary-buffer-view 'thread)
1645 (let* ((number (wl-summary-message-number))
1646 (entity (wl-thread-get-entity number))
1648 (if (wl-thread-entity-get-opened entity)
1649 ;; opened...mark line.
1650 ;; Crossposts are not processed
1651 (wl-summary-mark-as-important-internal inverse)
1653 (wl-summary-mark-as-important-internal
1655 (wl-thread-get-children-msgs number)))
1658 (wl-summary-mark-as-important-internal inverse)
1659 (forward-line 1))))))
1660 (wl-summary-count-unread)
1661 (wl-summary-update-modeline))
1663 (defun wl-summary-mark-as-read-all ()
1665 (if (or (not (interactive-p))
1666 (y-or-n-p "Mark all messages as read? "))
1667 (let ((folder wl-summary-buffer-elmo-folder)
1668 (cur-buf (current-buffer)))
1669 (message "Setting all msgs as read...")
1670 (elmo-folder-set-flag
1672 (elmo-folder-list-flagged folder 'unread 'in-msgdb)
1675 (goto-char (point-min))
1677 (wl-summary-update-persistent-mark)
1679 (wl-folder-update-unread (wl-summary-buffer-folder-name) 0)
1680 (setq wl-summary-buffer-unread-count 0)
1681 (setq wl-summary-buffer-new-count 0)
1682 (wl-summary-update-modeline)
1683 (message "Setting all msgs as read...done"))))
1685 (defun wl-summary-delete-cache ()
1686 "Delete cache of current message."
1689 (let* ((folder wl-summary-buffer-elmo-folder)
1691 (setq number (wl-summary-message-number))
1692 (elmo-message-set-cached folder number nil)
1693 (when (wl-summary-update-persistent-mark)
1694 (elmo-file-cache-delete
1695 (elmo-file-cache-get-path
1696 (elmo-message-field wl-summary-buffer-elmo-folder
1700 (defun wl-summary-resume-cache-status ()
1701 "Resume the cache status of all messages in the current folder."
1703 (let ((folder wl-summary-buffer-elmo-folder)
1705 (message "Resuming cache status...")
1707 (goto-char (point-min))
1709 (setq number (wl-summary-message-number))
1710 (setq msgid (elmo-message-field folder number 'message-id))
1711 (elmo-message-set-cached folder number
1712 (elmo-file-cache-exists-p msgid))
1713 (wl-summary-update-persistent-mark)
1715 (wl-summary-count-unread)
1716 (wl-summary-update-modeline)
1717 (message "Resuming cache status...done"))))
1719 (defun wl-summary-delete-messages-on-buffer (msgs &optional deleting-info)
1722 (let ((inhibit-read-only t)
1723 (buffer-read-only nil)
1727 ;(deleting-info (or deleting-info "Deleting..."))
1729 (elmo-kill-buffer wl-summary-search-buf-name)
1731 (if (eq wl-summary-buffer-view 'thread)
1733 ;; don't use wl-append(nconc), because list is broken. ...why?
1736 (wl-thread-delete-message (car msgs))))
1737 (setq update-list (delq (car msgs) update-list)))
1738 (goto-char (point-min))
1739 (if (wl-summary-jump-to-msg (car msgs))
1741 (delete-region (point-at-bol) (point-at-eol))
1742 (delete-char 1) ; delete '\n'
1743 (setq wl-summary-buffer-number-list
1744 (delq (car msgs) wl-summary-buffer-number-list)))))
1745 ; (when (> len elmo-display-progress-threshold)
1747 ; (if (or (zerop (% i 5)) (= i len))
1748 ; (elmo-display-progress
1749 ; 'wl-summary-delete-messages-on-buffer deleting-info
1750 ; (/ (* i 100) len))))
1751 (setq msgs (cdr msgs)))
1752 (when (eq wl-summary-buffer-view 'thread)
1753 (wl-thread-update-line-msgs (elmo-uniq-list update-list))
1754 (wl-thread-cleanup-symbols msgs2))
1755 ;;(message (concat deleting-info "done"))
1756 (wl-summary-count-unread)
1757 (wl-summary-update-modeline)
1758 (wl-summary-folder-info-update))))
1760 (defun wl-summary-update-status-marks (beg end &optional check)
1761 "Synchronize status marks on current buffer to the msgdb."
1765 (while (and (< (point) end) (not (eobp)))
1766 (when (or (not check)
1767 (let ((number (wl-summary-message-number)))
1768 (when (memq number wl-summary-buffer-unsync-mark-number-list)
1769 (setq wl-summary-buffer-unsync-mark-number-list
1771 wl-summary-buffer-unsync-mark-number-list))
1773 (wl-summary-update-persistent-mark))
1776 (defun wl-summary-update-mark-window (&optional win beg)
1777 "Update persistent mark in visible summary window.
1778 This function is defined for `window-scroll-functions'"
1779 (with-current-buffer (window-buffer win)
1780 (when (eq major-mode 'wl-summary-mode)
1781 (let ((start (window-start win))
1782 (end (condition-case nil
1783 (window-end win t) ; old emacsen doesn't support 2nd arg.
1784 (error (window-end win)))))
1785 (wl-summary-update-status-marks start end 'check)))))
1787 (defun wl-summary-insert-message (&rest args)
1788 (if (eq wl-summary-buffer-view 'thread)
1789 (apply 'wl-summary-insert-thread args)
1790 (apply 'wl-summary-insert-sequential args)))
1792 (defun wl-summary-sort ()
1796 (format "Sort by (%s): " (symbol-name wl-summary-default-sort-spec))
1797 (mapcar (lambda (spec)
1798 (list (symbol-name spec)))
1799 wl-summary-sort-specs)
1800 nil t nil nil (symbol-name wl-summary-default-sort-spec))))
1802 (defun wl-summary-sync-marks ()
1803 "Update persistent marks in summary."
1805 (let ((mes "Updated ")
1807 ;; synchronize marks.
1808 (when (not (eq (elmo-folder-type-internal
1809 wl-summary-buffer-elmo-folder)
1812 (message "Updating marks...")
1813 (dolist (flag elmo-global-flag-list)
1814 (unless (memq flag '(answered cached new unread))
1815 (setq diff (elmo-list-diff (elmo-folder-list-flagged
1816 wl-summary-buffer-elmo-folder
1818 (elmo-folder-list-flagged
1819 wl-summary-buffer-elmo-folder
1821 (setq diffs (cadr diff)) ; deletes
1822 (setq mes (concat mes (format "-%d" (length diffs))))
1824 (wl-summary-remove-flags-internal (car diffs)
1825 (list flag) 'no-server)
1826 (setq diffs (cdr diffs)))
1827 (setq diffs (car diff)) ; appends
1828 (setq mes (concat mes (format "/+%d %s," (length diffs) flag)))
1830 (wl-summary-add-flags-internal (car diffs)
1831 (list flag) 'no-server)
1832 (setq diffs (cdr diffs)))))
1834 (setq diff (elmo-list-diff (elmo-folder-list-flagged
1835 wl-summary-buffer-elmo-folder
1837 (elmo-folder-list-flagged
1838 wl-summary-buffer-elmo-folder
1839 'answered 'in-msgdb)))
1840 (setq diffs (cadr diff))
1841 (setq mes (concat mes (format "-%d" (length diffs))))
1843 (wl-summary-mark-as-unanswered (car diffs) 'no-modeline)
1844 (setq diffs (cdr diffs)))
1845 (setq diffs (car diff)) ; unread-appends
1846 (setq mes (concat mes (format "/+%d answered," (length diffs))))
1848 (wl-summary-mark-as-answered (car diffs) 'no-modeline)
1849 (setq diffs (cdr diffs)))
1851 (setq diff (elmo-list-diff (elmo-folder-list-flagged
1852 wl-summary-buffer-elmo-folder
1854 (elmo-folder-list-flagged
1855 wl-summary-buffer-elmo-folder
1856 'unread 'in-msgdb)))
1857 (setq diffs (cadr diff))
1858 (setq mes (concat mes (format "-%d" (length diffs))))
1860 (wl-summary-mark-as-read (car diffs) 'no-folder 'no-modeline)
1861 (setq diffs (cdr diffs)))
1862 (setq diffs (car diff)) ; unread-appends
1863 (setq mes (concat mes (format "/+%d unread." (length diffs))))
1865 (wl-summary-mark-as-unread (car diffs) 'no-folder 'no-modeline)
1866 (setq diffs (cdr diffs)))
1867 (if (interactive-p) (message "%s" mes)))))
1869 (defun wl-summary-sync-update (&optional unset-cursor
1873 "Update the summary view to the newest folder status."
1875 (let* ((folder wl-summary-buffer-elmo-folder)
1876 (elmo-mime-charset wl-summary-buffer-mime-charset)
1877 (inhibit-read-only t)
1878 (buffer-read-only nil)
1882 append-list delete-list crossed
1883 update-thread update-top-list
1884 expunged mes entity)
1887 (unless wl-summary-buffer-elmo-folder
1888 (error "(Internal error) Folder is not set:%s" (buffer-name
1890 ;; Flush pending append operations (disconnected operation).
1892 ;;(wl-summary-flush-pending-append-operations seen-list))
1893 (goto-char (point-max))
1894 (wl-folder-confirm-existence folder (elmo-folder-plugged-p folder))
1895 (setq crossed (elmo-folder-synchronize folder
1902 (if sync-all (wl-summary-sync-all-init))
1903 (setq diff (elmo-list-diff (elmo-folder-list-messages
1905 (not disable-killed)
1907 wl-summary-buffer-number-list))
1908 (setq append-list (car diff))
1909 (setq delete-list (cadr diff))
1912 (wl-summary-delete-messages-on-buffer delete-list))
1913 (unless wl-summary-lazy-update-mark
1914 (wl-summary-update-status-marks (point-min) (point-max)))
1915 (when (and wl-summary-lazy-highlight
1916 wl-summary-lazy-update-mark)
1917 (let (buffer-read-only)
1918 (put-text-property (point-min) (point-max) 'face nil))
1919 (run-hooks 'wl-summary-buffer-window-scroll-functions))
1920 (setq num (length append-list))
1922 (setq wl-summary-delayed-update nil)
1923 (elmo-kill-buffer wl-summary-search-buf-name)
1924 (dolist (number append-list)
1925 (setq entity (elmo-message-entity folder number))
1926 (when (setq update-thread
1927 (wl-summary-insert-message
1930 (wl-append update-top-list update-thread))
1931 (if elmo-use-database
1932 (elmo-database-msgid-put
1933 (car entity) (elmo-folder-name-internal folder)
1934 (elmo-message-entity-number entity)))
1935 (when (> num elmo-display-progress-threshold)
1937 (if (or (zerop (% i 5)) (= i num))
1938 (elmo-display-progress
1939 'wl-summary-sync-update
1940 (if (eq wl-summary-buffer-view 'thread)
1942 "Inserting message...")
1943 (/ (* i 100) num)))))
1944 (when wl-summary-delayed-update
1945 (while wl-summary-delayed-update
1946 (message "Parent (%d) of message %d is no entity"
1947 (caar wl-summary-delayed-update)
1948 (elmo-message-entity-number
1949 (cdar wl-summary-delayed-update)))
1950 (when (setq update-thread
1951 (wl-summary-insert-message
1952 (cdar wl-summary-delayed-update)
1953 wl-summary-buffer-elmo-folder
1955 (wl-append update-top-list update-thread))
1956 (setq wl-summary-delayed-update
1957 (cdr wl-summary-delayed-update))))
1958 (when (and (eq wl-summary-buffer-view 'thread)
1960 (wl-thread-update-indent-string-thread
1961 (elmo-uniq-list update-top-list)))
1962 (message (if (eq wl-summary-buffer-view 'thread)
1963 "Making thread...done"
1964 "Inserting message...done"))
1965 (when (or delete-list append-list)
1966 (wl-summary-set-message-modified))
1967 (when (and sync-all (eq wl-summary-buffer-view 'thread))
1968 (elmo-kill-buffer wl-summary-search-buf-name)
1969 (message "Inserting message...")
1970 (wl-thread-insert-top)
1971 (message "Inserting message...done"))
1972 (if elmo-use-database
1973 (elmo-database-close))
1974 (run-hooks 'wl-summary-sync-updated-hook)
1976 (if (and (eq (length delete-list) 0)
1979 "No updates for \"%s\"" (elmo-folder-name-internal
1981 (format "Updated (-%d/+%d) message(s)"
1982 (length delete-list) num))))
1983 (setq mes "Quit updating")))
1984 ;; synchronize marks.
1985 (if (and crossed wl-summary-auto-sync-marks)
1986 (wl-summary-sync-marks))
1988 (when wl-use-scoring
1989 (setq wl-summary-scored nil)
1990 (wl-summary-score-headers (and sync-all
1991 (wl-summary-rescore-msgs
1992 wl-summary-buffer-number-list))
1994 (when (and wl-summary-scored
1995 (setq expunged (wl-summary-score-update-all-lines)))
1996 (setq mes (concat mes
1997 (format " (%d expunged)"
1998 (length expunged))))))
1999 (if (and crossed (> crossed 0))
2003 (format " (%d crosspost)" crossed))
2004 (format "%d crosspost message(s)" crossed)))
2005 (and mes (setq mes (concat mes "."))))
2006 ;; Update Folder mode
2007 (wl-folder-set-folder-updated
2008 (elmo-folder-name-internal folder)
2010 (let ((lst (wl-summary-count-unread)))
2011 (+ (car lst) (nth 1 lst)))
2012 (elmo-folder-length folder)))
2013 (wl-summary-update-modeline)
2015 (unless unset-cursor
2016 (goto-char (point-min))
2017 (if (not (wl-summary-cursor-down t))
2019 (goto-char (point-max))
2021 (if (and wl-summary-highlight
2022 (not wl-summary-lazy-highlight)
2023 (not (get-text-property (point) 'face)))
2027 wl-summary-partial-highlight-above-lines
2028 wl-summary-highlight-partial-threshold)))
2029 (wl-highlight-summary (point) (point-max))))))
2030 (wl-delete-all-overlays)
2031 (set-buffer-modified-p nil)
2032 (if mes (message "%s" mes)))))
2034 (defun wl-summary-set-score-mark (mark)
2037 (let ((cur-mark (wl-summary-temp-mark)))
2038 (when (member cur-mark (list " "
2039 wl-summary-score-below-mark
2040 wl-summary-score-over-mark))
2041 (wl-summary-put-temp-mark mark)
2042 (if wl-summary-highlight
2043 (wl-highlight-summary-current-line))
2044 (set-buffer-modified-p nil)))))
2046 (defun wl-summary-get-score-mark (msg-num)
2047 (let ((score (cdr (assq msg-num wl-summary-scored))))
2049 (cond ((< score wl-summary-default-score)
2051 ((> score wl-summary-default-score)
2054 (defun wl-summary-update-modeline ()
2055 (setq wl-summary-buffer-mode-line
2056 (funcall wl-summary-buffer-mode-line-formatter)))
2058 (defun wl-summary-jump-to-msg (&optional number)
2060 (let ((num (or number
2062 (read-from-minibuffer "Jump to Message(No.): ")))))
2063 (setq num (int-to-string num))
2065 (if (or (and (re-search-forward (concat "\r" num "[^0-9]") nil t)
2066 (progn (backward-char 1) t))
2067 (re-search-backward (concat "\r" num "[^0-9]") nil t))
2068 (progn (beginning-of-line) t)
2071 (defun wl-summary-highlight-msgs (msgs)
2073 (let ((len (length msgs))
2075 (message "Hilighting...")
2078 (if (wl-summary-jump-to-msg (car msgs))
2079 (wl-highlight-summary-current-line))
2080 (setq msgs (cdr msgs))
2081 (when (> len elmo-display-progress-threshold)
2083 (if (or (zerop (% i 5)) (= i len))
2084 (elmo-display-progress
2085 'wl-summary-highlight-msgs "Highlighting..."
2086 (/ (* i 100) len)))))
2087 (message "Highlighting...done"))))
2089 (defun wl-summary-message-number ()
2092 (if (or (re-search-forward "\r\\(-?[0-9]+\\)" (point-at-eol) t)
2093 (re-search-forward "^ *\\(-?[0-9]+\\)" (point-at-eol) t))
2094 (string-to-int (wl-match-buffer 1))
2097 (defun wl-summary-delete-all-msgs ()
2099 (let ((cur-buf (current-buffer))
2100 (dels (elmo-folder-list-messages wl-summary-buffer-elmo-folder)))
2101 (set-buffer cur-buf)
2103 (message "No message to delete.")
2104 (if (y-or-n-p (format "%s has %d message(s). Delete all? "
2105 (wl-summary-buffer-folder-name)
2108 (message "Deleting...")
2109 (elmo-folder-move-messages wl-summary-buffer-elmo-folder dels
2111 (wl-summary-set-message-modified)
2112 (wl-folder-set-folder-updated (wl-summary-buffer-folder-name)
2115 ;;; (setq wl-thread-top-entity '(nil t nil nil))
2116 (setq wl-summary-buffer-unread-count 0)
2117 (setq wl-summary-buffer-new-count 0)
2118 (wl-summary-update-modeline)
2119 (set-buffer cur-buf)
2120 (let ((inhibit-read-only t)
2121 (buffer-read-only nil))
2123 ;;; (if wl-summary-cache-use (wl-summary-save-view-cache))
2124 (message "Deleting...done")
2128 (defun wl-summary-toggle-thread (&optional arg)
2129 "Toggle thread status (T)hread and (S)equential.
2130 If ARG, without confirm."
2133 (y-or-n-p (format "Toggle threading? (y=%s): "
2134 (if (eq wl-summary-buffer-view 'thread)
2135 "\"off\"" "\"on\""))))
2136 (if (eq wl-summary-buffer-view 'thread)
2137 (setq wl-summary-buffer-view 'sequence)
2138 (setq wl-summary-buffer-view 'thread))
2139 (wl-summary-update-modeline)
2140 (force-mode-line-update)
2141 (wl-summary-rescan nil nil t)))
2143 (defun wl-summary-load-file-object (filename)
2144 "Load lisp object from dir."
2146 (let ((tmp-buffer (get-buffer-create " *wl-summary-load-file-object*"))
2147 insert-file-contents-pre-hook ; To avoid autoconv-xmas...
2148 insert-file-contents-post-hook
2150 (if (not (file-readable-p filename))
2152 (set-buffer tmp-buffer)
2153 (as-binary-input-file (insert-file-contents filename))
2156 (read (current-buffer))
2157 (error (error "Reading failed")))))
2158 (kill-buffer tmp-buffer)
2161 (defun wl-summary-goto-folder (&optional arg)
2163 (wl-summary-goto-folder-subr nil nil nil nil t nil arg))
2165 (defun wl-summary-goto-folder-sticky ()
2167 (wl-summary-goto-folder-subr nil nil nil t t))
2169 (defun wl-summary-goto-last-visited-folder ()
2172 (wl-folder-search-entity-by-name wl-summary-last-visited-folder
2175 (if entity (wl-folder-set-current-entity-id
2176 (wl-folder-get-entity-id entity))))
2177 (wl-summary-goto-folder-subr wl-summary-last-visited-folder nil nil nil t))
2179 (defun wl-summary-sticky-p (&optional folder)
2181 (get-buffer (wl-summary-sticky-buffer-name
2182 (elmo-folder-name-internal folder)))
2183 (not (string= wl-summary-buffer-name (buffer-name)))))
2185 (defun wl-summary-always-sticky-folder-p (folder)
2186 (or (eq t wl-summary-always-sticky-folder-list)
2187 (wl-string-match-member
2188 (elmo-folder-name-internal folder)
2189 wl-summary-always-sticky-folder-list)))
2191 (defun wl-summary-stick (&optional force)
2192 "Make current summary buffer sticky."
2194 (if (wl-summary-sticky-p)
2195 (message "Current summary buffer is already sticky.")
2196 (when (or force (y-or-n-p "Stick current summary buffer? "))
2197 (wl-summary-toggle-disp-msg 'off)
2198 (wl-summary-switch-to-clone-buffer
2199 (wl-summary-sticky-buffer-name
2200 (wl-summary-buffer-folder-name)))
2202 ;;; (rename-buffer (wl-summary-sticky-buffer-name
2203 ;;; (wl-summary-buffer-folder-name))))
2204 (message "Folder `%s' is now sticky." (wl-summary-buffer-folder-name)))))
2206 (defun wl-summary-switch-to-clone-buffer (buffer-name)
2207 (let ((cur-buf (current-buffer))
2208 (msg (wl-summary-message-number))
2209 (buf (get-buffer-create buffer-name))
2210 (folder wl-summary-buffer-elmo-folder)
2212 (append '(wl-summary-buffer-view
2213 wl-summary-buffer-temp-mark-list
2214 wl-summary-buffer-target-mark-list
2215 wl-summary-buffer-elmo-folder
2216 wl-summary-buffer-number-column
2217 wl-summary-buffer-temp-mark-column
2218 wl-summary-buffer-persistent-mark-column
2219 wl-summary-buffer-message-modified
2220 wl-summary-buffer-thread-modified
2221 wl-summary-buffer-number-list
2222 wl-summary-buffer-unsync-mark-number-list
2223 wl-summary-buffer-folder-name
2224 wl-summary-buffer-line-formatter)
2225 (and (eq wl-summary-buffer-view 'thread)
2226 '(wl-thread-entity-hashtb
2228 wl-thread-entity-list))
2231 wl-summary-default-score
2232 wl-summary-important-above
2233 wl-summary-target-above
2234 wl-summary-mark-below
2235 wl-summary-expunge-below))
2236 (and (featurep 'wl-score)
2237 '(wl-current-score-file
2241 (wl-summary-buffer-set-folder folder)
2242 (let ((buffer-read-only nil))
2243 (insert-buffer cur-buf))
2244 (set-buffer-modified-p nil)
2245 (while copy-variables
2246 (set (car copy-variables)
2248 (set-buffer cur-buf)
2249 (symbol-value (car copy-variables))))
2250 (setq copy-variables (cdr copy-variables)))
2251 (switch-to-buffer buf)
2252 (kill-buffer cur-buf)
2253 (wl-summary-count-unread)
2254 (wl-summary-update-modeline)
2256 (if (eq wl-summary-buffer-view 'thread)
2257 (wl-thread-jump-to-msg msg)
2258 (wl-summary-jump-to-msg msg))
2259 (goto-char (point-max))
2260 (beginning-of-line))))
2262 (defun wl-summary-get-buffer (folder)
2264 (get-buffer (wl-summary-sticky-buffer-name folder)))
2265 (get-buffer wl-summary-buffer-name)))
2267 (defun wl-summary-get-buffer-create (name &optional force-sticky)
2270 (wl-summary-sticky-buffer-name name))
2271 (or (get-buffer (wl-summary-sticky-buffer-name name))
2272 (get-buffer-create wl-summary-buffer-name))))
2274 (defun wl-summary-make-number-list ()
2276 (goto-char (point-min))
2277 (setq wl-summary-buffer-number-list nil)
2279 (setq wl-summary-buffer-number-list
2280 (cons (wl-summary-message-number)
2281 wl-summary-buffer-number-list))
2283 (setq wl-summary-buffer-number-list
2284 (nreverse wl-summary-buffer-number-list))))
2286 (defun wl-summary-auto-select-msg-p (unread-msg)
2288 (not (elmo-message-has-global-flag-p
2289 wl-summary-buffer-elmo-folder unread-msg))))
2291 (defsubst wl-summary-open-folder (folder)
2293 (let ((elmo-mime-charset wl-summary-buffer-mime-charset))
2295 (elmo-folder-open folder 'load-msgdb)
2296 ;; For compatibility
2297 (setq wl-summary-buffer-folder-name (elmo-folder-name-internal
2300 (defun wl-summary-goto-folder-subr (&optional name scan-type other-window
2301 sticky interactive scoring
2303 "Display target folder on summary."
2305 (let* ((keep-cursor (memq this-command
2306 wl-summary-keep-cursor-command))
2307 (name (or name (wl-summary-read-folder wl-default-folder)))
2308 (cur-fld wl-summary-buffer-elmo-folder)
2309 folder buf mes hilit reuse-buf
2311 (if (string= name "")
2312 (setq name wl-default-folder))
2313 (setq folder (wl-folder-get-elmo-folder name))
2314 (when (and (not (string=
2315 (and cur-fld (elmo-folder-name-internal cur-fld))
2316 (elmo-folder-name-internal folder))) ; folder is moved.
2317 (eq major-mode 'wl-summary-mode)) ; called in summary.
2318 (setq wl-summary-last-visited-folder (wl-summary-buffer-folder-name))
2319 (run-hooks 'wl-summary-exit-pre-hook)
2320 (if (or force-exit (not (wl-summary-sticky-p)))
2321 (wl-summary-cleanup-temp-marks (wl-summary-sticky-p)))
2322 (wl-summary-save-view)
2323 (elmo-folder-commit wl-summary-buffer-elmo-folder)
2324 (if (and (wl-summary-sticky-p) force-exit)
2325 (kill-buffer (current-buffer))))
2326 (setq buf (wl-summary-get-buffer-create (elmo-folder-name-internal folder)
2331 (string= (elmo-folder-name-internal folder)
2332 (wl-summary-buffer-folder-name))))
2336 (switch-to-buffer buf)
2339 (delete-other-windows))
2341 (unless (eq major-mode 'wl-summary-mode)
2343 (wl-summary-buffer-set-folder folder)
2344 (setq wl-summary-buffer-disp-msg nil)
2345 (setq wl-summary-buffer-last-displayed-msg nil)
2346 (setq wl-summary-buffer-current-msg nil)
2347 (let ((inhibit-read-only t)
2348 (buffer-read-only nil))
2350 ;; Resume summary view
2351 (if wl-summary-cache-use
2352 (let* ((dir (elmo-folder-msgdb-path folder))
2353 (cache (expand-file-name wl-summary-cache-file dir))
2354 (view (expand-file-name wl-summary-view-file dir)))
2355 (when (file-exists-p cache)
2356 (insert-file-contents-as-binary cache)
2357 (set-buffer-multibyte
2358 default-enable-multibyte-characters)
2359 (decode-mime-charset-region
2360 (point-min)(point-max)
2361 wl-summary-buffer-mime-charset 'LF))
2362 (if (file-exists-p view)
2363 (setq wl-summary-buffer-view
2364 (wl-summary-load-file-object view))
2365 (setq wl-summary-buffer-view
2366 (or (wl-get-assoc-list-value
2367 wl-summary-default-view-alist
2368 (elmo-folder-name-internal folder))
2369 wl-summary-default-view)))
2370 (wl-thread-resume-entity folder)
2371 (wl-summary-open-folder folder)
2372 (wl-summary-detect-mark-position))
2373 (setq wl-summary-buffer-view
2374 (wl-summary-load-file-object
2375 (expand-file-name wl-summary-view-file
2376 (elmo-folder-msgdb-path folder))))
2377 (wl-summary-open-folder folder)
2378 (wl-summary-detect-mark-position)
2379 (wl-summary-rescan))
2380 (wl-summary-count-unread)
2381 (wl-summary-update-modeline)))
2382 (unless (eq wl-summary-buffer-view 'thread)
2383 (wl-summary-make-number-list))
2384 (setq wl-summary-buffer-unsync-mark-number-list
2385 (copy-sequence wl-summary-buffer-number-list))
2386 (when (and wl-summary-cache-use
2387 (or (and wl-summary-check-line-format
2388 (wl-summary-line-format-changed-p))
2389 (wl-summary-view-old-p)))
2390 (wl-summary-rescan))
2391 (wl-summary-toggle-disp-msg (if wl-summary-buffer-disp-msg 'on 'off))
2392 (unless (and reuse-buf keep-cursor)
2394 (let ((wl-use-scoring
2395 (if (or scoring interactive) wl-use-scoring)))
2396 (if (and (not scan-type)
2399 (setq scan-type (wl-summary-get-sync-range folder)))
2402 (wl-summary-sync 'unset-cursor))
2403 ((eq scan-type 'all)
2404 (wl-summary-sync 'unset-cursor "all"))
2405 ((eq scan-type 'no-sync))
2406 ((eq scan-type 'rescan)
2407 (wl-summary-rescan))
2408 ((or (eq scan-type 'force-update)
2409 (eq scan-type 'update))
2410 (setq mes (wl-summary-sync-force-update
2413 (switch-to-buffer buf)
2415 ;; stick always-sticky-folder
2416 (when (wl-summary-always-sticky-folder-p folder)
2417 (or (wl-summary-sticky-p) (wl-summary-stick t)))
2418 (run-hooks 'wl-summary-prepared-pre-hook)
2419 (set-buffer-modified-p nil)
2420 (goto-char (point-min))
2421 (if (wl-summary-cursor-down t)
2422 (let ((unreadp (wl-summary-next-message
2423 (wl-summary-message-number)
2425 (cond ((and wl-auto-select-first
2426 (wl-summary-auto-select-msg-p unreadp))
2427 ;; wl-auto-select-first is non-nil and
2428 ;; unreadp is non-nil but not flagged
2429 (setq retval 'disp-msg))
2430 ((and wl-auto-prefetch-first
2431 (wl-summary-auto-select-msg-p unreadp))
2432 ;; wl-auto-select-first is non-nil and
2433 ;; unreadp is non-nil but not flagged
2434 (setq retval 'prefetch-msg))
2435 ((not (wl-summary-auto-select-msg-p unreadp))
2436 ;; unreadp is nil or flagged
2437 (setq retval 'more-next))))
2438 (goto-char (point-max))
2439 (if (elmo-folder-plugged-p folder)
2442 (setq retval 'more-next))
2443 (if (and wl-summary-highlight
2444 (not wl-summary-lazy-highlight)
2446 (if (and wl-summary-highlight-partial-threshold
2447 (> (count-lines (point-min) (point-max))
2448 wl-summary-highlight-partial-threshold))
2453 wl-summary-partial-highlight-above-lines
2454 wl-summary-highlight-partial-threshold)))
2455 (wl-highlight-summary (point) (point-max)))
2456 (wl-highlight-summary (point-min) (point-max))))
2457 (if (eq retval 'disp-msg)
2458 (wl-summary-redisplay))
2459 (if (eq retval 'prefetch-msg)
2460 (wl-message-buffer-prefetch
2462 (wl-summary-message-number)
2463 wl-message-buffer-prefetch-depth
2465 wl-summary-buffer-mime-charset))
2466 (if mes (message "%s" mes))
2467 (if (and interactive wl-summary-recenter)
2468 (recenter (/ (- (window-height) 2) 2))))))
2469 ;; set current entity-id
2472 (wl-folder-search-entity-by-name
2473 (elmo-folder-name-internal folder)
2476 ;; entity-id is unknown.
2477 (wl-folder-set-current-entity-id
2478 (wl-folder-get-entity-id entity)))
2479 (when (and wl-summary-buffer-window-scroll-functions
2483 (run-hooks 'wl-summary-prepared-hook)
2484 (set-buffer-modified-p nil))
2487 (defun wl-summary-goto-previous-message-beginning ()
2489 (re-search-backward "\r\\(-?[0-9]+\\)" nil t)
2490 (beginning-of-line))
2492 (defun wl-summary-goto-top-of-current-thread ()
2493 (wl-summary-jump-to-msg
2494 (wl-thread-entity-get-number
2495 (wl-thread-entity-get-top-entity (wl-thread-get-entity
2496 (wl-summary-message-number))))))
2498 (defun wl-summary-goto-bottom-of-sub-thread (&optional depth)
2500 (let ((depth (or depth
2501 (wl-thread-get-depth-of-current-line))))
2503 (while (and (not (eobp))
2504 (>= (wl-thread-get-depth-of-current-line)
2507 (beginning-of-line)))
2509 (defun wl-summary-insert-line (line)
2510 "Insert LINE in the Summary."
2511 (if wl-use-highlight-mouse-line
2512 ;; remove 'mouse-face of current line.
2514 (save-excursion (beginning-of-line)(point))
2515 (save-excursion (end-of-line)(point))
2518 (if wl-use-highlight-mouse-line
2519 ;; remove 'mouse-face of current line.
2521 (save-excursion (beginning-of-line)(point))
2522 (save-excursion (end-of-line)(point))
2525 (run-hooks 'wl-summary-line-inserted-hook)))
2527 (defun wl-summary-insert-sequential (entity folder &rest args)
2529 (let ((inhibit-read-only t)
2530 (number (elmo-message-entity-number entity))
2532 (goto-char (point-max))
2533 (wl-summary-insert-line
2534 (wl-summary-create-line entity nil nil
2536 wl-summary-buffer-elmo-folder
2538 (elmo-message-cached-p
2539 wl-summary-buffer-elmo-folder
2541 (setq wl-summary-buffer-number-list
2542 (wl-append wl-summary-buffer-number-list
2543 (list (elmo-message-entity-number entity))))
2546 (defun wl-summary-default-subject-filter (subject)
2547 (setq subject (elmo-replace-in-string subject "[ \t]*\\(re\\|was\\)[:>]" ""))
2548 (setq subject (elmo-replace-in-string subject "[ \t]" ""))
2549 (elmo-replace-in-string subject "^\\[.*\\]" ""))
2551 (defun wl-summary-subject-equal (subject1 subject2)
2552 (string= (funcall wl-summary-subject-filter-function subject1)
2553 (funcall wl-summary-subject-filter-function subject2)))
2555 (defmacro wl-summary-put-alike (alike)
2556 (` (elmo-set-hash-val (format "#%d" (wl-count-lines))
2558 wl-summary-alike-hashtb)))
2560 (defmacro wl-summary-get-alike ()
2561 (` (elmo-get-hash-val (format "#%d" (wl-count-lines))
2562 wl-summary-alike-hashtb)))
2564 (defun wl-summary-insert-headers (folder func mime-decode)
2565 (let ((numbers (elmo-folder-list-messages folder 'visible t))
2567 (buffer-disable-undo (current-buffer))
2568 (make-local-variable 'wl-summary-alike-hashtb)
2569 (setq wl-summary-alike-hashtb (elmo-make-hash (* (length numbers) 2)))
2571 (set-buffer-multibyte default-enable-multibyte-characters))
2572 (while (setq ov (elmo-message-entity folder (pop numbers)))
2573 (setq this (funcall func ov))
2574 (and this (setq this (std11-unfold-string this)))
2575 (if (equal last this)
2576 (setq alike (cons ov alike))
2578 (wl-summary-put-alike alike)
2580 (setq alike (list ov)
2583 (wl-summary-put-alike alike)
2586 (decode-mime-charset-region (point-min) (point-max)
2588 (when (eq mime-decode 'mime)
2589 (eword-decode-region (point-min) (point-max))))
2590 (run-hooks 'wl-summary-insert-headers-hook)))
2592 (defun wl-summary-search-by-subject (entity folder)
2593 (let ((summary-buf (current-buffer))
2594 (buf (get-buffer-create wl-summary-search-buf-name))
2595 (folder-name (wl-summary-buffer-folder-name))
2596 match founds result)
2597 (with-current-buffer buf
2598 (let ((case-fold-search t))
2599 (when (or (not (string= wl-summary-search-buf-folder-name folder-name))
2600 (zerop (buffer-size)))
2601 (setq wl-summary-search-buf-folder-name folder-name)
2602 (message "Creating subject cache...")
2603 (wl-summary-insert-headers
2607 (funcall wl-summary-subject-filter-function
2608 (elmo-message-entity-field x 'subject))))
2610 (message "Creating subject cache...done"))
2611 (setq match (funcall wl-summary-subject-filter-function
2612 (elmo-message-entity-field entity 'subject
2614 (if (string= match "")
2616 (goto-char (point-max))
2617 (while (and (null result)
2618 (not (= (point) (point-min)))
2619 (search-backward match nil t))
2620 ;; check exactly match
2621 (when (and (bolp) (= (point-at-eol)(match-end 0)))
2622 (setq founds (wl-summary-get-alike))
2623 (with-current-buffer summary-buf
2626 ;; the first element of found-entity list exists on
2628 (wl-thread-get-entity
2629 (elmo-message-entity-number (car founds)))
2630 ;; message id is not same as myself.
2632 (elmo-message-entity-field entity 'message-id)
2633 (elmo-message-entity-field (car founds)
2635 ;; not a descendant.
2636 (not (wl-thread-descendant-p
2637 (elmo-message-entity-number entity)
2638 (elmo-message-entity-number (car founds)))))
2639 (setq result (car founds)
2641 (setq founds (cdr founds))))))
2644 (defun wl-summary-insert-thread (entity folder update
2645 &optional force-insert)
2647 this-id parent-entity parent-number
2648 number cur-entity linked retval delayed-entity
2649 update-list entity-stack thread-entity)
2651 (setq this-id (elmo-message-entity-field entity 'message-id)
2652 number (elmo-message-entity-number entity))
2653 (if (and wl-thread-saved-entity-hashtb-internal
2656 (format "#%d" (elmo-message-entity-number entity))
2657 wl-thread-saved-entity-hashtb-internal)))
2659 (elmo-message-entity
2661 (wl-thread-entity-get-parent thread-entity))
2662 linked (wl-thread-entity-get-linked thread-entity))
2663 (setq parent-entity (elmo-message-entity-parent folder entity)
2665 (setq parent-number (and parent-entity
2666 (elmo-message-entity-number parent-entity)))
2667 ;; If thread loop detected, set parent as nil.
2672 (elmo-message-entity-number
2673 (setq cur (elmo-message-entity-parent folder cur))))
2674 (if (memq anumber relatives)
2675 (setq parent-number nil
2677 (setq relatives (cons anumber relatives)))))
2678 (if (and parent-number
2679 (not (wl-thread-get-entity parent-number))
2681 ;; parent exists in overview, but not in wl-thread-entities
2683 (wl-append wl-summary-delayed-update
2684 (list (cons parent-number entity)))
2685 (setq entity nil)) ;; exit loop
2686 ;; Search parent by subject.
2687 (when (and (null parent-number)
2688 wl-summary-search-parent-by-subject-regexp
2690 wl-summary-search-parent-by-subject-regexp
2691 (elmo-message-entity-field entity 'subject)))
2692 (let ((found (wl-summary-search-by-subject entity folder)))
2694 (not (member found wl-summary-delayed-update)))
2695 (setq parent-entity found)
2697 (elmo-message-entity-number parent-entity))
2699 ;; If subject is change, divide thread.
2700 (if (and parent-number
2701 wl-summary-divide-thread-when-subject-changed
2702 (not (wl-summary-subject-equal
2703 (or (elmo-message-entity-field entity
2705 (or (elmo-message-entity-field parent-entity
2707 (setq parent-number nil))
2709 (wl-thread-insert-message entity
2710 number parent-number update linked))
2712 (wl-append update-list (list retval)))
2713 (setq entity nil) ; exit loop
2714 (while (setq delayed-entity (assq number wl-summary-delayed-update))
2715 (setq wl-summary-delayed-update
2716 (delq delayed-entity wl-summary-delayed-update))
2717 ;; update delayed message
2718 (wl-append entity-stack (list (cdr delayed-entity)))))
2719 (if (and (not entity)
2721 (setq entity (pop entity-stack))))
2724 (defun wl-summary-update-thread (entity
2727 (let* ((this-id (elmo-message-entity-field entity 'message-id))
2728 (overview-entity entity)
2729 (parent-id (elmo-message-entity-field parent-entity 'message-id))
2730 (number (elmo-message-entity-number entity))
2731 (parent-number (elmo-message-entity-number parent-entity))
2734 ((or (not parent-id)
2735 (string= this-id parent-id))
2736 (goto-char (point-max))
2738 (setq insert-line t))
2739 ;; parent already exists in buffer.
2740 ((wl-summary-jump-to-msg parent-number)
2741 (wl-thread-goto-bottom-of-sub-thread)
2742 (setq insert-line t)))
2744 (let (buffer-read-only)
2745 (wl-summary-insert-line
2746 (wl-summary-create-line
2750 (elmo-message-flags wl-summary-buffer-elmo-folder number)
2751 (elmo-message-cached-p wl-summary-buffer-elmo-folder number)
2752 (wl-thread-maybe-get-children-num number)
2753 (wl-thread-make-indent-string thr-entity)
2754 (wl-thread-entity-get-linked thr-entity)))))))
2756 (defun wl-summary-target-mark-msgs (msgs)
2757 "Return the number of marked messages."
2759 (dolist (number msgs)
2760 (when (wl-summary-target-mark number)
2764 (defun wl-summary-pick (&optional from-list delete-marks)
2767 (let* ((condition (car (elmo-parse-search-condition
2768 (elmo-read-search-condition
2769 wl-summary-pick-field-default))))
2770 (result (elmo-folder-search wl-summary-buffer-elmo-folder
2775 (let ((mlist wl-summary-buffer-target-mark-list))
2777 (when (wl-summary-jump-to-msg (car mlist))
2778 (wl-summary-unmark))
2779 (setq mlist (cdr mlist)))
2780 (setq wl-summary-buffer-target-mark-list nil)))
2782 (setq num (wl-summary-target-mark-msgs result))
2784 (if (= num (length result))
2785 (message "%d message(s) are picked." num)
2786 (message "%d(%d) message(s) are picked." num
2787 (- (length result) num)))
2788 (message "No message was picked.")))))
2790 (defun wl-summary-unvirtual ()
2791 "Exit from current virtual folder."
2794 (elmo-folder-type-internal wl-summary-buffer-elmo-folder))
2795 (wl-summary-goto-folder-subr
2796 (elmo-folder-name-internal
2797 (elmo-filter-folder-target-internal
2798 wl-summary-buffer-elmo-folder))
2800 (error "This folder is not filtered")))
2802 (defun wl-summary-virtual (&optional arg)
2803 "Goto virtual folder.
2804 If ARG, exit virtual folder."
2807 (wl-summary-unvirtual)
2808 (wl-summary-goto-folder-subr (concat "/"
2809 (elmo-read-search-condition
2810 wl-summary-pick-field-default)
2812 (wl-summary-buffer-folder-name))
2814 (run-hooks 'wl-summary-virtual-hook)))
2816 (defun wl-summary-delete-all-temp-marks (&optional no-msg force)
2817 "Erase all temp marks from buffer."
2819 (when (or wl-summary-buffer-target-mark-list
2820 wl-summary-buffer-temp-mark-list
2823 (goto-char (point-min))
2825 (message "Unmarking..."))
2827 (wl-summary-unset-mark nil nil force)
2830 (message "Unmarking...done"))
2831 (setq wl-summary-buffer-target-mark-list nil)
2832 (setq wl-summary-buffer-temp-mark-list nil))))
2834 (defsubst wl-summary-temp-mark (&optional number)
2835 "Return temp-mark string of current line."
2836 (let ((number (or number (wl-summary-message-number)))
2838 (or (and (wl-summary-have-target-mark-p number)
2840 (and (setq info (wl-summary-registered-temp-mark number))
2842 (wl-summary-get-score-mark number)
2845 (defsubst wl-summary-persistent-mark-string (folder flags cached)
2846 "Return the persistent mark string.
2847 The mark is decided according to the FOLDER, FLAGS and CACHED."
2848 (let ((priorities wl-summary-persistent-mark-priority-list)
2850 (while (and (null mark) priorities)
2851 (if (and (eq (car priorities) 'flag)
2852 (elmo-get-global-flags flags 'ignore-preserved))
2853 (setq mark wl-summary-flag-mark)
2854 (when (memq (car priorities) flags)
2856 (or (case (car priorities)
2859 wl-summary-new-cached-mark
2860 wl-summary-new-uncached-mark))
2863 wl-summary-answered-cached-mark
2864 wl-summary-answered-uncached-mark))
2867 wl-summary-unread-cached-mark
2868 wl-summary-unread-uncached-mark)))))))
2869 (setq priorities (cdr priorities)))
2871 (if (or cached (elmo-folder-local-p folder))
2873 wl-summary-read-uncached-mark))))
2875 (defsubst wl-summary-message-mark (folder number &optional flags)
2876 "Return mark of the message."
2878 (wl-summary-persistent-mark-string
2880 (or flags (setq flags (elmo-message-flags folder number)))
2881 (memq 'cached flags) ; XXX for speed-up.
2884 (defsubst wl-summary-persistent-mark (&optional number flags)
2885 "Return persistent-mark string of current line."
2886 (or (wl-summary-message-mark wl-summary-buffer-elmo-folder
2887 (or number (wl-summary-message-number))
2891 (defun wl-summary-put-temp-mark (mark)
2892 "Put temp MARK on current line."
2893 (when wl-summary-buffer-temp-mark-column
2896 (let ((inhibit-read-only t)
2897 (buffer-read-only nil))
2898 (move-to-column wl-summary-buffer-temp-mark-column)
2899 (delete-backward-char 1)
2902 (defun wl-summary-next-buffer ()
2903 "Switch to next summary buffer."
2905 (let ((buffers (sort (wl-collect-summary)
2906 (lambda (buffer1 buffer2)
2907 (string-lessp (buffer-name buffer1)
2908 (buffer-name buffer2))))))
2910 (or (cadr (memq (current-buffer) buffers))
2913 (defun wl-summary-previous-buffer ()
2914 "Switch to previous summary buffer."
2916 (let ((buffers (sort (wl-collect-summary)
2917 (lambda (buffer1 buffer2)
2918 (not (string-lessp (buffer-name buffer1)
2919 (buffer-name buffer2)))))))
2921 (or (cadr (memq (current-buffer) buffers))
2924 (defun wl-summary-target-mark-mark-as-read ()
2927 (goto-char (point-min))
2928 (let ((inhibit-read-only t)
2929 (buffer-read-only nil)
2930 wl-summary-buffer-disp-msg)
2931 (wl-summary-mark-as-read wl-summary-buffer-target-mark-list)
2932 (dolist (number wl-summary-buffer-target-mark-list)
2933 (wl-summary-unset-mark number)))))
2935 (defun wl-summary-target-mark-mark-as-unread ()
2938 (goto-char (point-min))
2939 (let ((inhibit-read-only t)
2940 (buffer-read-only nil)
2941 wl-summary-buffer-disp-msg)
2942 (wl-summary-mark-as-unread wl-summary-buffer-target-mark-list)
2943 (dolist (number wl-summary-buffer-target-mark-list)
2944 (wl-summary-unset-mark number)))))
2946 (defun wl-summary-target-mark-operation (flag)
2948 (goto-char (point-min))
2949 (let ((inhibit-read-only t)
2950 (buffer-read-only nil)
2951 wl-summary-buffer-disp-msg)
2953 (intern (format "wl-summary-mark-as-%s-internal" flag))
2955 wl-summary-buffer-target-mark-list)
2956 (dolist (number wl-summary-buffer-target-mark-list)
2957 (wl-summary-unset-mark number)))))
2959 (defun wl-summary-target-mark-mark-as-important ()
2961 (wl-summary-target-mark-operation 'important))
2963 (defun wl-summary-target-mark-mark-as-answered ()
2965 (wl-summary-target-mark-operation 'answered))
2967 (defun wl-summary-target-mark-set-flags ()
2970 (goto-char (point-min))
2971 (let ((inhibit-read-only t)
2972 (buffer-read-only nil)
2973 wl-summary-buffer-disp-msg
2975 (dolist (number wl-summary-buffer-target-mark-list)
2976 (wl-summary-unset-mark number)
2977 (setq flags (wl-summary-set-flags-internal number flags)))
2978 (wl-summary-count-unread)
2979 (wl-summary-update-modeline))))
2981 (defun wl-summary-target-mark-save ()
2984 (wl-read-directory-name "Save to directory: "
2985 wl-temporary-file-directory))
2987 (if (null (file-exists-p wl-save-dir))
2988 (make-directory wl-save-dir))
2989 (while (setq number (car wl-summary-buffer-target-mark-list))
2990 (wl-thread-jump-to-msg number)
2991 (wl-summary-save t wl-save-dir)
2992 (wl-summary-unmark))))
2994 (defun wl-summary-target-mark-pick ()
2996 (wl-summary-pick wl-summary-buffer-target-mark-list 'delete))
2998 (defun wl-summary-update-persistent-mark (&optional number flags)
2999 "Synch up persistent mark of current line with msgdb's.
3000 Return non-nil if the mark is updated"
3002 (when wl-summary-buffer-persistent-mark-column
3004 (move-to-column wl-summary-buffer-persistent-mark-column)
3005 (let ((inhibit-read-only t)
3006 (buffer-read-only nil)
3007 (mark (buffer-substring (- (point) 1) (point)))
3008 (new-mark (wl-summary-persistent-mark number flags)))
3009 (unless (string= new-mark mark)
3010 (delete-backward-char 1)
3012 (wl-summary-set-message-modified)
3014 (when wl-summary-highlight
3015 (wl-highlight-summary-current-line))
3016 (set-buffer-modified-p nil)))
3018 (defsubst wl-summary-mark-as-read-internal (inverse
3023 (let ((folder wl-summary-buffer-elmo-folder)
3024 unread-message number
3025 number-list visible)
3026 (setq number-list (cond ((numberp number-or-numbers)
3027 (setq unread-message
3028 (elmo-message-flagged-p
3032 (list number-or-numbers))
3033 ((and (not (null number-or-numbers))
3034 (listp number-or-numbers))
3036 ((setq number (wl-summary-message-number))
3038 (setq unread-message
3039 (elmo-message-flagged-p
3044 (if (null number-list)
3045 (message "No message.")
3047 (elmo-folder-unset-flag folder number-list 'read no-folder-mark)
3048 (elmo-folder-set-flag folder number-list 'read no-folder-mark))
3049 (dolist (number number-list)
3050 (setq visible (wl-summary-jump-to-msg number))
3052 (when unread-message
3053 (run-hooks 'wl-summary-unread-message-hook)))
3054 ;; set mark on buffer
3056 (wl-summary-update-persistent-mark)))
3057 (unless no-modeline-update
3058 ;; Update unread numbers.
3059 (wl-summary-count-unread)
3060 (wl-summary-update-modeline)
3061 (wl-folder-update-unread
3062 (wl-summary-buffer-folder-name)
3063 (+ wl-summary-buffer-unread-count
3064 wl-summary-buffer-new-count)))))))
3066 (defun wl-summary-mark-as-read (&optional number-or-numbers
3070 (wl-summary-mark-as-read-internal nil
3073 no-modeline-update))
3075 (defun wl-summary-mark-as-unread (&optional number-or-numbers
3079 (wl-summary-mark-as-read-internal 'inverse
3082 no-modeline-update))
3084 (defsubst wl-summary-mark-as-answered-internal (inverse
3089 (let ((folder wl-summary-buffer-elmo-folder)
3090 number number-list visible)
3091 (setq number-list (cond ((numberp number-or-numbers)
3092 (list number-or-numbers))
3093 ((and (not (null number-or-numbers))
3094 (listp number-or-numbers))
3096 ((setq number (wl-summary-message-number))
3099 (if (null number-list)
3100 (message "No message.")
3102 (elmo-folder-unset-flag folder number-list 'answered)
3103 (elmo-folder-set-flag folder number-list 'answered))
3104 (dolist (number number-list)
3105 (setq visible (wl-summary-jump-to-msg number))
3106 ;; set mark on buffer
3108 (wl-summary-update-persistent-mark)))
3109 (unless no-modeline-update
3110 ;; Update unread numbers.
3111 ;; should elmo-flag-mark-as-read return unread numbers?
3112 (wl-summary-count-unread)
3113 (wl-summary-update-modeline)
3114 (wl-folder-update-unread
3115 (wl-summary-buffer-folder-name)
3116 (+ wl-summary-buffer-unread-count
3117 wl-summary-buffer-new-count)))))))
3119 (defun wl-summary-mark-as-answered (&optional number-or-numbers
3122 (wl-summary-mark-as-answered-internal
3123 (and (interactive-p)
3124 (elmo-message-flagged-p wl-summary-buffer-elmo-folder
3125 (wl-summary-message-number)
3128 no-modeline-update))
3130 (defun wl-summary-mark-as-unanswered (&optional number-or-numbers
3132 (wl-summary-mark-as-answered-internal 'inverse
3134 no-modeline-update))
3136 (defun wl-summary-decide-flag (folder number)
3137 (let ((flags (elmo-get-global-flags (elmo-message-flags
3139 (completion-ignore-case t)
3145 (and (> (length flag) 0)
3146 (intern (downcase flag))))
3147 (wl-completing-read-multiple
3149 (mapcar (lambda (flag)
3150 (list (capitalize (symbol-name flag))))
3151 elmo-global-flag-list)
3152 nil nil (mapconcat (lambda (flag)
3153 (capitalize (symbol-name flag)))
3156 (dolist (flag new-flags)
3157 (unless (memq flag elmo-global-flag-list)
3158 (if (y-or-n-p (format "Flag `%s' does not exist yet. Create?"
3159 (capitalize (symbol-name flag))))
3160 (setq elmo-global-flag-list (append
3161 elmo-global-flag-list
3163 (error "Stopped"))))
3166 (defsubst wl-summary-set-flags-internal (&optional
3172 (let ((folder wl-summary-buffer-elmo-folder)
3173 number number-list visible)
3174 (setq number-list (cond ((numberp number-or-numbers)
3175 (list number-or-numbers))
3176 ((and (not (null number-or-numbers))
3177 (listp number-or-numbers))
3179 ((setq number (wl-summary-message-number))
3185 (setq flags (wl-summary-decide-flag folder (car number-list)))))
3186 (if (null number-list)
3187 (message "No message.")
3188 (dolist (number number-list)
3189 (elmo-message-set-global-flags folder number flags local)
3190 (setq visible (wl-summary-jump-to-msg number))
3191 ;; set mark on buffer
3193 (wl-summary-update-persistent-mark))))
3196 (defsubst wl-summary-add-flags-internal (&optional
3201 (let ((folder wl-summary-buffer-elmo-folder)
3202 set-flags msg number-list visible)
3203 (setq number-list (cond ((numberp number-or-numbers)
3204 (list number-or-numbers))
3205 ((and (not (null number-or-numbers))
3206 (listp number-or-numbers))
3208 ((setq msg (wl-summary-message-number))
3211 (if (null number-list)
3212 (message "No message.")
3213 (dolist (number number-list)
3215 (elmo-get-global-flags
3216 (elmo-message-flags folder number)))
3217 (setq set-flags (nconc flags set-flags))
3218 (elmo-message-set-global-flags folder number set-flags local)
3219 (setq visible (wl-summary-jump-to-msg number))
3220 ;; set mark on buffer
3222 (wl-summary-update-persistent-mark)))))))
3224 (defsubst wl-summary-remove-flags-internal (&optional
3229 (let ((folder wl-summary-buffer-elmo-folder)
3230 set-flags msg number-list visible)
3231 (setq number-list (cond ((numberp number-or-numbers)
3232 (list number-or-numbers))
3233 ((and (not (null number-or-numbers))
3234 (listp number-or-numbers))
3236 ((setq msg (wl-summary-message-number))
3239 (if (null number-list)
3240 (message "No message.")
3241 (dolist (number number-list)
3242 (setq set-flags (elmo-get-global-flags
3243 (elmo-message-flags folder number)))
3244 (dolist (flag flags)
3245 (setq set-flags (delq flag set-flags)))
3246 (elmo-message-set-global-flags folder number set-flags local)
3247 (setq visible (wl-summary-jump-to-msg number))
3248 ;; set mark on buffer
3250 (wl-summary-update-persistent-mark)))))))
3252 (defun wl-summary-set-flags (&optional remove)
3254 (if (eq 'flag (elmo-folder-type-internal wl-summary-buffer-elmo-folder))
3255 (error "Cannot process flags in this folder"))
3256 (wl-summary-set-flags-internal nil nil nil remove))
3258 (defun wl-summary-mark-as-important-internal (inverse
3259 &optional number-or-numbers)
3261 (wl-summary-remove-flags-internal number-or-numbers '(important))
3262 (wl-summary-add-flags-internal number-or-numbers '(important))))
3264 (defun wl-summary-mark-as-important (&optional prompt)
3266 (if (eq 'flag (elmo-folder-type-internal wl-summary-buffer-elmo-folder))
3267 (error "Cannot process flags in this folder"))
3269 (wl-summary-set-flags-internal)
3270 (wl-summary-mark-as-important-internal
3271 (and (interactive-p)
3272 (elmo-message-flagged-p wl-summary-buffer-elmo-folder
3273 (wl-summary-message-number)
3277 (defvar wl-summary-line-formatter nil)
3279 (defun wl-summary-view-old-p ()
3280 "Return non-nil when summary view cache has old format."
3282 (goto-char (point-min))
3283 (and wl-summary-buffer-number-list
3284 (not (re-search-forward "\r-?[0-9]+" (point-at-eol) t)))))
3286 (defun wl-summary-line-format-changed-p ()
3287 "Return non-nil when summary line format is changed."
3289 wl-summary-buffer-line-format
3290 (or (elmo-object-load (expand-file-name
3291 wl-summary-line-format-file
3292 (elmo-folder-msgdb-path
3293 wl-summary-buffer-elmo-folder))
3294 wl-summary-buffer-mime-charset)
3295 wl-summary-buffer-line-format))))
3297 (defun wl-summary-line-format-save ()
3298 "Save current summary line format."
3300 (expand-file-name wl-summary-line-format-file
3301 (elmo-folder-msgdb-path
3302 wl-summary-buffer-elmo-folder))
3303 wl-summary-buffer-line-format
3304 wl-summary-buffer-mime-charset))
3306 (defun wl-summary-line-number ()
3307 (wl-set-string-width
3308 (- wl-summary-buffer-number-column)
3310 (elmo-message-entity-number wl-message-entity))))
3312 (defun wl-summary-line-year ()
3313 (aref wl-datevec 0))
3314 (defun wl-summary-line-month ()
3315 (format "%02d" (aref wl-datevec 1)))
3316 (defun wl-summary-line-day ()
3317 (format "%02d" (aref wl-datevec 2)))
3318 (defun wl-summary-line-day-of-week ()
3320 (elmo-date-get-week (aref wl-datevec 0)
3322 (aref wl-datevec 2))
3324 (defun wl-summary-line-hour ()
3325 (format "%02d" (aref wl-datevec 3)))
3326 (defun wl-summary-line-minute ()
3327 (format "%02d" (aref wl-datevec 4)))
3329 (defun wl-summary-line-size ()
3330 (let ((size (elmo-message-entity-field wl-message-entity 'size)))
3333 ((<= 1 (/ size 1048576))
3334 (format "%.0fM" (/ size 1048576.0)))
3335 ((<= 1 (/ size 1024))
3336 (format "%.0fK" (/ size 1024.0)))
3337 (t (format "%dB" size)))
3340 (defun wl-summary-line-subject ()
3341 (let (no-parent subject parent-raw-subject parent-subject)
3342 (if (string= wl-thr-indent-string "")
3343 (setq no-parent t)) ; no parent
3345 (elmo-delete-char ?\n
3346 (or (elmo-message-entity-field
3349 wl-summary-no-subject-message)))
3350 (setq parent-raw-subject
3351 (elmo-message-entity-field wl-parent-message-entity
3353 (setq parent-subject
3354 (if parent-raw-subject
3355 (elmo-delete-char ?\n parent-raw-subject)))
3357 (null parent-subject)
3358 (not (wl-summary-subject-equal
3359 subject parent-subject)))
3360 (funcall wl-summary-subject-function subject)
3363 (defun wl-summary-line-from ()
3364 (elmo-delete-char ?\n
3365 (funcall wl-summary-from-function
3366 (elmo-message-entity-field
3370 (defun wl-summary-line-list-info ()
3371 (let ((list-info (wl-summary-get-list-info wl-message-entity)))
3373 (format (if (cdr list-info) "(%s %05.0f)" "(%s)")
3374 (car list-info) (cdr list-info))
3377 (defun wl-summary-line-list-count ()
3378 (let ((ml-count (cdr (wl-summary-get-list-info wl-message-entity))))
3380 (format "%.0f" ml-count)
3383 (defun wl-summary-line-attached ()
3384 (let ((content-type (elmo-message-entity-field
3385 wl-message-entity 'content-type))
3386 (case-fold-search t))
3387 (if (and content-type
3388 (string-match "multipart/mixed" content-type))
3393 ;;(defun wl-summary-line-cached ()
3394 ;; (if (elmo-message-cached-p wl-summary-buffer-elmo-folder
3395 ;; (elmo-message-entity-number wl-message-entity))
3399 (defun wl-summary-create-line (wl-message-entity
3400 wl-parent-message-entity
3405 wl-thr-children-number
3406 wl-thr-indent-string
3408 "Create a summary line."
3409 (let ((wl-mime-charset wl-summary-buffer-mime-charset)
3410 (wl-persistent-mark (wl-summary-persistent-mark-string
3411 wl-summary-buffer-elmo-folder
3414 (elmo-mime-charset wl-summary-buffer-mime-charset)
3415 (elmo-lang wl-summary-buffer-weekday-name-lang)
3416 (wl-datevec (or (ignore-errors (timezone-fix-time
3417 (elmo-message-entity-field
3421 wl-summary-fix-timezone))
3423 (entity wl-message-entity) ; backward compatibility.
3425 (if (and wl-thr-indent-string
3426 wl-summary-indent-length-limit
3427 (< wl-summary-indent-length-limit
3428 (string-width wl-thr-indent-string)))
3429 (setq wl-thr-indent-string (wl-set-string-width
3430 wl-summary-indent-length-limit
3431 wl-thr-indent-string)))
3432 (setq line (funcall wl-summary-buffer-line-formatter))
3433 (if wl-summary-width (setq line
3434 (wl-set-string-width
3435 (- wl-summary-width 1) line nil
3437 (setq line (concat line
3440 (elmo-message-entity-number
3441 wl-message-entity))))
3442 (if wl-summary-highlight
3443 (wl-highlight-summary-line-string
3444 (elmo-message-entity-number wl-message-entity)
3448 wl-thr-indent-string))
3451 (defsubst wl-summary-proc-wday (wday-str year month mday)
3453 (if (string-match "\\([A-Z][a-z][a-z]\\).*" wday-str)
3454 (wl-match-string 1 wday-str)
3455 (elmo-date-get-week year month mday))))
3457 (defvar wl-summary-move-spec-alist
3462 (unread . ((t . nil)
3466 (defsubst wl-summary-next-message (num direction hereto)
3467 (if wl-summary-buffer-next-message-function
3468 (funcall wl-summary-buffer-next-message-function num direction hereto)
3469 (let ((cur-spec (cdr (assq wl-summary-move-order
3470 wl-summary-move-spec-alist)))
3471 (nums (memq num (if (eq direction 'up)
3472 (reverse wl-summary-buffer-number-list)
3473 wl-summary-buffer-number-list)))
3475 (unless hereto (setq nums (cdr nums)))
3481 (cond ((eq (car (car cur-spec)) 'p)
3482 (if (setq flagged-list
3483 (elmo-folder-list-flagged
3484 wl-summary-buffer-elmo-folder
3485 (cdr (car cur-spec)) t))
3487 (if (and (memq (car nums) flagged-list)
3488 (elmo-message-accessible-p
3489 wl-summary-buffer-elmo-folder
3491 (throw 'done (car nums)))
3492 (setq nums (cdr nums)))))
3493 ((eq (car (car cur-spec)) 't)
3494 (if wl-summary-buffer-target-mark-list
3496 (if (memq (car nums)
3497 wl-summary-buffer-target-mark-list)
3498 (throw 'done (car nums)))
3499 (setq nums (cdr nums))))))
3500 (setq cur-spec (cdr cur-spec))))
3503 (defsubst wl-summary-cursor-move (direction hereto)
3504 (when (and (eq direction 'up)
3509 (when (setq num (wl-summary-next-message (wl-summary-message-number)
3512 (wl-thread-jump-to-msg num))
3515 ;; Goto unread or global flag message
3516 ;; returns t if next message exists in this folder.
3517 (defun wl-summary-cursor-down (&optional hereto)
3519 (wl-summary-cursor-move 'down hereto))
3521 (defun wl-summary-cursor-up (&optional hereto)
3523 (wl-summary-cursor-move 'up hereto))
3525 (defun wl-summary-save-view-cache ()
3527 (let* ((dir (elmo-folder-msgdb-path wl-summary-buffer-elmo-folder))
3528 (cache (expand-file-name wl-summary-cache-file dir))
3529 (view (expand-file-name wl-summary-view-file dir))
3530 (save-view wl-summary-buffer-view)
3531 (mark-list (copy-sequence wl-summary-buffer-target-mark-list))
3532 (temp-list (copy-sequence wl-summary-buffer-temp-mark-list))
3533 (tmp-buffer (get-buffer-create " *wl-summary-save-view-cache*"))
3534 (temp-column wl-summary-buffer-temp-mark-column)
3535 (charset wl-summary-buffer-mime-charset))
3537 (if (file-directory-p dir)
3539 (if (file-exists-p dir)
3540 (error "File %s already exists" dir)
3541 (elmo-make-directory dir)))
3542 (if (eq save-view 'thread)
3543 (wl-thread-save-entity dir))
3544 (when wl-summary-check-line-format
3545 (wl-summary-line-format-save))
3548 (when (file-writable-p cache)
3549 (copy-to-buffer tmp-buffer (point-min) (point-max))
3550 (with-current-buffer tmp-buffer
3552 (make-local-variable 'wl-summary-highlight)
3553 (setq wl-summary-highlight nil
3554 wl-summary-buffer-target-mark-list mark-list
3555 wl-summary-buffer-temp-mark-list temp-list
3556 wl-summary-buffer-temp-mark-column temp-column)
3557 (wl-summary-delete-all-temp-marks 'no-msg 'force)
3558 (encode-coding-region
3559 (point-min) (point-max)
3561 ;; one in mcs-ltn1(apel<10.4) cannot take 2 arg.
3562 (mime-charset-to-coding-system charset 'LF))
3563 ;; Mule 2 doesn't have `*ctext*unix'.
3564 (mime-charset-to-coding-system charset)))
3565 (write-region-as-binary (point-min)(point-max)
3566 cache nil 'no-msg)))
3567 (when (file-writable-p view) ; 'thread or 'sequence
3569 (set-buffer tmp-buffer)
3571 (prin1 save-view tmp-buffer)
3572 (princ "\n" tmp-buffer)
3573 (write-region (point-min) (point-max) view nil 'no-msg))))
3575 (kill-buffer tmp-buffer))))))
3577 (defsubst wl-summary-get-sync-range (folder)
3579 (elmo-folder-plugged-p folder)
3580 (wl-get-assoc-list-value
3581 wl-folder-sync-range-alist
3582 (elmo-folder-name-internal folder)
3584 wl-default-sync-range)))
3586 ;; redefined for wl-summary-sync-update
3587 (defun wl-summary-input-range (folder)
3588 "returns update or all or rescan."
3589 ;; for the case when parts are expanded in the bottom of the folder
3590 (let ((input-range-list '("no-sync"
3602 (default (or (wl-get-assoc-list-value
3603 wl-folder-sync-range-alist
3606 wl-default-sync-range))
3609 (completing-read (format "Range (%s): " default)
3611 (function (lambda (x) (cons x x)))
3613 (if (string= range "")
3617 (defun wl-summary-toggle-disp-folder (&optional arg)
3619 (let ((cur-buf (current-buffer))
3620 (summary-win (get-buffer-window (current-buffer)))
3624 (setq wl-summary-buffer-disp-folder t)
3625 ;; hide your folder window
3626 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
3627 (if (setq fld-win (get-buffer-window fld-buf))
3628 (delete-window fld-win))))
3630 (setq wl-summary-buffer-disp-folder nil)
3631 ;; hide your wl-message window!
3632 (when (buffer-live-p wl-message-buffer)
3633 (wl-message-select-buffer wl-message-buffer)
3635 (select-window (get-buffer-window cur-buf))
3636 ;; display wl-folder window!!
3637 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
3638 (if (setq fld-win (get-buffer-window fld-buf))
3639 ;; folder win is already displayed.
3640 (select-window fld-win)
3641 ;; folder win is not displayed.
3642 (switch-to-buffer fld-buf))
3645 ;; temporarily delete summary-win.
3647 (delete-window summary-win))
3648 (split-window-horizontally wl-folder-window-width)
3650 (switch-to-buffer cur-buf))
3652 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
3653 (if (setq fld-win (get-buffer-window fld-buf))
3654 (setq wl-summary-buffer-disp-folder nil)
3655 (setq wl-summary-buffer-disp-folder t)))
3656 (if (not wl-summary-buffer-disp-folder)
3657 ;; hide message window
3658 (let ((mes-win (and wl-message-buffer
3659 (get-buffer-window wl-message-buffer)))
3660 (wl-stay-folder-window t))
3661 (if mes-win (delete-window mes-win))
3662 ;; hide your folder window
3663 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
3664 (if (setq fld-win (get-buffer-window fld-buf))
3666 (delete-window (get-buffer-window cur-buf))
3667 (select-window fld-win)
3668 (switch-to-buffer cur-buf))))
3669 (run-hooks 'wl-summary-toggle-disp-folder-off-hook)
3670 ;; resume message window.
3672 (wl-message-select-buffer wl-message-buffer)
3673 (run-hooks 'wl-summary-toggle-disp-folder-message-resumed-hook)
3674 (select-window (get-buffer-window cur-buf))))
3675 ;; hide message window
3676 (let ((wl-stay-folder-window t)
3677 (mes-win (and wl-message-buffer
3678 (get-buffer-window wl-message-buffer))))
3679 (if mes-win (delete-window mes-win))
3680 (select-window (get-buffer-window cur-buf))
3681 ;; display wl-folder window!!
3682 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
3683 (if (setq fld-win (get-buffer-window fld-buf))
3684 ;; folder win is already displayed.
3685 (select-window fld-win)
3686 ;; folder win is not displayed...occupy all.
3687 (switch-to-buffer fld-buf))
3690 (split-window-horizontally wl-folder-window-width)
3692 (switch-to-buffer cur-buf)
3693 ;; resume message window.
3694 (run-hooks 'wl-summary-toggle-disp-folder-on-hook)
3696 (wl-message-select-buffer wl-message-buffer)
3697 (run-hooks 'wl-summary-toggle-disp-folder-message-resumed-hook)
3698 (select-window (get-buffer-window cur-buf))))))))
3699 (run-hooks 'wl-summary-toggle-disp-folder-hook))
3701 (defun wl-summary-toggle-disp-msg (&optional arg)
3703 (let ((cur-buf (current-buffer))
3708 (setq wl-summary-buffer-disp-msg t)
3710 ;; hide your folder window
3711 (if (and (not wl-stay-folder-window)
3712 (setq fld-buf (get-buffer wl-folder-buffer-name)))
3713 (if (setq fld-win (get-buffer-window fld-buf))
3714 (unless (one-window-p fld-win)
3715 (delete-window fld-win))))))
3717 (wl-delete-all-overlays)
3718 (setq wl-summary-buffer-disp-msg nil)
3720 (when (buffer-live-p wl-message-buffer)
3721 (wl-message-select-buffer wl-message-buffer)
3723 (and (get-buffer-window cur-buf)
3724 (select-window (get-buffer-window cur-buf))))
3725 (run-hooks 'wl-summary-toggle-disp-off-hook)))
3727 (if (and wl-message-buffer
3728 (get-buffer-window wl-message-buffer)) ; already displayed
3729 (setq wl-summary-buffer-disp-msg nil)
3730 (setq wl-summary-buffer-disp-msg t))
3731 (if wl-summary-buffer-disp-msg
3733 (wl-summary-redisplay)
3734 ;;; hide your folder window
3735 ;;; (setq fld-buf (get-buffer wl-folder-buffer-name))
3736 ;;; (if (setq fld-win (get-buffer-window fld-buf))
3737 ;;; (delete-window fld-win)))
3738 (run-hooks 'wl-summary-toggle-disp-on-hook))
3739 (wl-delete-all-overlays)
3741 (wl-message-select-buffer wl-message-buffer)
3743 (select-window (get-buffer-window cur-buf))
3744 (setq wl-message-buffer nil)
3745 (run-hooks 'wl-summary-toggle-disp-off-hook))
3746 ;;; (switch-to-buffer cur-buf)
3748 (run-hooks 'wl-summary-buffer-window-scroll-functions)))
3750 (defun wl-summary-next-line-content ()
3751 "Show next line of the message."
3753 (let ((cur-buf (current-buffer)))
3754 (wl-summary-toggle-disp-msg 'on)
3755 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
3756 (set-buffer cur-buf)
3757 (wl-message-next-page 1))))
3759 (defun wl-summary-prev-line-content ()
3761 (let ((cur-buf (current-buffer)))
3762 (wl-summary-toggle-disp-msg 'on)
3763 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
3764 (set-buffer cur-buf)
3765 (wl-message-prev-page 1))))
3767 (defun wl-summary-next-page ()
3769 (let ((cur-buf (current-buffer)))
3770 (wl-summary-toggle-disp-msg 'on)
3771 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
3772 (set-buffer cur-buf)
3773 (wl-message-next-page))))
3775 (defun wl-summary-prev-page ()
3777 (let ((cur-buf (current-buffer)))
3778 (wl-summary-toggle-disp-msg 'on)
3779 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
3780 (set-buffer cur-buf)
3781 (wl-message-prev-page))))
3783 (defsubst wl-summary-no-mime-p (folder)
3784 (wl-string-match-member (elmo-folder-name-internal folder)
3785 wl-summary-no-mime-folder-list))
3787 (defun wl-summary-set-message-buffer-or-redisplay (&rest args)
3788 "Set message buffer.
3789 If message is not displayed yet, display it.
3790 Return t if message exists."
3791 (let ((folder wl-summary-buffer-elmo-folder)
3792 (number (wl-summary-message-number))
3793 cur-folder cur-number message-last-pos)
3794 (when (buffer-live-p wl-message-buffer)
3795 (save-window-excursion
3796 (wl-message-select-buffer wl-message-buffer)
3797 (setq cur-folder wl-message-buffer-cur-folder)
3798 (setq cur-number wl-message-buffer-cur-number)))
3799 (if (and (string= (elmo-folder-name-internal folder) (or cur-folder ""))
3800 (eq number (or cur-number 0)))
3802 (set-buffer wl-message-buffer)
3804 (if (wl-summary-no-mime-p folder)
3805 (wl-summary-redisplay-no-mime-internal folder number)
3806 (wl-summary-redisplay-internal folder number))
3807 (when (buffer-live-p wl-message-buffer)
3808 (set-buffer wl-message-buffer))
3811 (defun wl-summary-target-mark-forward (&optional arg)
3813 (let ((mlist (nreverse wl-summary-buffer-target-mark-list))
3814 (summary-buf (current-buffer))
3815 (wl-draft-forward t)
3818 (wl-summary-jump-to-msg (car mlist))
3819 (wl-summary-forward t)
3820 (setq start-point (point))
3821 (setq draft-buf (current-buffer))
3822 (setq mlist (cdr mlist))
3823 (save-window-excursion
3826 (set-buffer summary-buf)
3827 (wl-summary-jump-to-msg (car mlist))
3828 (wl-summary-redisplay)
3829 (set-buffer draft-buf)
3830 (goto-char (point-max))
3831 (wl-draft-insert-message)
3832 (setq mlist (cdr mlist)))
3833 (wl-draft-body-goto-top)
3834 (wl-draft-enclose-digest-region (point) (point-max)))
3835 (goto-char start-point)
3837 (set-buffer summary-buf)
3838 (wl-summary-delete-all-temp-marks)))
3839 (run-hooks 'wl-mail-setup-hook)))
3841 (defun wl-summary-target-mark-reply-with-citation (&optional arg)
3843 (let ((mlist (nreverse wl-summary-buffer-target-mark-list))
3844 (summary-buf (current-buffer))
3845 change-major-mode-hook
3848 (wl-summary-jump-to-msg (car mlist))
3849 (when (wl-summary-reply arg t)
3850 (goto-char (point-max))
3851 (setq start-point (point-marker))
3852 (setq draft-buf (current-buffer))
3853 (save-window-excursion
3855 (set-buffer summary-buf)
3856 (delete-other-windows)
3857 (wl-summary-jump-to-msg (car mlist))
3858 (wl-summary-redisplay)
3859 (set-buffer draft-buf)
3860 (goto-char (point-max))
3861 (wl-draft-yank-original)
3862 (setq mlist (cdr mlist)))
3863 (goto-char start-point)
3865 (set-buffer summary-buf)
3866 (wl-summary-delete-all-temp-marks)))
3867 (wl-draft-reply-position wl-draft-reply-default-position)
3868 (run-hooks 'wl-mail-setup-hook))))
3870 (defun wl-summary-reply-with-citation (&optional arg)
3872 (when (wl-summary-reply arg t)
3873 (goto-char (point-max))
3874 (wl-draft-yank-original)
3875 (wl-draft-reply-position wl-draft-reply-default-position)
3876 (run-hooks 'wl-mail-setup-hook)))
3878 (defun wl-summary-jump-to-msg-by-message-id (&optional id)
3880 (let* ((original (wl-summary-message-number))
3881 (msgid (elmo-string (or id (read-from-minibuffer "Message-ID: "))))
3882 (entity (elmo-message-entity wl-summary-buffer-elmo-folder msgid))
3884 (errmsg (format "No message with id \"%s\" in the folder." msgid)))
3885 (if (setq msg (elmo-message-entity-number entity))
3887 (wl-thread-jump-to-msg msg)
3890 (if (and elmo-use-database
3893 "No message with id \"%s\" in the database." msgid))
3894 (setq otherfld (elmo-database-msgid-get msgid)))
3895 (if (cdr (wl-summary-jump-to-msg-internal
3896 (car otherfld) (nth 1 otherfld) 'no-sync))
3898 ;; Back to original.
3899 (wl-summary-jump-to-msg-internal
3900 (wl-summary-buffer-folder-name) original 'no-sync))
3901 (cond ((eq wl-summary-search-via-nntp 'confirm)
3902 (require 'elmo-nntp)
3903 (message "Search message in nntp server \"%s\" <y/n/s(elect)>? "
3904 elmo-nntp-default-server)
3905 (setq schar (let ((cursor-in-echo-area t)) (read-char)))
3906 (cond ((eq schar ?y)
3907 (wl-summary-jump-to-msg-by-message-id-via-nntp msgid))
3909 (wl-summary-jump-to-msg-by-message-id-via-nntp
3911 (read-from-minibuffer "NNTP Server: ")))
3913 (message "%s" errmsg)
3915 ((or (eq wl-summary-search-via-nntp 'force)
3917 (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
3919 wl-summary-search-via-nntp))
3920 (wl-summary-jump-to-msg-by-message-id-via-nntp msgid))
3922 (message "%s" errmsg)
3925 (defun wl-summary-jump-to-msg-by-message-id-via-nntp (&optional id server-spec)
3927 (let* ((msgid (elmo-string (or id (read-from-minibuffer "Message-ID: "))))
3928 newsgroups folder ret
3929 user server port type spec)
3931 (if (string-match "^-" server-spec)
3932 (setq spec (wl-folder-get-elmo-folder server-spec)
3933 user (elmo-net-folder-user-internal spec)
3934 server (elmo-net-folder-server-internal spec)
3935 port (elmo-net-folder-port-internal spec)
3936 type (elmo-net-folder-stream-type-internal spec))
3937 (setq server server-spec)))
3938 (when (setq ret (elmo-nntp-get-newsgroup-by-msgid
3940 (or server elmo-nntp-default-server)
3941 (or user elmo-nntp-default-user)
3942 (or port elmo-nntp-default-port)
3943 (or type elmo-nntp-default-stream-type)))
3944 (setq newsgroups (elmo-nntp-parse-newsgroups ret))
3945 (setq folder (concat "-" (car newsgroups)
3946 (elmo-nntp-folder-postfix user server port type)))
3949 (if (wl-folder-entity-exists-p (car newsgroups)
3950 wl-folder-newsgroups-hashtb)
3952 (setq folder (concat "-" (car newsgroups)
3953 (elmo-nntp-folder-postfix
3954 user server port type)))))
3955 (setq newsgroups (cdr newsgroups)))))
3957 (wl-summary-jump-to-msg-internal folder nil 'update msgid)
3958 (message "No message id \"%s\" in nntp server \"%s\"."
3959 msgid (or server elmo-nntp-default-server))
3962 (defun wl-summary-jump-to-msg-internal (folder msg scan-type &optional msgid)
3963 (let (wl-auto-select-first entity)
3964 (if (or (string= folder (wl-summary-buffer-folder-name))
3967 "Message was found in the folder \"%s\". Jump to it? "
3971 (wl-summary-goto-folder-subr
3972 folder scan-type nil nil t)
3975 (elmo-message-entity-number
3976 (elmo-message-entity
3977 wl-summary-buffer-elmo-folder
3979 (setq entity (wl-folder-search-entity-by-name folder
3983 (wl-folder-set-current-entity-id
3984 (wl-folder-get-entity-id entity))))
3986 (message "Message was not found currently in this folder.")
3987 (setq msg (and (wl-thread-jump-to-msg msg) msg)))
3988 (cons folder msg)))))
3990 (defun wl-summary-jump-to-parent-message (arg)
3992 (let ((cur-buf (current-buffer))
3993 (disp-msg wl-summary-buffer-disp-msg)
3994 (number (wl-summary-message-number))
3995 (regexp "\\(<[^<>]*>\\)[ \t]*$")
3997 msg-id msg-num ref-list ref irt)
3999 (message "No message.")
4000 (when (eq wl-summary-buffer-view 'thread)
4001 (cond ((and arg (not (numberp arg)))
4003 (wl-thread-entity-get-number
4004 (wl-thread-entity-get-top-entity
4005 (wl-thread-get-entity number)))))
4006 ((and arg (numberp arg))
4008 (setq msg-num number)
4011 (wl-thread-entity-get-number
4012 (wl-thread-entity-get-parent-entity
4013 (wl-thread-get-entity msg-num))))
4016 (wl-thread-entity-get-number
4017 (wl-thread-entity-get-parent-entity
4018 (wl-thread-get-entity number)))))))
4019 (when (null msg-num)
4020 (wl-summary-set-message-buffer-or-redisplay)
4021 (set-buffer (wl-message-get-original-buffer))
4022 (message "Searching parent message...")
4023 (setq ref (std11-field-body "References")
4024 irt (std11-field-body "In-Reply-To"))
4026 ((and arg (not (numberp arg)) ref (not (string= ref ""))
4027 (string-match regexp ref))
4028 ;; The first message of the thread.
4029 (setq msg-id (wl-match-string 1 ref)))
4030 ;; "In-Reply-To:" has only one msg-id.
4031 ((and (null arg) irt (not (string= irt ""))
4032 (string-match regexp irt))
4033 (setq msg-id (wl-match-string 1 irt)))
4034 ((and (or (null arg) (numberp arg)) ref (not (string= ref ""))
4035 (string-match regexp ref))
4036 ;; "^" searching parent, "C-u 2 ^" looking for grandparent.
4037 (while (string-match regexp ref)
4040 (wl-match-string 1 ref))
4042 (setq ref (substring ref (match-end 0)))
4045 (if (null arg) (nth 0 ref-list) ;; previous
4046 (if (<= arg i) (nth (1- arg) ref-list)
4047 (nth i ref-list))))))
4048 (set-buffer cur-buf)
4049 (or disp-msg (wl-summary-toggle-disp-msg 'off)))
4050 (cond ((and (null msg-id) (null msg-num))
4051 (message "No parent message!")
4053 ((and msg-id (wl-summary-jump-to-msg-by-message-id msg-id))
4054 (if wl-summary-buffer-disp-msg (wl-summary-redisplay))
4055 (message "Searching parent message...done")
4057 ((and msg-num (wl-summary-jump-to-msg msg-num))
4058 (if wl-summary-buffer-disp-msg (wl-summary-redisplay))
4059 (message "Searching parent message...done")
4062 (message "Parent message was not found.")
4065 (defun wl-summary-reply (&optional arg without-setup-hook)
4066 "Reply to current message. Default is \"wide\" reply.
4067 Reply to author if invoked with ARG."
4069 (let ((folder wl-summary-buffer-elmo-folder)
4070 (number (wl-summary-message-number))
4071 (summary-buf (current-buffer))
4072 (winconf (current-window-configuration))
4076 (wl-summary-set-message-buffer-or-redisplay))
4077 (setq mes-buf wl-message-buffer)
4078 (wl-message-select-buffer wl-message-buffer)
4079 (set-buffer mes-buf)
4081 (when (setq mes-buf (wl-message-get-original-buffer))
4082 (wl-draft-reply mes-buf arg summary-buf number)
4083 (wl-draft-reply-position wl-draft-reply-default-position)
4084 (unless without-setup-hook
4085 (run-hooks 'wl-mail-setup-hook)))
4086 (error (set-window-configuration winconf)
4087 (signal (car err)(cdr err))))
4088 (with-current-buffer summary-buf
4089 (elmo-folder-set-flag folder (list number) 'answered)
4090 (wl-summary-update-persistent-mark))
4093 (defun wl-summary-write ()
4094 "Write a new draft from Summary."
4096 (wl-draft (list (cons 'To ""))
4097 nil nil nil nil (wl-summary-buffer-folder-name))
4098 (run-hooks 'wl-mail-setup-hook)
4099 (mail-position-on-field "To"))
4101 (defvar wl-summary-write-current-folder-functions
4102 '(wl-folder-get-newsgroups
4103 wl-folder-guess-mailing-list-by-refile-rule
4104 wl-folder-guess-mailing-list-by-folder-name)
4105 "Newsgroups or Mailing List address guess functions list.
4106 Call from `wl-summary-write-current-folder'.
4107 When guess function return nil, challenge next guess-function.")
4109 (defun wl-summary-write-current-folder (&optional folder)
4110 "Write message to current FOLDER's newsgroup or mailing-list.
4111 Use function list is `wl-summary-write-current-folder-functions'."
4113 ;; default FOLDER is current buffer folder
4114 (setq folder (or folder (wl-summary-buffer-folder-name)))
4115 (let ((func-list wl-summary-write-current-folder-functions)
4116 guess-list guess-func)
4118 (setq guess-list (funcall (car func-list) folder))
4119 (if (null guess-list)
4120 (setq func-list (cdr func-list))
4121 (setq guess-func (car func-list))
4122 (setq func-list nil)))
4123 (if (null guess-func)
4125 (unless (or (stringp (nth 0 guess-list))
4126 (stringp (nth 1 guess-list))
4127 (stringp (nth 2 guess-list)))
4128 (error "Invalid value return guess function `%s'"
4129 (symbol-name guess-func)))
4130 (wl-draft (list (cons 'To (nth 0 guess-list))
4131 (cons 'Cc (nth 1 guess-list))
4132 (cons 'Newsgroups (nth 2 guess-list)))
4133 nil nil nil nil folder)
4134 (run-hooks 'wl-mail-setup-hook)
4135 (mail-position-on-field "Subject"))))
4137 (defun wl-summary-forward (&optional without-setup-hook)
4140 (let ((folder wl-summary-buffer-elmo-folder)
4141 (number (wl-summary-message-number))
4142 (summary-buf (current-buffer))
4143 (wl-draft-forward t)
4147 (message "No message.")
4148 (if (and (elmo-message-use-cache-p folder number)
4149 (eq (elmo-file-cache-status
4150 (elmo-file-cache-get
4151 (elmo-message-field folder number 'message-id)))
4154 (wl-summary-redisplay-internal nil nil 'force-reload)
4155 (wl-summary-redisplay-internal folder number))
4156 (setq mes-buf wl-message-buffer)
4157 (wl-message-select-buffer mes-buf)
4158 ;; get original subject.
4161 (set-buffer summary-buf)
4163 (or (elmo-message-entity-field
4164 (elmo-message-entity folder number) 'subject 'decode)
4166 (set-buffer mes-buf)
4167 (wl-draft-forward subject summary-buf)
4168 (unless without-setup-hook
4169 (run-hooks 'wl-mail-setup-hook)))))
4171 (defun wl-summary-click (e)
4176 (defun wl-summary-read ()
4177 "Proceed reading message in the summary buffer."
4179 (let ((cur-buf (current-buffer)))
4180 (wl-summary-toggle-disp-msg 'on)
4181 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
4182 (set-buffer cur-buf)
4183 (if (wl-message-next-page)
4184 (wl-summary-down t)))))
4186 (defsubst wl-summary-cursor-move-surface (downward interactive)
4187 (if wl-summary-move-direction-toggle
4188 (setq wl-summary-move-direction-downward downward))
4189 (let ((start (point))
4190 (skip-tmark-regexp (wl-regexp-opt wl-summary-skip-mark-list))
4192 (column (current-column))
4193 goto-next next-entity finfo)
4196 (not (if downward (eobp) (bobp))))
4200 (setq skip (or (string-match skip-tmark-regexp
4201 (wl-summary-temp-mark))
4202 (not (and (wl-summary-message-number)
4203 (elmo-message-accessible-p
4204 wl-summary-buffer-elmo-folder
4205 (wl-summary-message-number)))))))
4206 (if (if downward (eobp) (and (bobp) skip)) (setq goto-next t))
4207 (if (or (eobp) (and (bobp) skip))
4209 (move-to-column column)
4212 (if wl-summary-buffer-disp-msg
4213 (wl-summary-redisplay))
4216 ((and (not downward) wl-summary-buffer-prev-folder-function)
4217 (funcall wl-summary-buffer-prev-folder-function))
4218 ((and downward wl-summary-buffer-next-folder-function)
4219 (funcall wl-summary-buffer-next-folder-function))
4221 (when wl-auto-select-next
4224 (wl-summary-get-next-folder)
4225 (wl-summary-get-prev-folder)))
4227 (setq finfo (wl-folder-get-entity-info next-entity))))
4229 '(lambda () (wl-summary-next-folder-or-exit next-entity))
4231 "No more messages. Type SPC to go to %s."
4232 (wl-summary-entity-info-msg next-entity finfo)))))))))
4234 (defun wl-summary-prev (&optional interactive)
4236 (wl-summary-cursor-move-surface nil (or interactive (interactive-p))))
4238 (defun wl-summary-next (&optional interactive)
4240 (wl-summary-cursor-move-surface t (or interactive (interactive-p))))
4242 (defun wl-summary-up (&optional interactive skip-no-unread)
4245 (if wl-summary-move-direction-toggle
4246 (setq wl-summary-move-direction-downward nil))
4247 (if (wl-summary-cursor-up)
4248 (if wl-summary-buffer-disp-msg
4249 (wl-summary-redisplay))
4252 (if wl-summary-buffer-prev-folder-function
4253 (funcall wl-summary-buffer-prev-folder-function)
4254 (let (next-entity finfo)
4255 (when wl-auto-select-next
4257 (setq next-entity (wl-summary-get-prev-unread-folder))
4259 (setq finfo (wl-folder-get-entity-info next-entity)))))
4260 (if (and skip-no-unread
4261 (eq wl-auto-select-next 'skip-no-unread))
4262 (wl-summary-next-folder-or-exit next-entity t)
4264 '(lambda () (wl-summary-next-folder-or-exit next-entity t))
4266 "No more unread messages. Type SPC to go to %s."
4267 (wl-summary-entity-info-msg next-entity finfo)))))))))
4269 (defun wl-summary-get-prev-folder ()
4270 (let ((folder-buf (get-buffer wl-folder-buffer-name))
4273 (setq cur-id (save-excursion (set-buffer folder-buf)
4274 wl-folder-buffer-cur-entity-id))
4275 (wl-folder-get-prev-folder cur-id))))
4277 (defun wl-summary-get-next-folder ()
4278 (let ((folder-buf (get-buffer wl-folder-buffer-name))
4281 (setq cur-id (save-excursion (set-buffer folder-buf)
4282 wl-folder-buffer-cur-entity-id))
4283 (wl-folder-get-next-folder cur-id))))
4285 (defun wl-summary-get-next-unread-folder ()
4286 (let ((folder-buf (get-buffer wl-folder-buffer-name))
4289 (setq cur-id (save-excursion (set-buffer folder-buf)
4290 wl-folder-buffer-cur-entity-id))
4291 (wl-folder-get-next-folder cur-id 'unread))))
4293 (defun wl-summary-get-prev-unread-folder ()
4294 (let ((folder-buf (get-buffer wl-folder-buffer-name))
4297 (setq cur-id (save-excursion (set-buffer folder-buf)
4298 wl-folder-buffer-cur-entity-id))
4299 (wl-folder-get-prev-folder cur-id 'unread))))
4301 (defun wl-summary-down (&optional interactive skip-no-unread)
4303 (if wl-summary-move-direction-toggle
4304 (setq wl-summary-move-direction-downward t))
4305 (if (wl-summary-cursor-down)
4306 (if wl-summary-buffer-disp-msg
4307 (wl-summary-redisplay))
4310 (if wl-summary-buffer-next-folder-function
4311 (funcall wl-summary-buffer-next-folder-function)
4312 (let (next-entity finfo)
4313 (when wl-auto-select-next
4314 (setq next-entity (wl-summary-get-next-unread-folder)))
4316 (setq finfo (wl-folder-get-entity-info next-entity)))
4317 (if (and skip-no-unread
4318 (eq wl-auto-select-next 'skip-no-unread))
4319 (wl-summary-next-folder-or-exit next-entity)
4321 '(lambda () (wl-summary-next-folder-or-exit next-entity))
4323 "No more unread messages. Type SPC to go to %s."
4324 (wl-summary-entity-info-msg next-entity finfo)))))))))
4326 (defun wl-summary-goto-last-displayed-msg ()
4328 (unless wl-summary-buffer-last-displayed-msg
4329 (setq wl-summary-buffer-last-displayed-msg
4330 wl-summary-buffer-current-msg))
4331 (if wl-summary-buffer-last-displayed-msg
4333 (wl-summary-jump-to-msg wl-summary-buffer-last-displayed-msg)
4334 (if wl-summary-buffer-disp-msg
4335 (wl-summary-redisplay)))
4336 (message "No last message.")))
4338 (defun wl-summary-redisplay (&optional arg)
4341 (wl-summary-no-mime-p wl-summary-buffer-elmo-folder))
4342 (wl-summary-redisplay-no-mime)
4343 (wl-summary-redisplay-internal nil nil arg)))
4345 (defsubst wl-summary-redisplay-internal (&optional folder number force-reload)
4347 (let* ((folder (or folder wl-summary-buffer-elmo-folder))
4348 (num (or number (wl-summary-message-number)))
4349 (wl-mime-charset wl-summary-buffer-mime-charset)
4350 (default-mime-charset wl-summary-buffer-mime-charset)
4351 no-folder-mark fld-buf fld-win thr-entity)
4352 (if (and wl-thread-open-reading-thread
4353 (eq wl-summary-buffer-view 'thread)
4354 (not (wl-thread-entity-get-opened
4355 (setq thr-entity (wl-thread-get-entity
4357 (wl-thread-entity-get-children thr-entity))
4358 (wl-thread-force-open))
4361 (setq wl-summary-buffer-disp-msg t)
4362 (setq wl-summary-buffer-last-displayed-msg
4363 wl-summary-buffer-current-msg)
4364 ;; hide folder window
4365 (if (and (not wl-stay-folder-window)
4366 (setq fld-buf (get-buffer wl-folder-buffer-name)))
4367 (if (setq fld-win (get-buffer-window fld-buf))
4368 (delete-window fld-win)))
4369 (setq wl-current-summary-buffer (current-buffer))
4370 (setq no-folder-mark
4371 ;; If cache is used, change folder-mark.
4372 (if (wl-message-redisplay folder num
4376 (string= (elmo-folder-name-internal
4380 ;; plugged, then leave folder-mark.
4381 (if (and (not (elmo-folder-local-p
4382 wl-summary-buffer-elmo-folder))
4383 (elmo-folder-plugged-p
4384 wl-summary-buffer-elmo-folder))
4386 (when (elmo-message-use-cache-p folder num)
4387 (elmo-message-set-cached folder num t))
4389 (if (elmo-message-flagged-p wl-summary-buffer-elmo-folder
4392 (wl-summary-mark-as-read num no-folder-mark)
4393 (wl-summary-update-persistent-mark)))
4394 (setq wl-summary-buffer-current-msg num)
4395 (when wl-summary-recenter
4396 (recenter (/ (- (window-height) 2) 2))
4397 (if (not wl-summary-indent-length-limit)
4398 (wl-horizontal-recenter)))
4399 (wl-highlight-summary-displaying)
4400 (wl-message-buffer-prefetch-next folder num
4401 wl-message-buffer-prefetch-depth
4403 wl-summary-buffer-mime-charset)
4404 (run-hooks 'wl-summary-redisplay-hook))
4405 (message "No message to display."))))
4407 (defun wl-summary-redisplay-no-mime (&optional ask-coding)
4408 "Display message without MIME decoding.
4409 If ASK-CODING is non-nil, coding-system for the message is asked."
4411 (let ((elmo-mime-display-as-is-coding-system
4413 (or (read-coding-system "Coding system: ")
4414 elmo-mime-display-as-is-coding-system)
4415 elmo-mime-display-as-is-coding-system)))
4416 (wl-summary-redisplay-no-mime-internal)))
4418 (defun wl-summary-redisplay-no-mime-internal (&optional folder number)
4419 (let* ((fld (or folder wl-summary-buffer-elmo-folder))
4420 (num (or number (wl-summary-message-number)))
4424 (setq wl-summary-buffer-disp-msg t)
4425 (setq wl-summary-buffer-last-displayed-msg
4426 wl-summary-buffer-current-msg)
4427 (setq wl-current-summary-buffer (current-buffer))
4428 (wl-message-redisplay fld num 'as-is
4429 (string= (elmo-folder-name-internal fld)
4431 (when (elmo-message-use-cache-p fld num)
4432 (elmo-message-set-cached fld num t))
4434 (if (elmo-message-flagged-p fld num 'unread)
4435 (wl-summary-mark-as-read num); no-folder-mark)
4436 (wl-summary-update-persistent-mark)))
4437 (setq wl-summary-buffer-current-msg num)
4438 (when wl-summary-recenter
4439 (recenter (/ (- (window-height) 2) 2))
4440 (if (not wl-summary-indent-length-limit)
4441 (wl-horizontal-recenter)))
4442 (wl-highlight-summary-displaying)
4443 (run-hooks 'wl-summary-redisplay-hook))
4444 (message "No message to display.")
4445 (wl-ask-folder 'wl-summary-exit
4446 "No more messages. Type SPC to go to folder mode."))))
4448 (defun wl-summary-redisplay-all-header (&optional folder number)
4450 (let* ((fld (or folder wl-summary-buffer-elmo-folder))
4451 (num (or number (wl-summary-message-number)))
4452 (wl-mime-charset wl-summary-buffer-mime-charset)
4453 (default-mime-charset wl-summary-buffer-mime-charset))
4456 (setq wl-summary-buffer-disp-msg t)
4457 (setq wl-summary-buffer-last-displayed-msg
4458 wl-summary-buffer-current-msg)
4459 (setq wl-current-summary-buffer (current-buffer))
4460 (when (elmo-message-use-cache-p fld num)
4461 (elmo-message-set-cached fld num t))
4462 (if (wl-message-redisplay fld num 'all-header
4463 (string= (elmo-folder-name-internal fld)
4465 (wl-summary-mark-as-read num))
4466 (setq wl-summary-buffer-current-msg num)
4467 (when wl-summary-recenter
4468 (recenter (/ (- (window-height) 2) 2))
4469 (if (not wl-summary-indent-length-limit)
4470 (wl-horizontal-recenter)))
4471 (wl-highlight-summary-displaying)
4472 (run-hooks 'wl-summary-redisplay-hook))
4473 (message "No message to display."))))
4475 (defun wl-summary-jump-to-current-message ()
4476 "Jump into Message buffer."
4478 (let (message-buf message-win)
4479 (if (setq message-buf wl-message-buffer)
4480 (if (setq message-win (get-buffer-window message-buf))
4481 (select-window message-win)
4482 (wl-message-select-buffer wl-message-buffer))
4483 (wl-summary-redisplay)
4484 (wl-message-select-buffer wl-message-buffer))))
4486 (defun wl-summary-cancel-message ()
4487 "Cancel an article on news."
4489 (if (null (wl-summary-message-number))
4490 (message "No message.")
4491 (let ((summary-buf (current-buffer))
4493 (wl-summary-set-message-buffer-or-redisplay)
4494 (if (setq message-buf (wl-message-get-original-buffer))
4495 (set-buffer message-buf))
4496 (unless (wl-message-news-p)
4497 (set-buffer summary-buf)
4498 (if (and (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
4500 (y-or-n-p "Cannot get Newsgroups. Fetch again? "))
4502 (wl-summary-redisplay t)
4503 (wl-summary-supersedes-message))
4504 (error "This is not a news article; supersedes is impossible")))
4505 (when (yes-or-no-p "Do you really want to cancel this article? ")
4506 (let (from newsgroups message-id distribution buf)
4508 (setq from (std11-field-body "from")
4509 newsgroups (std11-field-body "newsgroups")
4510 message-id (std11-field-body "message-id")
4511 distribution (std11-field-body "distribution"))
4512 ;; Make sure that this article was written by the user.
4513 (unless (wl-address-user-mail-address-p
4514 (wl-address-header-extract-address
4515 (car (wl-parse-addresses from))))
4516 (error "This article is not yours"))
4517 ;; Make control message.
4518 (setq buf (set-buffer (get-buffer-create " *message cancel*")))
4519 (setq wl-draft-buffer-cur-summary-buffer summary-buf)
4520 (buffer-disable-undo (current-buffer))
4522 (insert "Newsgroups: " newsgroups "\n"
4523 "From: " (wl-address-header-extract-address
4525 "Subject: cmsg cancel " message-id "\n"
4526 "Control: cancel " message-id "\n"
4528 (concat "Distribution: " distribution "\n")
4530 mail-header-separator "\n"
4531 wl-summary-cancel-message)
4532 (message "Canceling your message...")
4533 (wl-draft-raw-send t t) ; kill when done, force-pre-hooks.
4534 (message "Canceling your message...done")))))))
4536 (defun wl-summary-supersedes-message ()
4537 "Supersede current message."
4539 (wl-summary-toggle-disp-msg 'off)
4540 (let ((summary-buf (current-buffer))
4542 (wl-summary-set-message-buffer-or-redisplay)
4543 (if (setq message-buf (wl-message-get-original-buffer))
4544 (set-buffer message-buf))
4545 (unless (wl-message-news-p)
4546 (set-buffer summary-buf)
4547 (if (and (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
4549 (y-or-n-p "Cannot get Newsgroups. Fetch again? "))
4551 (wl-summary-redisplay t)
4552 (wl-summary-supersedes-message))
4553 (error "This is not a news article; supersedes is impossible")))
4555 (setq from (std11-field-body "from"))
4556 ;; Make sure that this article was written by the user.
4557 (unless (wl-address-user-mail-address-p
4558 (wl-address-header-extract-address
4559 (car (wl-parse-addresses from))))
4560 (error "This article is not yours"))
4561 (let* ((message-id (std11-field-body "message-id"))
4562 (followup-to (std11-field-body "followup-to"))
4563 (mail-default-headers
4564 (concat mail-default-headers
4565 "Supersedes: " message-id "\n"
4567 (concat "Followup-To: " followup-to "\n")))))
4568 (if message-buf (set-buffer message-buf))
4569 (wl-draft-edit-string (buffer-substring (point-min) (point-max)))))))
4571 (defun wl-summary-save (&optional arg wl-save-dir)
4572 "Save current message to disk."
4575 (num (wl-summary-message-number)))
4576 (if (null wl-save-dir)
4577 (setq wl-save-dir wl-temporary-file-directory))
4580 (setq filename (expand-file-name
4581 (concat (int-to-string num)
4582 wl-summary-save-file-suffix)
4585 (null (file-exists-p filename))))
4587 (read-file-name "Save to file: " filename)))
4589 (wl-summary-set-message-buffer-or-redisplay)
4590 (set-buffer (wl-message-get-original-buffer))
4591 (if (and (null arg) (file-exists-p filename))
4592 (if (y-or-n-p "File already exists. override it? ")
4593 (write-region (point-min) (point-max) filename))
4594 (write-region (point-min) (point-max) filename)))
4595 (message "No message to save."))
4598 (defun wl-summary-save-region (beg end)
4602 (wl-summary-narrow-to-region beg end)
4603 (goto-char (point-min))
4605 (wl-read-directory-name "Save to directory: "
4606 wl-temporary-file-directory)))
4607 (if (null (file-exists-p wl-save-dir))
4608 (make-directory wl-save-dir))
4609 (if (eq wl-summary-buffer-view 'thread)
4612 (let* ((number (wl-summary-message-number))
4613 (entity (wl-thread-get-entity number)))
4614 (if (wl-thread-entity-get-opened entity)
4615 (wl-summary-save t wl-save-dir)
4617 (wl-summary-save t wl-save-dir))
4620 (wl-summary-save t wl-save-dir)
4621 (forward-line 1)))))))
4623 ;; mew-summary-pipe-message()
4624 (defun wl-summary-pipe-message (prefix command)
4625 "Send this message via pipe."
4626 (interactive (list current-prefix-arg nil))
4627 (if (null (wl-summary-message-number))
4628 (message "No message.")
4629 (setq command (read-string "Shell command on message: "
4630 wl-summary-shell-command-last))
4631 (if (y-or-n-p "Send this message to pipe? ")
4632 (wl-summary-pipe-message-subr prefix command))))
4634 (defun wl-summary-target-mark-pipe (prefix command)
4635 "Send each marked messages via pipe."
4636 (interactive (list current-prefix-arg nil))
4637 (if (null wl-summary-buffer-target-mark-list)
4638 (message "No marked message.")
4639 (setq command (read-string "Shell command on each marked message: "
4640 wl-summary-shell-command-last))
4641 (when (y-or-n-p "Send each marked message to pipe? ")
4642 (while (car wl-summary-buffer-target-mark-list)
4643 (let ((num (car wl-summary-buffer-target-mark-list)))
4644 (wl-thread-jump-to-msg num)
4645 (wl-summary-pipe-message-subr prefix command)
4646 (wl-summary-unmark))))))
4648 (defun wl-summary-pipe-message-subr (prefix command)
4650 (wl-summary-set-message-buffer-or-redisplay)
4651 (set-buffer (wl-message-get-original-buffer))
4652 (if (string= command "")
4653 (setq command wl-summary-shell-command-last))
4654 (goto-char (point-min)) ; perhaps this line won't be necessary
4656 (search-forward "\n\n"))
4657 (shell-command-on-region (point) (point-max) command nil)
4658 (setq wl-summary-shell-command-last command)))
4660 (defun wl-summary-print-message (&optional arg)
4662 (if (null (wl-summary-message-number))
4663 (message "No message.")
4665 (wl-summary-set-message-buffer-or-redisplay)
4666 (if (or (not (interactive-p))
4667 (y-or-n-p "Print ok? "))
4669 (let ((buffer (generate-new-buffer " *print*")))
4670 (copy-to-buffer buffer (point-min) (point-max))
4672 (funcall wl-print-buffer-function)
4673 (kill-buffer buffer)))
4676 (defun wl-summary-print-message-with-ps-print (&optional filename)
4677 "Print message via ps-print."
4679 (if (null (wl-summary-message-number))
4680 (message "No message.")
4681 (setq filename (ps-print-preprint current-prefix-arg))
4682 (if (or (not (interactive-p))
4683 (y-or-n-p "Print ok? "))
4684 (let ((summary-buffer (current-buffer))
4687 (wl-summary-set-message-buffer-or-redisplay)
4688 ;; (wl-summary-redisplay-internal)
4689 (let* ((buffer (generate-new-buffer " *print*"))
4691 (set-buffer summary-buffer)
4692 (elmo-message-entity
4693 wl-summary-buffer-elmo-folder
4694 (wl-summary-message-number))))
4697 (or (elmo-message-entity-field entity 'subject t)
4701 (or (elmo-message-entity-field entity 'from t) "")))
4704 (or (elmo-message-entity-field entity 'date) ""))))
4705 (run-hooks 'wl-ps-preprint-hook)
4706 (set-buffer wl-message-buffer)
4707 (copy-to-buffer buffer (point-min) (point-max))
4710 (let ((ps-left-header
4711 (list (concat "(" wl-ps-subject ")")
4712 (concat "(" wl-ps-from ")")))
4714 (list "/pagenumberstring load"
4715 (concat "(" wl-ps-date ")"))))
4716 (run-hooks 'wl-ps-print-hook)
4717 (funcall wl-ps-print-buffer-function filename))
4718 (kill-buffer buffer)))))
4721 (if (featurep 'ps-print) ; ps-print is available.
4722 (fset 'wl-summary-print-message 'wl-summary-print-message-with-ps-print))
4724 (defun wl-summary-target-mark-print ()
4726 (if (null wl-summary-buffer-target-mark-list)
4727 (message "No marked message.")
4728 (when (y-or-n-p "Print all marked messages. OK? ")
4729 (while (car wl-summary-buffer-target-mark-list)
4730 (let ((num (car wl-summary-buffer-target-mark-list)))
4731 (wl-thread-jump-to-msg num)
4732 (wl-summary-print-message)
4733 (wl-summary-unmark))))))
4735 (defun wl-summary-folder-info-update ()
4736 (wl-folder-set-folder-updated
4737 (elmo-string (wl-summary-buffer-folder-name))
4739 (+ wl-summary-buffer-unread-count
4740 wl-summary-buffer-new-count)
4742 wl-summary-buffer-elmo-folder))))
4744 (defun wl-summary-get-original-buffer ()
4745 "Get original buffer for the current summary."
4747 (wl-summary-set-message-buffer-or-redisplay)
4748 (wl-message-get-original-buffer)))
4750 (defun wl-summary-pack-number (&optional arg)
4752 (elmo-folder-pack-numbers wl-summary-buffer-elmo-folder)
4753 (let (wl-use-scoring)
4754 (wl-summary-rescan nil nil t)))
4756 (defun wl-summary-target-mark-uudecode ()
4758 (let ((mlist (reverse wl-summary-buffer-target-mark-list))
4759 (summary-buf (current-buffer))
4760 (tmp-buf (get-buffer-create "*WL UUENCODE*"))
4761 orig-buf i k filename rc errmsg)
4763 (setq k (length mlist))
4764 (set-buffer tmp-buf)
4766 (save-window-excursion
4768 (set-buffer summary-buf)
4769 (wl-summary-jump-to-msg (car mlist))
4770 (wl-summary-redisplay)
4771 (set-buffer (setq orig-buf (wl-summary-get-original-buffer)))
4772 (goto-char (point-min))
4773 (cond ((= i 1) ; first
4774 (if (setq filename (wl-message-uu-substring
4778 (error "Can't find begin line")))
4780 (wl-message-uu-substring orig-buf tmp-buf))
4782 (wl-message-uu-substring orig-buf tmp-buf nil t)))
4784 (setq mlist (cdr mlist)))
4785 (set-buffer tmp-buf)
4786 (message "Exec %s..." wl-prog-uudecode)
4788 (let ((decode-dir wl-temporary-file-directory))
4789 (if (not wl-prog-uudecode-no-stdout-option)
4790 (setq filename (read-file-name "Save to file: "
4792 (elmo-safe-filename filename)
4793 wl-temporary-file-directory)))
4795 (wl-read-directory-name "Save to directory: "
4796 wl-temporary-file-directory))
4797 (setq filename (expand-file-name filename decode-dir)))
4798 (if (file-exists-p filename)
4799 (or (yes-or-no-p (format "File %s exists. Save anyway? "
4802 (elmo-bind-directory
4806 (apply 'call-process-region (point-min) (point-max)
4807 wl-prog-uudecode t (current-buffer) nil
4808 wl-prog-uudecode-arg))))
4809 (when (not (= 0 rc))
4810 (setq errmsg (buffer-substring (point-min)(point-max)))
4811 (error "Uudecode error: %s" errmsg))
4812 (if (not wl-prog-uudecode-no-stdout-option)
4813 (let (file-name-handler-alist) ;; void jka-compr
4814 (as-binary-output-file
4815 (write-region (point-min) (point-max)
4816 filename nil 'no-msg))))
4818 (set-buffer summary-buf)
4819 (wl-summary-delete-all-temp-marks))
4820 (if (file-exists-p filename)
4821 (message "Saved as %s" filename)))
4822 (kill-buffer tmp-buf)))))
4825 ;; (defun wl-summary-drop-unsync ()
4826 ;; "Drop all unsync messages."
4828 ;; (if (elmo-folder-pipe-p (wl-summary-buffer-folder-name))
4829 ;; (error "You cannot drop unsync messages in this folder"))
4830 ;; (if (or (not (interactive-p))
4831 ;; (y-or-n-p "Drop all unsync messages? "))
4832 ;; (let* ((folder-list (elmo-folder-get-primitive-folder-list
4833 ;; (wl-summary-buffer-folder-name)))
4834 ;; (is-multi (elmo-multi-p (wl-summary-buffer-folder-name)))
4838 ;; (message "Dropping...")
4839 ;; (while folder-list
4840 ;; (setq pair (elmo-folder-message-numbers (car folder-list)))
4841 ;; (when is-multi ;; dirty hack...
4843 ;; (setcar pair (+ (* multi-num elmo-multi-divide-number)
4845 ;; (elmo-msgdb-set-number-alist
4846 ;; (wl-summary-buffer-msgdb)
4848 ;; (elmo-msgdb-get-number-alist (wl-summary-buffer-msgdb))
4849 ;; (list (cons (car pair) nil))))
4850 ;; (setq sum (+ sum (cdr pair)))
4851 ;; (setq folder-list (cdr folder-list)))
4852 ;; (wl-summary-set-message-modified)
4853 ;; (wl-folder-set-folder-updated (wl-summary-buffer-folder-name)
4855 ;; (+ wl-summary-buffer-unread-count
4856 ;; wl-summary-buffer-new-count)
4858 ;; (message "Dropping...done"))))
4860 (defun wl-summary-default-get-next-msg (msg)
4861 (or (wl-summary-next-message msg
4862 (if wl-summary-move-direction-downward 'down
4865 (cadr (memq msg (if wl-summary-move-direction-downward
4866 wl-summary-buffer-number-list
4867 (reverse wl-summary-buffer-number-list))))))
4869 (defun wl-summary-save-current-message ()
4870 "Save current message for `wl-summary-yank-saved-message'."
4872 (let ((number (wl-summary-message-number)))
4873 (setq wl-summary-buffer-saved-message number)
4874 (and number (message "No: %s is saved." number))))
4876 (defun wl-summary-yank-saved-message ()
4877 "Set current message as a parent of the saved message."
4879 (if wl-summary-buffer-saved-message
4880 (let ((number (wl-summary-message-number)))
4881 (if (eq wl-summary-buffer-saved-message number)
4882 (message "Cannot set itself as a parent.")
4884 (wl-thread-jump-to-msg wl-summary-buffer-saved-message)
4885 (wl-thread-set-parent number)
4886 (wl-summary-set-thread-modified))
4887 (setq wl-summary-buffer-saved-message nil)))
4888 (message "There's no saved message.")))
4890 (defun wl-summary-toggle-header-narrowing ()
4891 "Toggle message header narrowing."
4893 (when wl-message-use-header-narrowing
4894 (save-selected-window
4895 (let* ((mbuf wl-message-buffer)
4896 (mwin (when mbuf (get-buffer-window mbuf)))
4897 (wpos (when mwin (window-start mwin))))
4900 (wl-message-header-narrowing-toggle)
4901 (and wpos (set-window-start mwin wpos)))))))
4903 (autoload 'elmo-folder-list-global-flag-messages "elmo-flag")
4906 (product-provide (provide 'wl-summary) (require 'wl-version))
4908 ;;; wl-summary.el ends here