1 ;;; wl-summary.el --- Summary mode for Wanderlust.
3 ;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
4 ;; Copyright (C) 1998,1999,2000 Masahiro MURATA <muse@ba2.so-net.ne.jp>
5 ;; Copyright (C) 1999,2000 TSUMURA Tomoaki <tsumura@kuis.kyoto-u.ac.jp>
6 ;; Copyright (C) 1999,2000 Kenichi OKADA <okada@opaopa.org>
8 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
9 ;; Masahiro MURATA <muse@ba2.so-net.ne.jp>
10 ;; TSUMURA Tomoaki <tsumura@kuis.kyoto-u.ac.jp>
11 ;; Kenichi OKADA <okada@opaopa.org>
12 ;; Keywords: mail, net news
14 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
16 ;; This program is free software; you can redistribute it and/or modify
17 ;; it under the terms of the GNU General Public License as published by
18 ;; the Free Software Foundation; either version 2, or (at your option)
21 ;; This program is distributed in the hope that it will be useful,
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;; GNU General Public License for more details.
26 ;; You should have received a copy of the GNU General Public License
27 ;; along with GNU Emacs; see the file COPYING. If not, write to the
28 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
29 ;; Boston, MA 02111-1307, USA.
42 (require 'wl-highlight)
45 (condition-case nil (require 'timezone) (error nil))
46 (condition-case nil (require 'easymenu) (error nil))
48 (condition-case nil (require 'ps-print) (error nil))
52 (condition-case () (require 'timer) (error nil))
53 (defalias-maybe 'ps-print-buffer-with-faces 'ignore)
54 (defalias-maybe 'elmo-database-msgid-put 'ignore)
55 (defalias-maybe 'elmo-database-close 'ignore)
56 (defalias-maybe 'elmo-database-msgid-get 'ignore)
57 (defalias-maybe 'run-with-idle-timer 'ignore)
58 (defalias-maybe 'ps-print-preprint 'ignore))
60 (defvar dragdrop-drop-functions)
61 (defvar scrollbar-height)
62 (defvar mail-reply-buffer)
64 (defvar wl-summary-buffer-name "Summary")
65 (defvar wl-summary-mode-map nil)
66 (defvar wl-current-summary-buffer nil)
68 (defvar wl-summary-buffer-elmo-folder nil)
70 (defmacro wl-summary-buffer-folder-name ()
71 (` (and wl-summary-buffer-elmo-folder
72 (elmo-folder-name-internal wl-summary-buffer-elmo-folder))))
74 (defvar wl-summary-buffer-disp-msg nil)
75 (defvar wl-summary-buffer-disp-folder nil)
76 (defvar wl-summary-buffer-temp-mark-list nil)
77 (defvar wl-summary-buffer-last-displayed-msg nil)
78 (defvar wl-summary-buffer-current-msg nil)
79 (defvar wl-summary-buffer-unread-count 0)
80 (defvar wl-summary-buffer-new-count 0)
81 (defvar wl-summary-buffer-answered-count 0)
82 (defvar wl-summary-buffer-mime-charset nil)
83 (defvar wl-summary-buffer-weekday-name-lang nil)
84 (defvar wl-summary-buffer-thread-indent-set-alist nil)
85 (defvar wl-summary-buffer-view nil)
86 (defvar wl-summary-buffer-message-modified nil)
87 (defvar wl-summary-buffer-thread-modified nil)
89 (defvar wl-summary-buffer-number-column nil)
90 (defvar wl-summary-buffer-temp-mark-column nil)
91 (defvar wl-summary-buffer-persistent-mark-column nil)
93 (defvar wl-summary-buffer-unsync-mark-number-list nil)
95 (defvar wl-summary-buffer-persistent nil)
96 (defvar wl-summary-buffer-thread-nodes nil)
97 (defvar wl-summary-buffer-target-mark-list nil)
98 (defvar wl-summary-buffer-prev-refile-destination nil)
99 (defvar wl-summary-buffer-prev-copy-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))
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 Date" wl-summary-sort-by-date t]
283 ["By From" wl-summary-sort-by-from t]
284 ["By Subject" wl-summary-sort-by-subject t]
285 ["By List Info" wl-summary-sort-by-list-info t])
288 ["Mark as read" wl-summary-mark-as-read t]
289 ["Mark as important" wl-summary-mark-as-important t]
290 ["Mark as unread" wl-summary-mark-as-unread t]
291 ["Set dispose mark" wl-summary-dispose t]
292 ["Set refile mark" wl-summary-refile t]
293 ["Set copy mark" wl-summary-copy t]
294 ["Set resend mark" wl-summary-resend t]
295 ["Prefetch" wl-summary-prefetch t]
296 ["Set target mark" wl-summary-target-mark t]
297 ["Unmark" wl-summary-unmark t]
298 ["Save" wl-summary-save t]
299 ["Cancel posted news" wl-summary-cancel-message t]
300 ["Supersedes message" wl-summary-supersedes-message t]
301 ["Resend bounced mail" wl-summary-resend-bounced-mail t]
302 ["Enter the message" wl-summary-jump-to-current-message t]
303 ["Pipe message" wl-summary-pipe-message t]
304 ["Print message" wl-summary-print-message t])
306 ["Open or Close" wl-thread-open-close (eq wl-summary-buffer-view 'thread)]
307 ["Open all" wl-thread-open-all (eq wl-summary-buffer-view 'thread)]
308 ["Close all" wl-thread-close-all (eq wl-summary-buffer-view 'thread)]
309 ["Mark as read" wl-thread-mark-as-read (eq wl-summary-buffer-view 'thread)]
310 ["Mark as important" wl-thread-mark-as-important (eq wl-summary-buffer-view 'thread)]
311 ["Mark as unread" wl-thread-mark-as-unread (eq wl-summary-buffer-view 'thread)]
312 ["Set delete mark" wl-thread-delete (eq wl-summary-buffer-view 'thread)]
313 ["Set refile mark" wl-thread-refile (eq wl-summary-buffer-view 'thread)]
314 ["Set copy mark" wl-thread-copy (eq wl-summary-buffer-view 'thread)]
315 ["Prefetch" wl-thread-prefetch (eq wl-summary-buffer-view 'thread)]
316 ["Set target mark" wl-thread-target-mark (eq wl-summary-buffer-view 'thread)]
317 ["Unmark" wl-thread-unmark (eq wl-summary-buffer-view 'thread)]
318 ["Save" wl-thread-save (eq wl-summary-buffer-view 'thread)]
319 ["Execute" wl-thread-exec (eq wl-summary-buffer-view 'thread)])
321 ["Mark as read" wl-summary-mark-as-read-region t]
322 ["Mark as important" wl-summary-mark-as-important-region t]
323 ["Mark as unread" wl-summary-mark-as-unread-region t]
324 ["Set dispose mark" wl-summary-dispose-region t]
325 ["Set refile mark" wl-summary-refile-region t]
326 ["Set copy mark" wl-summary-copy-region t]
327 ["Prefetch" wl-summary-prefetch-region t]
328 ["Set target mark" wl-summary-target-mark-region t]
329 ["Unmark" wl-summary-unmark-region t]
330 ["Save" wl-summary-save-region t]
331 ["Execute" wl-summary-exec-region t])
333 ["Mark as read" wl-summary-target-mark-mark-as-read t]
334 ["Mark as important" wl-summary-target-mark-mark-as-important t]
335 ["Mark as unread" wl-summary-target-mark-mark-as-unread t]
336 ["Set delete mark" wl-summary-target-mark-delete t]
337 ["Set refile mark" wl-summary-target-mark-refile t]
338 ["Set copy mark" wl-summary-target-mark-copy t]
339 ["Prefetch" wl-summary-target-mark-prefetch t]
340 ["Save" wl-summary-target-mark-save t]
341 ["Reply with citation" wl-summary-target-mark-reply-with-citation t]
342 ["Forward" wl-summary-target-mark-forward t]
343 ["uudecode" wl-summary-target-mark-uudecode t])
345 ["Switch current score file" wl-score-change-score-file t]
346 ["Edit current score file" wl-score-edit-current-scores t]
347 ["Edit score file" wl-score-edit-file t]
348 ["Set mark below" wl-score-set-mark-below t]
349 ["Set expunge below" wl-score-set-expunge-below t]
350 ["Rescore buffer" wl-summary-rescore t]
351 ["Increase score" wl-summary-increase-score t]
352 ["Lower score" wl-summary-lower-score t])
355 ["Write a message" wl-summary-write t]
356 ["Write for current folder" wl-summary-write-current-folder t]
357 ["Reply" wl-summary-reply t]
358 ["Reply with citation" wl-summary-reply-with-citation t]
359 ["Forward" wl-summary-forward t])
361 ["Toggle Plug Status" wl-toggle-plugged t]
362 ["Change Plug Status" wl-plugged-change t]
364 ["Exit Current Folder" wl-summary-exit t]))
367 (defun wl-summary-setup-mouse ()
368 (define-key wl-summary-mode-map 'button4 'wl-summary-prev)
369 (define-key wl-summary-mode-map 'button5 'wl-summary-next)
370 (define-key wl-summary-mode-map [(shift button4)]
372 (define-key wl-summary-mode-map [(shift button5)]
374 (define-key wl-summary-mode-map 'button2 'wl-summary-click))
375 (defun wl-summary-setup-mouse ()
376 (define-key wl-summary-mode-map [mouse-4] 'wl-summary-prev)
377 (define-key wl-summary-mode-map [mouse-5] 'wl-summary-next)
378 (define-key wl-summary-mode-map [S-mouse-4] 'wl-summary-up)
379 (define-key wl-summary-mode-map [S-mouse-5] 'wl-summary-down)
380 (define-key wl-summary-mode-map [mouse-2] 'wl-summary-click)))
382 (if wl-summary-mode-map
384 (setq wl-summary-mode-map (make-sparse-keymap))
385 (define-key wl-summary-mode-map " " 'wl-summary-read)
386 (define-key wl-summary-mode-map "." 'wl-summary-redisplay)
387 (define-key wl-summary-mode-map "<" 'wl-summary-display-top)
388 (define-key wl-summary-mode-map ">" 'wl-summary-display-bottom)
389 (define-key wl-summary-mode-map "\177" 'wl-summary-prev-page)
390 (define-key wl-summary-mode-map [backspace] 'wl-summary-prev-page)
391 (define-key wl-summary-mode-map "\r" 'wl-summary-next-line-content)
392 (define-key wl-summary-mode-map "\C-m" 'wl-summary-next-line-content)
393 (define-key wl-summary-mode-map "/" 'wl-thread-open-close)
394 (define-key wl-summary-mode-map "[" 'wl-thread-open-all)
395 (define-key wl-summary-mode-map "]" 'wl-thread-close-all)
396 (define-key wl-summary-mode-map "-" 'wl-summary-prev-line-content)
397 (define-key wl-summary-mode-map "\e\r" 'wl-summary-prev-line-content)
398 (define-key wl-summary-mode-map "g" 'wl-summary-goto-folder)
399 (define-key wl-summary-mode-map "G" 'wl-summary-goto-folder-sticky)
400 (define-key wl-summary-mode-map "c" 'wl-summary-mark-as-read-all)
402 (define-key wl-summary-mode-map "a" 'wl-summary-reply)
403 (define-key wl-summary-mode-map "A" 'wl-summary-reply-with-citation)
404 (define-key wl-summary-mode-map "C" 'wl-summary-cancel-message)
405 (define-key wl-summary-mode-map "E" 'wl-summary-reedit)
406 (define-key wl-summary-mode-map "\eE" 'wl-summary-resend-bounced-mail)
407 (define-key wl-summary-mode-map "f" 'wl-summary-forward)
408 (define-key wl-summary-mode-map "$" 'wl-summary-mark-as-important)
409 (define-key wl-summary-mode-map "&" 'wl-summary-mark-as-answered)
410 (define-key wl-summary-mode-map "@" 'wl-summary-edit-addresses)
412 (define-key wl-summary-mode-map "y" 'wl-summary-save)
413 (define-key wl-summary-mode-map "n" 'wl-summary-next)
414 (define-key wl-summary-mode-map "p" 'wl-summary-prev)
415 (define-key wl-summary-mode-map "N" 'wl-summary-down)
416 (define-key wl-summary-mode-map "P" 'wl-summary-up)
417 (define-key wl-summary-mode-map "w" 'wl-summary-write)
418 (define-key wl-summary-mode-map "W" 'wl-summary-write-current-folder)
419 (define-key wl-summary-mode-map "e" 'wl-summary-save)
420 (define-key wl-summary-mode-map "\C-c\C-o" 'wl-jump-to-draft-buffer)
421 (define-key wl-summary-mode-map "\C-c\C-a" 'wl-addrmgr)
422 (define-key wl-summary-mode-map "\C-c\C-p" 'wl-summary-previous-buffer)
423 (define-key wl-summary-mode-map "\C-c\C-n" 'wl-summary-next-buffer)
424 (define-key wl-summary-mode-map "H" 'wl-summary-redisplay-all-header)
425 (define-key wl-summary-mode-map "M" 'wl-summary-redisplay-no-mime)
426 (define-key wl-summary-mode-map "B" 'wl-summary-burst)
427 (define-key wl-summary-mode-map "Z" 'wl-status-update)
428 (define-key wl-summary-mode-map "#" 'wl-summary-print-message)
429 (define-key wl-summary-mode-map "|" 'wl-summary-pipe-message)
430 (define-key wl-summary-mode-map "z" 'wl-summary-suspend)
431 (define-key wl-summary-mode-map "q" 'wl-summary-exit)
432 (define-key wl-summary-mode-map "Q" 'wl-summary-force-exit)
434 (define-key wl-summary-mode-map "j" 'wl-summary-jump-to-current-message)
435 (define-key wl-summary-mode-map "J" 'wl-thread-jump-to-msg)
436 (define-key wl-summary-mode-map "I" 'wl-summary-incorporate)
437 (define-key wl-summary-mode-map "\M-j" 'wl-summary-jump-to-msg-by-message-id)
438 (define-key wl-summary-mode-map "^" 'wl-summary-jump-to-parent-message)
439 (define-key wl-summary-mode-map "!" 'wl-summary-mark-as-unread)
441 (define-key wl-summary-mode-map "s" 'wl-summary-sync)
442 (define-key wl-summary-mode-map "S" 'wl-summary-sort)
443 (define-key wl-summary-mode-map "\M-s" 'wl-summary-stick)
444 (define-key wl-summary-mode-map "T" 'wl-summary-toggle-thread)
446 (define-key wl-summary-mode-map "l" 'wl-summary-toggle-disp-folder)
447 (define-key wl-summary-mode-map "v" 'wl-summary-toggle-disp-msg)
448 (define-key wl-summary-mode-map "V" 'wl-summary-virtual)
450 (define-key wl-summary-mode-map "\C-i" 'wl-summary-goto-last-displayed-msg)
451 (define-key wl-summary-mode-map "?" 'wl-summary-pick)
452 (define-key wl-summary-mode-map "\ee" 'wl-summary-expire)
455 (define-key wl-summary-mode-map "\ew" 'wl-summary-save-current-message)
456 (define-key wl-summary-mode-map "\C-y" 'wl-summary-yank-saved-message)
459 (define-key wl-summary-mode-map "R" 'wl-summary-mark-as-read)
460 (define-key wl-summary-mode-map "i" 'wl-summary-prefetch)
461 (define-key wl-summary-mode-map "x" 'wl-summary-exec)
462 (define-key wl-summary-mode-map "*" 'wl-summary-target-mark)
463 (define-key wl-summary-mode-map "o" 'wl-summary-refile)
464 (define-key wl-summary-mode-map "O" 'wl-summary-copy)
465 (define-key wl-summary-mode-map "\M-o" 'wl-summary-refile-prev-destination)
466 (define-key wl-summary-mode-map "\C-o" 'wl-summary-auto-refile)
467 (define-key wl-summary-mode-map "d" 'wl-summary-dispose)
468 (define-key wl-summary-mode-map "u" 'wl-summary-unmark)
469 (define-key wl-summary-mode-map "U" 'wl-summary-unmark-all)
470 (define-key wl-summary-mode-map "D" 'wl-summary-delete)
471 (define-key wl-summary-mode-map "~" 'wl-summary-resend)
474 (define-key wl-summary-mode-map "t" (make-sparse-keymap))
475 (define-key wl-summary-mode-map "tR" 'wl-thread-mark-as-read)
476 (define-key wl-summary-mode-map "ti" 'wl-thread-prefetch)
477 (define-key wl-summary-mode-map "tx" 'wl-thread-exec)
478 (define-key wl-summary-mode-map "t*" 'wl-thread-target-mark)
479 (define-key wl-summary-mode-map "to" 'wl-thread-refile)
480 (define-key wl-summary-mode-map "tO" 'wl-thread-copy)
481 (define-key wl-summary-mode-map "td" 'wl-thread-dispose)
482 (define-key wl-summary-mode-map "tD" 'wl-thread-delete)
483 (define-key wl-summary-mode-map "t~" 'wl-thread-resend)
484 (define-key wl-summary-mode-map "tu" 'wl-thread-unmark)
485 (define-key wl-summary-mode-map "t!" 'wl-thread-mark-as-unread)
486 (define-key wl-summary-mode-map "t$" 'wl-thread-mark-as-important)
487 (define-key wl-summary-mode-map "ty" 'wl-thread-save)
488 (define-key wl-summary-mode-map "ts" 'wl-thread-set-parent)
490 ;; target-mark commands
491 (define-key wl-summary-mode-map "m" (make-sparse-keymap))
492 (define-key wl-summary-mode-map "mi" 'wl-summary-target-mark-prefetch)
493 (define-key wl-summary-mode-map "mo" 'wl-summary-target-mark-refile)
494 (define-key wl-summary-mode-map "mO" 'wl-summary-target-mark-copy)
495 (define-key wl-summary-mode-map "md" 'wl-summary-target-mark-dispose)
496 (define-key wl-summary-mode-map "mD" 'wl-summary-target-mark-delete)
497 (define-key wl-summary-mode-map "m~" 'wl-summary-target-mark-resend)
499 (define-key wl-summary-mode-map "mu" 'wl-summary-delete-all-temp-marks)
501 (define-key wl-summary-mode-map "my" 'wl-summary-target-mark-save)
502 (define-key wl-summary-mode-map "mR" 'wl-summary-target-mark-mark-as-read)
503 (define-key wl-summary-mode-map "m!" 'wl-summary-target-mark-mark-as-unread)
504 (define-key wl-summary-mode-map "m$" 'wl-summary-target-mark-mark-as-important)
505 (define-key wl-summary-mode-map "mU" 'wl-summary-target-mark-uudecode)
506 (define-key wl-summary-mode-map "ma" 'wl-summary-target-mark-all)
507 (define-key wl-summary-mode-map "mt" 'wl-summary-target-mark-thread)
508 (define-key wl-summary-mode-map "mA" 'wl-summary-target-mark-reply-with-citation)
509 (define-key wl-summary-mode-map "mf" 'wl-summary-target-mark-forward)
510 (define-key wl-summary-mode-map "m?" 'wl-summary-target-mark-pick)
511 (define-key wl-summary-mode-map "m#" 'wl-summary-target-mark-print)
512 (define-key wl-summary-mode-map "m|" 'wl-summary-target-mark-pipe)
515 (define-key wl-summary-mode-map "r" (make-sparse-keymap))
516 (define-key wl-summary-mode-map "rR" 'wl-summary-mark-as-read-region)
517 (define-key wl-summary-mode-map "ri" 'wl-summary-prefetch-region)
518 (define-key wl-summary-mode-map "rx" 'wl-summary-exec-region)
519 (define-key wl-summary-mode-map "mr" 'wl-summary-target-mark-region)
520 (define-key wl-summary-mode-map "r*" 'wl-summary-target-mark-region)
521 (define-key wl-summary-mode-map "ro" 'wl-summary-refile-region)
522 (define-key wl-summary-mode-map "rO" 'wl-summary-copy-region)
523 (define-key wl-summary-mode-map "rd" 'wl-summary-dispose-region)
524 (define-key wl-summary-mode-map "rD" 'wl-summary-delete-region)
525 (define-key wl-summary-mode-map "r~" 'wl-summary-resend-region)
526 (define-key wl-summary-mode-map "ru" 'wl-summary-unmark-region)
527 (define-key wl-summary-mode-map "r!" 'wl-summary-mark-as-unread-region)
528 (define-key wl-summary-mode-map "r$" 'wl-summary-mark-as-important-region)
529 (define-key wl-summary-mode-map "ry" 'wl-summary-save-region)
532 (define-key wl-summary-mode-map "K" 'wl-summary-increase-score)
533 (define-key wl-summary-mode-map "L" 'wl-summary-lower-score)
534 (define-key wl-summary-mode-map "h" (make-sparse-keymap))
535 (define-key wl-summary-mode-map "hR" 'wl-summary-rescore)
536 (define-key wl-summary-mode-map "hc" 'wl-score-change-score-file)
537 (define-key wl-summary-mode-map "he" 'wl-score-edit-current-scores)
538 (define-key wl-summary-mode-map "hf" 'wl-score-edit-file)
539 (define-key wl-summary-mode-map "hF" 'wl-score-flush-cache)
540 (define-key wl-summary-mode-map "hm" 'wl-score-set-mark-below)
541 (define-key wl-summary-mode-map "hx" 'wl-score-set-expunge-below)
544 (define-key wl-summary-mode-map "\C-c\C-f" 'wl-summary-toggle-header-narrowing)
545 (define-key wl-summary-mode-map "\M-t" 'wl-toggle-plugged)
546 (define-key wl-summary-mode-map "\C-t" 'wl-plugged-change)
548 (define-key wl-summary-mode-map "\C-x\C-s" 'wl-summary-save-status)
549 (wl-summary-setup-mouse)
553 "Menu used in Summary mode."
554 wl-summary-mode-menu-spec))
556 (defsubst wl-summary-message-visible-p (number)
557 "Return non-nil if the message with NUMBER is visible."
558 (or (eq wl-summary-buffer-view 'sequence)
559 (not (wl-thread-entity-parent-invisible-p
560 (wl-thread-get-entity number)))))
562 (defun wl-summary-update-mark-and-highlight-window (&optional win beg)
563 "A function to be called as window-scroll-functions."
564 (with-current-buffer (window-buffer win)
565 (when (eq major-mode 'wl-summary-mode)
566 (let ((beg (or beg (window-start win)))
567 (end (condition-case nil
568 (window-end win t) ; old emacsen doesn't support 2nd arg.
569 (error (window-end win))))
571 wl-summary-highlight)
574 (while (and (< (point) end) (not (eobp)))
575 (when (null (get-text-property (point) 'face))
576 (setq number (wl-summary-message-number)
577 flags (elmo-message-flags wl-summary-buffer-elmo-folder
579 (setq wl-summary-highlight nil)
580 (wl-summary-update-persistent-mark number flags)
581 (setq wl-summary-highlight t)
582 (wl-highlight-summary-current-line number flags))
584 (set-buffer-modified-p nil)))
586 (defun wl-summary-window-scroll-functions ()
587 (cond ((and wl-summary-lazy-highlight
588 wl-summary-lazy-update-mark)
589 (list 'wl-summary-update-mark-and-highlight-window))
590 (wl-summary-lazy-highlight
591 (list 'wl-highlight-summary-window))
592 (wl-summary-lazy-update-mark
593 (list 'wl-summary-update-mark-window))))
595 (defun wl-status-update ()
599 (defun wl-summary-display-top ()
601 (goto-char (point-min))
602 (run-hooks 'wl-summary-buffer-window-scroll-functions)
603 (if wl-summary-buffer-disp-msg
604 (wl-summary-redisplay)))
606 (defun wl-summary-display-bottom ()
608 (goto-char (point-max))
610 (run-hooks 'wl-summary-buffer-window-scroll-functions)
611 (if wl-summary-buffer-disp-msg
612 (wl-summary-redisplay)))
614 (defun wl-summary-count-unread ()
615 (let ((lst (elmo-folder-count-flags wl-summary-buffer-elmo-folder)))
616 (if (eq major-mode 'wl-summary-mode)
617 (setq wl-summary-buffer-new-count (car lst)
618 wl-summary-buffer-unread-count (nth 1 lst)
619 wl-summary-buffer-answered-count (nth 2 lst)))
622 (defun wl-summary-message-string (&optional use-cache)
623 "Return full body string of current message.
624 If optional USE-CACHE is non-nil, use cache if exists."
625 (let ((number (wl-summary-message-number))
626 (folder wl-summary-buffer-elmo-folder))
628 (message "No message.")
630 (elmo-message-fetch folder
632 (elmo-make-fetch-strategy
634 use-cache ; use cache
635 nil ; save cache (should `t'?)
638 (elmo-file-cache-get-path
639 (elmo-message-field folder number 'message-id))))
645 (defun wl-summary-reedit (&optional arg)
646 "Re-edit current message.
647 If ARG is non-nil, Supersedes message"
649 (wl-summary-toggle-disp-msg 'off)
651 ((not (wl-summary-message-number))
652 (message "No message."))
654 (wl-summary-supersedes-message))
655 ((string= (wl-summary-buffer-folder-name) wl-draft-folder)
656 (wl-draft-reedit (wl-summary-message-number))
657 (if (wl-message-news-p)
658 (mail-position-on-field "Newsgroups")
659 (mail-position-on-field "To")))
661 (wl-draft-edit-string (wl-summary-message-string)))))
663 (defun wl-summary-resend-bounced-mail ()
664 "Re-mail the current message.
665 This only makes sense if the current message is a bounce message which
666 contains some mail you have written but has been bounced back to
669 (wl-summary-toggle-disp-msg 'off)
671 (wl-summary-set-message-buffer-or-redisplay)
672 (set-buffer (wl-message-get-original-buffer))
673 (goto-char (point-min))
674 (let ((case-fold-search nil))
678 (concat "^\\($\\|[Cc]ontent-[Tt]ype:[ \t]+multipart/\\(report\\|mixed\\)\\)") nil t)
680 (re-search-forward "boundary=\"\\([^\"]+\\)\"" nil t))
681 (let ((boundary (buffer-substring (match-beginning 1) (match-end 1)))
684 ((and (setq start (re-search-forward
685 (concat "^--" boundary "\n"
686 "\\([Cc]ontent-[Dd]escription:.*\n\\)?"
687 "[Cc]ontent-[Tt]ype:[ \t]+"
688 "\\(message/rfc822\\|text/rfc822-headers\\).*\n"
689 "\\(.+\n\\)*\n") nil t))
691 (concat "\n\\(--" boundary "\\)--\n") nil t))
692 (wl-draft-edit-string (buffer-substring start (match-beginning 1))))
694 (message "Seems no message/rfc822 part.")))))
695 ((let ((case-fold-search t))
696 (re-search-forward wl-rejected-letter-start nil t))
697 (skip-chars-forward " \t\n")
698 (wl-draft-edit-string (buffer-substring (point) (point-max))))
700 (message "Does not appear to be a rejected letter."))))))
702 (defun wl-summary-detect-mark-position ()
703 (let ((column wl-summary-buffer-number-column)
704 (formatter wl-summary-buffer-line-formatter)
705 (dummy-temp (char-to-string 200))
706 (wl-summary-new-mark (char-to-string 201)) ; bind only for the check.
707 (wl-summary-flag-priority-list '(new)) ; ditto.
711 (setq wl-summary-buffer-number-column column
712 wl-summary-buffer-line-formatter formatter)
714 (wl-summary-create-line
715 (elmo-msgdb-make-message-entity
716 (luna-make-entity 'modb-entity-handler)
725 (goto-char (point-min))
726 (setq temp (save-excursion
727 (when (search-forward dummy-temp nil t)
729 persistent (save-excursion
730 (when (search-forward wl-summary-new-mark nil t)
732 (setq wl-summary-buffer-temp-mark-column temp
733 wl-summary-buffer-persistent-mark-column persistent)))
735 (defun wl-summary-buffer-set-folder (folder)
737 (setq folder (wl-folder-get-elmo-folder folder)))
738 (setq wl-summary-buffer-elmo-folder folder)
739 (make-local-variable 'wl-message-buffer)
740 (setq wl-summary-buffer-mime-charset (or (wl-get-assoc-list-value
741 wl-folder-mime-charset-alist
742 (elmo-folder-name-internal folder))
744 (setq wl-summary-buffer-weekday-name-lang
745 (or (wl-get-assoc-list-value
746 wl-folder-weekday-name-lang-alist
747 (elmo-folder-name-internal folder))
748 wl-summary-weekday-name-lang))
749 (setq wl-summary-buffer-thread-indent-set
750 (wl-get-assoc-list-value
751 wl-folder-thread-indent-set-alist
752 (elmo-folder-name-internal folder)))
753 (setq wl-summary-buffer-number-column
754 (or (wl-get-assoc-list-value wl-summary-number-column-alist
755 (wl-summary-buffer-folder-name))
756 wl-summary-default-number-column))
757 (wl-line-formatter-setup
758 wl-summary-buffer-line-formatter
759 (setq wl-summary-buffer-line-format
760 (or (wl-get-assoc-list-value
761 wl-folder-summary-line-format-alist
762 (elmo-folder-name-internal folder))
763 wl-summary-line-format))
764 wl-summary-line-format-spec-alist)
765 (wl-line-formatter-setup
766 wl-summary-buffer-mode-line-formatter
767 wl-summary-mode-line-format
768 wl-summary-mode-line-format-spec-alist)
769 (setq wl-summary-buffer-persistent
770 (wl-folder-persistent-p (elmo-folder-name-internal folder)))
771 (elmo-folder-set-persistent-internal folder wl-summary-buffer-persistent)
772 ;; process duplicates.
773 (elmo-folder-set-process-duplicates-internal
774 folder (cdr (elmo-string-matched-assoc
775 (elmo-folder-name-internal folder)
776 wl-folder-process-duplicates-alist)))
778 wl-thread-indent-level-internal
779 (or (nth 0 wl-summary-buffer-thread-indent-set)
780 wl-thread-indent-level)
781 wl-thread-have-younger-brother-str-internal
782 (or (nth 1 wl-summary-buffer-thread-indent-set)
783 wl-thread-have-younger-brother-str)
784 wl-thread-youngest-child-str-internal
785 (or (nth 2 wl-summary-buffer-thread-indent-set)
786 wl-thread-youngest-child-str)
787 wl-thread-vertical-str-internal
788 (or (nth 3 wl-summary-buffer-thread-indent-set)
789 wl-thread-vertical-str)
790 wl-thread-horizontal-str-internal
791 (or (nth 4 wl-summary-buffer-thread-indent-set)
792 wl-thread-horizontal-str)
793 wl-thread-space-str-internal
794 (or (nth 5 wl-summary-buffer-thread-indent-set)
795 wl-thread-space-str))
796 (run-hooks 'wl-summary-buffer-set-folder-hook))
798 (defun wl-summary-mode ()
799 "Major mode for reading threaded messages.
800 See Info under Wanderlust for full documentation.
803 \\{wl-summary-mode-map}
805 Entering Folder mode calls the value of `wl-summary-mode-hook'."
807 (unless (interactive-p) (kill-all-local-variables))
808 (setq major-mode 'wl-summary-mode)
809 (setq mode-name "Summary")
810 (use-local-map wl-summary-mode-map)
811 ;;;(setq default-directory (or wl-tmp-dir (expand-file-name "~/")))
812 (setq buffer-read-only t)
813 (setq truncate-lines t)
814 ;;;(make-local-variable 'tab-width)
815 ;;;(setq tab-width 1)
816 (buffer-disable-undo (current-buffer))
817 (setq selective-display t
818 selective-display-ellipses nil)
819 (wl-mode-line-buffer-identification '(wl-summary-buffer-mode-line))
820 (easy-menu-add wl-summary-mode-menu)
821 (setq wl-summary-buffer-window-scroll-functions
822 (wl-summary-window-scroll-functions))
823 (when wl-summary-buffer-window-scroll-functions
824 (let ((hook (if wl-on-xemacs 'pre-idle-hook 'window-scroll-functions)))
825 (make-local-hook hook)
826 (dolist (function wl-summary-buffer-window-scroll-functions)
827 (add-hook hook function nil t))))
828 ;; This hook may contain the function `wl-setup-summary' for reasons
829 ;; of system internal to accord facilities for the Emacs variants.
830 (run-hooks 'wl-summary-mode-hook))
833 (defun wl-summary-overview-entity-compare-by-date (x y)
834 "Compare entity X and Y by date."
837 (timezone-make-date-sortable
838 (elmo-message-entity-field x 'date))
839 (timezone-make-date-sortable
840 (elmo-message-entity-field y 'date)))
841 (error))) ;; ignore error.
843 (defun wl-summary-overview-entity-compare-by-number (x y)
844 "Compare entity X and Y by number."
846 (elmo-message-entity-number x)
847 (elmo-message-entity-number y)))
849 (defun wl-summary-overview-entity-compare-by-from (x y)
850 "Compare entity X and Y by from."
852 (wl-address-header-extract-address
853 (or (elmo-message-entity-field x 'from t)
854 wl-summary-no-from-message))
855 (wl-address-header-extract-address
856 (or (elmo-message-entity-field y 'from t)
857 wl-summary-no-from-message))))
859 (defun wl-summary-overview-entity-compare-by-subject (x y)
860 "Compare entity X and Y by subject."
861 (string< (elmo-message-entity-field x 'subject)
862 (elmo-message-entity-field y 'subject)))
864 (defun wl-summary-get-list-info (entity)
865 "Returns (\"ML-name\" . ML-count) of ENTITY."
866 (let (sequence ml-name ml-count subject return-path delivered-to mailing-list)
867 (setq sequence (elmo-message-entity-field entity 'x-sequence)
868 ml-name (or (elmo-message-entity-field entity 'x-ml-name)
870 (car (split-string sequence " "))))
871 ml-count (or (elmo-message-entity-field entity 'x-mail-count)
872 (elmo-message-entity-field entity 'x-ml-count)
874 (cadr (split-string sequence " ")))))
875 (and (setq subject (elmo-message-entity-field entity 'subject t))
876 (setq subject (elmo-delete-char ?\n subject))
877 (string-match "^\\s(\\(\\S)+\\)[ :]\\([0-9]+\\)\\s)[ \t]*" subject)
879 (or ml-name (setq ml-name (match-string 1 subject)))
880 (or ml-count (setq ml-count (match-string 2 subject)))))
881 (and (setq return-path
882 (elmo-message-entity-field entity 'return-path))
883 (string-match "^<\\([^@>]+\\)-return-\\([0-9]+\\)-" return-path)
885 (or ml-name (setq ml-name (match-string 1 return-path)))
886 (or ml-count (setq ml-count (match-string 2 return-path)))))
887 (and (setq delivered-to
888 (elmo-message-entity-field entity 'delivered-to))
889 (string-match "^mailing list \\([^@]+\\)@" delivered-to)
890 (or ml-name (setq ml-name (match-string 1 delivered-to))))
891 (and (setq mailing-list
892 (elmo-message-entity-field entity 'mailing-list))
893 ;; *-help@, *-owner@, etc.
894 (string-match "\\(^\\|; \\)contact \\([^@]+\\)-[^-@]+@" mailing-list)
895 (or ml-name (setq ml-name (match-string 2 mailing-list))))
896 (cons (and ml-name (car (split-string ml-name " ")))
897 (and ml-count (string-to-int ml-count)))))
899 (defun wl-summary-overview-entity-compare-by-list-info (x y)
900 "Compare entity X and Y by mailing-list info."
901 (let* ((list-info-x (wl-summary-get-list-info x))
902 (list-info-y (wl-summary-get-list-info y)))
903 (if (equal (car list-info-x) (car list-info-y))
904 (if (equal (cdr list-info-x) (cdr list-info-y))
905 (wl-summary-overview-entity-compare-by-date x y)
906 (< (or (cdr list-info-x) 0)
907 (or (cdr list-info-y) 0)))
908 (string< (or (car list-info-x) "")
909 (or (car list-info-y) "")))))
911 (defun wl-summary-sort-by-date ()
913 (wl-summary-rescan "date"))
914 (defun wl-summary-sort-by-number ()
916 (wl-summary-rescan "number"))
917 (defun wl-summary-sort-by-subject ()
919 (wl-summary-rescan "subject"))
920 (defun wl-summary-sort-by-from ()
922 (wl-summary-rescan "from"))
923 (defun wl-summary-sort-by-list-info ()
925 (wl-summary-rescan "list-info"))
927 (defun wl-summary-rescan (&optional sort-by disable-killed disable-thread)
928 "Rescan current folder without updating."
930 (let ((elmo-mime-charset wl-summary-buffer-mime-charset)
934 (inhibit-read-only t)
935 (buffer-read-only nil)
936 (numbers (elmo-folder-list-messages wl-summary-buffer-elmo-folder
937 (not disable-killed) t)) ; in-msgdb
938 (wl-thread-saved-entity-hashtb-internal (and (not disable-thread)
939 wl-thread-entity-hashtb))
940 (wl-summary-search-parent-by-subject-regexp
941 (and disable-thread wl-summary-search-parent-by-subject-regexp))
942 (wl-summary-divide-thread-when-subject-changed
943 (and disable-thread wl-summary-divide-thread-when-subject-changed))
946 (message "Re-scanning...")
949 (message "Sorting by %s..." sort-by)
954 (intern (format "wl-summary-overview-entity-compare-by-%s"
956 (elmo-message-entity wl-summary-buffer-elmo-folder x)
957 (elmo-message-entity wl-summary-buffer-elmo-folder y)))))
958 (message "Sorting by %s...done" sort-by))
959 (setq num (length numbers))
960 (setq wl-thread-entity-hashtb (elmo-make-hash (* num 2))
961 wl-thread-entity-list nil
962 wl-thread-entities nil
963 wl-summary-scored nil
964 wl-summary-buffer-number-list nil
965 wl-summary-buffer-unsync-mark-number-list nil
966 wl-summary-buffer-target-mark-list nil
967 wl-summary-buffer-temp-mark-list nil
968 wl-summary-delayed-update nil)
969 (elmo-kill-buffer wl-summary-search-buf-name)
971 (setq entity (elmo-message-entity wl-summary-buffer-elmo-folder
973 (wl-summary-insert-message entity
974 wl-summary-buffer-elmo-folder
976 (setq numbers (cdr numbers))
977 (when (> num elmo-display-progress-threshold)
979 (if (or (zerop (% i 5)) (= i num))
980 (elmo-display-progress
981 'wl-summary-rescan "Constructing summary structure..."
982 (/ (* i 100) num)))))
983 (when wl-summary-delayed-update
984 (while wl-summary-delayed-update
985 (message "Parent (%d) of message %d is no entity"
986 (caar wl-summary-delayed-update)
987 (elmo-message-entity-number
988 (cdar wl-summary-delayed-update)))
989 (wl-summary-insert-message
990 (cdar wl-summary-delayed-update)
991 wl-summary-buffer-elmo-folder nil t)
992 (setq wl-summary-delayed-update (cdr wl-summary-delayed-update))))
993 (message "Constructing summary structure...done")
994 (if (eq wl-summary-buffer-view 'thread)
996 (message "Inserting thread...")
997 (wl-thread-insert-top)
998 (message "Inserting thread...done")))
1000 (wl-summary-score-headers (wl-summary-rescore-msgs
1001 wl-summary-buffer-number-list)
1003 (when (and wl-summary-scored
1004 (setq expunged (wl-summary-score-update-all-lines)))
1005 (message "%d message(s) are expunged by scoring." (length expunged))))
1006 (wl-summary-set-message-modified)
1007 (wl-summary-count-unread)
1008 (wl-summary-update-modeline)
1009 (goto-char (point-max))
1011 (set-buffer-modified-p nil)))
1013 (defun wl-summary-next-folder-or-exit (&optional next-entity upward)
1014 (if (and next-entity
1015 wl-auto-select-next)
1017 (wl-summary-toggle-disp-msg 'off)
1020 (wl-summary-goto-folder-subr next-entity
1026 (wl-folder-set-current-entity-id (wl-folder-get-entity-id next-entity))
1027 (if (and (eq retval 'more-next)
1028 (memq wl-auto-select-next '(unread skip-no-unread))
1029 (memq this-command wl-summary-next-no-unread-command))
1032 t (eq wl-auto-select-next 'skip-no-unread))
1033 (goto-char (point-max))
1036 t (eq wl-auto-select-next 'skip-no-unread))))))
1039 (defun wl-summary-entity-info-msg (entity finfo)
1042 (if (memq 'ask-folder wl-use-folder-petname)
1043 (wl-folder-get-petname entity)
1045 (if (null (car finfo))
1048 " (%d new/%d unread)"
1054 (defun wl-summary-set-message-modified ()
1055 (setq wl-summary-buffer-message-modified t))
1056 (defun wl-summary-message-modified-p ()
1057 wl-summary-buffer-message-modified)
1058 (defun wl-summary-set-thread-modified ()
1059 (setq wl-summary-buffer-thread-modified t))
1060 (defun wl-summary-thread-modified-p ()
1061 wl-summary-buffer-thread-modified)
1063 (defsubst wl-summary-cleanup-temp-marks (&optional sticky)
1064 (when wl-summary-buffer-temp-mark-list
1065 (if (y-or-n-p (format "Execute remaining marks in %s? "
1066 (wl-summary-buffer-folder-name)))
1069 (if wl-summary-buffer-temp-mark-list
1070 (error "Some execution was failed")))
1071 ;; temp-mark-list is remained.
1073 (wl-summary-delete-all-temp-marks 'no-msg)
1074 (setq wl-summary-scored nil))
1076 ;; a subroutine for wl-summary-exit/wl-save-status
1077 ;; Note that folder is not commited here.
1078 (defun wl-summary-save-view ()
1079 ;; already in summary buffer.
1080 (when wl-summary-buffer-persistent
1081 ;; save the current summary buffer view.
1082 (if (and wl-summary-cache-use
1083 (or (wl-summary-message-modified-p)
1084 (wl-summary-thread-modified-p)))
1085 (wl-summary-save-view-cache))))
1087 (defun wl-summary-save-status ()
1088 "Save summary view and msgdb."
1090 (if (interactive-p) (message "Saving summary status..."))
1091 (wl-summary-save-view)
1092 (elmo-folder-commit wl-summary-buffer-elmo-folder)
1093 (elmo-folder-check wl-summary-buffer-elmo-folder)
1094 (if wl-use-scoring (wl-score-save))
1095 (if (interactive-p) (message "Saving summary status...done")))
1097 (defun wl-summary-force-exit ()
1098 "Exit current summary. Buffer is deleted even the buffer is sticky."
1100 (wl-summary-exit 'force-exit))
1102 (defun wl-summary-exit (&optional force-exit)
1103 "Exit current summary. if FORCE-EXIT, exits even the summary is sticky."
1105 (let ((summary-buf (current-buffer))
1106 (sticky (wl-summary-sticky-p))
1108 message-buf message-win
1109 folder-buf folder-win)
1110 (run-hooks 'wl-summary-exit-pre-hook)
1111 (if wl-summary-buffer-exit-function
1112 (funcall wl-summary-buffer-exit-function)
1113 (if (or force-exit (not sticky))
1114 (wl-summary-cleanup-temp-marks sticky))
1116 ;; save summary status
1118 (wl-summary-save-view)
1119 (if (or force-exit (not sticky))
1120 (elmo-folder-close wl-summary-buffer-elmo-folder)
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 ;; for sticky summary
1125 (wl-delete-all-overlays)
1126 (setq wl-summary-buffer-disp-msg nil)
1127 (elmo-kill-buffer wl-summary-search-buf-name)
1128 ;; delete message window if displayed.
1129 (if (and wl-message-buffer (get-buffer-window wl-message-buffer))
1130 (delete-window (get-buffer-window wl-message-buffer)))
1131 (if (and wl-summary-use-frame
1132 (> (length (visible-frame-list)) 1))
1134 (if (setq folder-buf (get-buffer wl-folder-buffer-name))
1135 (if wl-summary-use-frame
1137 (save-selected-window
1138 (dolist (frame (visible-frame-list))
1139 (select-frame frame)
1140 (if (get-buffer-window folder-buf)
1141 (setq select-frame frame))))
1143 (select-frame select-frame)
1144 (switch-to-buffer folder-buf)))
1145 (if (setq folder-win (get-buffer-window folder-buf))
1146 ;; folder win is already displayed.
1147 (select-window folder-win)
1148 ;; folder win is not displayed.
1149 (switch-to-buffer folder-buf)))
1150 ;; currently no folder buffer
1152 (and wl-folder-move-cur-folder
1153 wl-folder-buffer-cur-point
1154 (goto-char wl-folder-buffer-cur-point))
1155 (setq wl-folder-buffer-cur-path nil)
1156 (setq wl-folder-buffer-cur-entity-id nil)
1157 (wl-delete-all-overlays)
1158 (if wl-summary-exit-next-move
1159 (wl-folder-next-unsync t)
1160 (beginning-of-line))
1161 (if (setq summary-win (get-buffer-window summary-buf))
1162 (delete-window summary-win))
1166 (set-buffer summary-buf)
1167 (kill-buffer summary-buf)))
1168 (run-hooks 'wl-summary-exit-hook)))))
1170 (defun wl-summary-suspend ()
1173 (wl-folder-suspend))
1175 (defun wl-summary-sync-force-update (&optional unset-cursor no-check)
1177 (wl-summary-sync-update unset-cursor nil nil no-check))
1179 (defsubst wl-summary-sync-all-init ()
1180 (wl-summary-cleanup-temp-marks)
1182 (wl-summary-set-message-modified)
1183 (setq wl-thread-entity-hashtb (elmo-make-hash
1184 (* (elmo-folder-length
1185 wl-summary-buffer-elmo-folder)
1187 (setq wl-thread-entity-list nil)
1188 (setq wl-thread-entities nil)
1189 (setq wl-summary-buffer-number-list nil)
1190 (setq wl-summary-buffer-target-mark-list nil)
1191 (setq wl-summary-buffer-temp-mark-list nil))
1193 (defun wl-summary-sync (&optional unset-cursor force-range)
1195 (let* ((folder wl-summary-buffer-elmo-folder)
1196 (inhibit-read-only t)
1197 (buffer-read-only nil)
1198 (msgdb-dir (elmo-folder-msgdb-path folder))
1199 (range (or force-range (wl-summary-input-range
1200 (elmo-folder-name-internal folder)))))
1201 (cond ((string-match "rescan" range)
1202 (let ((msg (wl-summary-message-number))
1203 (wl-use-scoring (if (string-match "noscore" range)
1206 (wl-summary-rescan nil
1207 (string-match "noscore" range)
1208 (string-match "thread" range))
1209 (and msg (wl-summary-jump-to-msg msg))))
1210 ((string= range "mark")
1211 (let ((msg (wl-summary-message-number)))
1212 (call-interactively 'wl-summary-sync-marks)
1213 (and msg (wl-summary-jump-to-msg msg))))
1214 ((string= range "cache-status")
1215 (let ((msg (wl-summary-message-number)))
1216 (wl-summary-resume-cache-status)
1217 (and msg (wl-summary-jump-to-msg msg))))
1218 ((string= range "no-sync"))
1219 ((or (string-match "^last:" range)
1220 (string-match "^first:" range))
1221 (wl-summary-goto-folder-subr (concat "/" range "/"
1222 (elmo-folder-name-internal
1224 'force-update nil nil t))
1226 (wl-summary-sync-update unset-cursor
1227 (string-match "entirely" range)
1228 (string-match "all" range))))))
1230 (defvar wl-summary-edit-addresses-candidate-fields
1231 ;; First element becomes default.
1232 '("from" "to" "cc"))
1234 (defun wl-summary-edit-addresses-collect-candidate-fields (mime-charset)
1235 (let ((fields wl-summary-edit-addresses-candidate-fields)
1236 body candidates components)
1239 (mapconcat 'identity (elmo-multiple-field-body (car fields))
1241 (setq body (wl-parse-addresses body))
1242 (if body (setq candidates (append candidates body)))
1243 (setq fields (cdr fields)))
1244 (setq candidates (elmo-uniq-list candidates))
1246 (elmo-set-buffer-multibyte default-enable-multibyte-characters)
1249 (setq components (std11-extract-address-components x))
1250 (cons (nth 1 components)
1251 (and (car components)
1252 (eword-decode-string
1253 (decode-mime-charset-string
1258 (defun wl-summary-edit-addresses-subr (the-email name-in-addr)
1259 ;; returns nil if there's no change.
1260 (if (elmo-get-hash-val (downcase the-email) wl-address-petname-hash)
1262 (message "'%s' already exists. (e)dit/(d)elete/(c)ancel?"
1264 (while (not (or (eq (setq char (read-char)) ?\r)
1271 "Please answer `e' or `d' or `c'. (e)dit/(d)elete/(c)ancel?"))
1278 (wl-address-add-or-change
1280 (wl-address-header-extract-realname
1282 (let ((completion-ignore-case t) comp)
1284 (try-completion the-email wl-address-completion-list))
1285 (if (equal comp t) the-email comp))
1286 wl-address-completion-list))))
1290 (if (y-or-n-p (format "Delete '%s'? "
1293 (wl-address-delete the-email)
1300 (wl-address-add-or-change the-email name-in-addr)
1303 (defun wl-summary-edit-addresses (&optional addr-str)
1304 "Edit address book interactively.
1305 Optional argument ADDR-STR is used as a target address if specified."
1306 (interactive (if current-prefix-arg
1307 (list (read-from-minibuffer "Target address: "))))
1308 (if (null (wl-summary-message-number))
1309 (message "No message.")
1311 (let* ((charset wl-summary-buffer-mime-charset)
1313 (with-current-buffer (wl-summary-get-original-buffer)
1314 (wl-summary-edit-addresses-collect-candidate-fields
1316 address pair result)
1318 (setq address addr-str)
1320 (setq address (car (car candidates)))
1323 (format "Target address (%s): " address)
1325 (function (lambda (x) (cons (car x) (car x))))
1327 nil nil nil nil address))))
1329 (setq pair (assoc address candidates))
1331 (setq pair (cons address nil)))
1332 (when (setq result (wl-summary-edit-addresses-subr (car pair) (cdr pair)))
1335 (setq address (assoc (car pair) wl-address-list))
1337 (message "%s, %s, <%s> is %s."
1342 ;;; i'd like to update summary-buffer, but...
1343 ;;; (wl-summary-rescan)
1344 (run-hooks 'wl-summary-edit-addresses-hook))))))
1346 (defun wl-summary-incorporate (&optional arg)
1347 "Check and prefetch all uncached messages.
1348 If ARG is non-nil, checking is omitted."
1352 (wl-summary-sync-force-update)))
1353 (wl-summary-prefetch-region-no-mark (point-min) (point-max)
1354 wl-summary-incorporate-marks))
1356 (defun wl-summary-prefetch-msg (number &optional arg)
1357 "Prefetch message and return non-nil value. If skipped, return nil."
1358 ;; prefetching procedure.
1360 (let* ((size (elmo-message-field wl-summary-buffer-elmo-folder
1362 (file-cached (elmo-file-cache-exists-p
1363 (elmo-message-field wl-summary-buffer-elmo-folder
1364 number 'message-id)))
1365 (force-read (and size
1367 (and (null wl-prefetch-confirm) arg)
1368 (null wl-prefetch-threshold)
1369 (< size wl-prefetch-threshold))))
1372 (when (and (or arg (not file-cached))
1373 size (not force-read) wl-prefetch-confirm)
1374 (let ((wl-message-entity (elmo-message-entity
1375 wl-summary-buffer-elmo-folder
1382 "Message from %s has %d bytes. Prefetch it? "
1386 (wl-set-string-width
1389 wl-summary-from-function
1393 (elmo-message-entity-field
1399 (message ""))) ; flush.
1404 (if (or arg (not file-cached))
1405 (elmo-message-encache
1406 wl-summary-buffer-elmo-folder
1408 (elmo-message-set-cached wl-summary-buffer-elmo-folder
1410 (when (and (wl-summary-jump-to-msg number)
1411 (wl-summary-update-persistent-mark))
1413 (wl-summary-count-unread)
1414 (wl-summary-update-modeline)
1415 (wl-folder-update-unread
1416 (wl-summary-buffer-folder-name)
1417 (+ wl-summary-buffer-unread-count
1418 wl-summary-buffer-new-count))))
1422 (defsubst wl-summary-narrow-to-region (beg end)
1430 (if (eq (current-column) 0) (beginning-of-line) (end-of-line))
1433 (defun wl-summary-prefetch-region-no-mark (beg end &optional prefetch-marks)
1441 (setq start-pos (point))
1443 (wl-summary-narrow-to-region beg end)
1444 ;; collect prefetch targets.
1445 (message "Collecting marks...")
1446 (goto-char (point-min))
1448 (setq mark (wl-summary-persistent-mark)
1449 msg (wl-summary-message-number))
1450 (if (or (and (null prefetch-marks)
1452 (null (elmo-file-cache-exists-p
1454 wl-summary-buffer-elmo-folder
1457 (member mark prefetch-marks))
1458 (setq targets (nconc targets (list msg))))
1459 (setq entity (wl-thread-get-entity msg))
1460 (if (or (not (eq wl-summary-buffer-view 'thread))
1461 (wl-thread-entity-get-opened entity))
1462 (); opened. no hidden children.
1463 (setq targets (nconc
1465 (wl-thread-get-children-msgs-uncached
1466 msg prefetch-marks))))
1468 (setq length (length targets))
1469 (message "Prefetching...")
1471 (when (if (not (wl-thread-entity-parent-invisible-p
1472 (wl-thread-get-entity (car targets))))
1474 (wl-summary-jump-to-msg (car targets))
1475 (wl-summary-prefetch-msg
1476 (wl-summary-message-number)))
1477 (wl-summary-prefetch-msg (car targets)))
1478 (message "Prefetching... %d/%d message(s)"
1479 (setq count (+ 1 count)) length))
1480 (setq targets (cdr targets)))
1481 (message "Prefetched %d/%d message(s)" count length)
1482 (cons count length)))))
1484 (defun wl-summary-delete-marks-on-buffer (marks)
1486 (wl-summary-unmark (pop marks))))
1488 (defun wl-summary-delete-copy-marks-on-buffer (copies)
1489 (wl-summary-delete-marks-on-buffer copies))
1492 (defun wl-summary-delete-all-target-marks ()
1493 (wl-summary-delete-marks-on-buffer wl-summary-buffer-target-mark-list))
1495 (defun wl-summary-mark-as-read-region (beg end)
1499 (wl-summary-narrow-to-region beg end)
1500 (goto-char (point-min))
1501 (if (eq wl-summary-buffer-view 'thread)
1504 (let* ((number (wl-summary-message-number))
1505 (entity (wl-thread-get-entity number)))
1506 (if (wl-thread-entity-get-opened entity)
1507 (setq number-list (append number-list (list number)))
1510 (wl-thread-get-children-msgs number))))
1512 (wl-summary-mark-as-read number-list))
1516 (append number-list (list (wl-summary-message-number))))
1518 (wl-summary-mark-as-read number-list))))))
1520 (defun wl-summary-mark-as-unread-region (beg end)
1524 (wl-summary-narrow-to-region beg end)
1525 (goto-char (point-min))
1526 (if (eq wl-summary-buffer-view 'thread)
1529 (let* ((number (wl-summary-message-number))
1530 (entity (wl-thread-get-entity number)))
1531 (if (wl-thread-entity-get-opened entity)
1532 (setq number-list (append number-list (list number)))
1535 (wl-thread-get-children-msgs number))))
1537 (wl-summary-mark-as-unread number-list))
1541 (append number-list (list (wl-summary-message-number))))
1543 (wl-summary-mark-as-unread number-list))))))
1545 (defun wl-summary-mark-as-important-region (beg end)
1549 (wl-summary-narrow-to-region beg end)
1550 (goto-char (point-min))
1551 (if (eq wl-summary-buffer-view 'thread)
1554 (let* ((number (wl-summary-message-number))
1555 (entity (wl-thread-get-entity number))
1557 (if (wl-thread-entity-get-opened entity)
1558 ;; opened...mark line.
1559 ;; Crossposts are not processed
1560 (wl-summary-mark-as-important)
1562 (wl-summary-mark-as-important) ; mark itself.
1564 (delq number (wl-thread-get-children-msgs number)))
1566 (wl-summary-mark-as-important (car children))
1567 (setq children (cdr children))))
1570 (wl-summary-mark-as-important)
1571 (forward-line 1)))))
1572 (wl-summary-count-unread)
1573 (wl-summary-update-modeline))
1575 (defun wl-summary-mark-as-read-all ()
1577 (if (or (not (interactive-p))
1578 (y-or-n-p "Mark all messages as read? "))
1579 (let ((folder wl-summary-buffer-elmo-folder)
1580 (cur-buf (current-buffer)))
1581 (message "Setting all msgs as read...")
1582 (elmo-folder-flag-as-read folder
1583 (elmo-folder-list-unreads
1586 (goto-char (point-min))
1588 (wl-summary-update-persistent-mark)
1590 (wl-folder-update-unread (wl-summary-buffer-folder-name) 0)
1591 (setq wl-summary-buffer-unread-count 0)
1592 (setq wl-summary-buffer-new-count 0)
1593 (wl-summary-update-modeline)
1594 (message "Setting all msgs as read...done"))))
1596 (defun wl-summary-delete-cache ()
1597 "Delete cache of current message."
1600 (let* ((folder wl-summary-buffer-elmo-folder)
1602 (setq number (wl-summary-message-number))
1603 (elmo-message-set-cached folder number nil)
1604 (when (wl-summary-update-persistent-mark)
1605 (elmo-file-cache-delete
1606 (elmo-file-cache-get-path
1607 (elmo-message-field wl-summary-buffer-elmo-folder
1611 (defun wl-summary-resume-cache-status ()
1612 "Resume the cache status of all messages in the current folder."
1614 (let ((folder wl-summary-buffer-elmo-folder)
1616 (message "Resuming cache status...")
1618 (goto-char (point-min))
1620 (setq number (wl-summary-message-number))
1621 (setq msgid (elmo-message-field folder number 'message-id))
1622 (elmo-message-set-cached folder number
1623 (elmo-file-cache-exists-p msgid))
1624 (wl-summary-update-persistent-mark)
1626 (wl-summary-count-unread)
1627 (wl-summary-update-modeline)
1628 (message "Resuming cache status...done"))))
1630 (defun wl-summary-delete-messages-on-buffer (msgs &optional deleting-info)
1633 (let ((inhibit-read-only t)
1634 (buffer-read-only nil)
1638 ;(deleting-info (or deleting-info "Deleting..."))
1640 (elmo-kill-buffer wl-summary-search-buf-name)
1642 (if (eq wl-summary-buffer-view 'thread)
1644 ;; don't use wl-append(nconc), because list is broken. ...why?
1647 (wl-thread-delete-message (car msgs))))
1648 (setq update-list (delq (car msgs) update-list)))
1649 (goto-char (point-min))
1650 (if (wl-summary-jump-to-msg (car msgs))
1652 (delete-region (point-at-bol) (point-at-eol))
1653 (delete-char 1) ; delete '\n'
1654 (setq wl-summary-buffer-number-list
1655 (delq (car msgs) wl-summary-buffer-number-list)))))
1656 ; (when (> len elmo-display-progress-threshold)
1658 ; (if (or (zerop (% i 5)) (= i len))
1659 ; (elmo-display-progress
1660 ; 'wl-summary-delete-messages-on-buffer deleting-info
1661 ; (/ (* i 100) len))))
1662 (setq msgs (cdr msgs)))
1663 (when (eq wl-summary-buffer-view 'thread)
1664 (wl-thread-update-line-msgs (elmo-uniq-list update-list))
1665 (wl-thread-cleanup-symbols msgs2))
1666 ;;(message (concat deleting-info "done"))
1667 (wl-summary-count-unread)
1668 (wl-summary-update-modeline)
1669 (wl-summary-folder-info-update))))
1671 (defun wl-summary-update-status-marks (beg end &optional check)
1672 "Synchronize status marks on current buffer to the msgdb."
1676 (while (and (< (point) end) (not (eobp)))
1677 (when (or (not check)
1678 (let ((number (wl-summary-message-number)))
1679 (when (memq number wl-summary-buffer-unsync-mark-number-list)
1680 (setq wl-summary-buffer-unsync-mark-number-list
1682 wl-summary-buffer-unsync-mark-number-list))
1684 (wl-summary-update-persistent-mark))
1687 (defun wl-summary-update-mark-window (&optional win beg)
1688 "Update persistent mark in visible summary window.
1689 This function is defined for `window-scroll-functions'"
1690 (with-current-buffer (window-buffer win)
1691 (when (eq major-mode 'wl-summary-mode)
1692 (let ((start (window-start win))
1693 (end (condition-case nil
1694 (window-end win t) ; old emacsen doesn't support 2nd arg.
1695 (error (window-end win)))))
1696 (wl-summary-update-status-marks start end 'check)))))
1698 (defun wl-summary-insert-message (&rest args)
1699 (if (eq wl-summary-buffer-view 'thread)
1700 (apply 'wl-summary-insert-thread args)
1701 (apply 'wl-summary-insert-sequential args)))
1703 (defun wl-summary-sort ()
1707 (format "Sort by (%s): " (symbol-name wl-summary-default-sort-spec))
1708 (mapcar (lambda (spec)
1709 (list (symbol-name spec)))
1710 wl-summary-sort-specs)
1711 nil t nil nil (symbol-name wl-summary-default-sort-spec))))
1713 (defun wl-summary-sync-marks ()
1714 "Update persistent marks in summary."
1716 (let ((last-progress 0)
1717 (folder wl-summary-buffer-elmo-folder)
1719 answereds importants unreads diff diffs
1721 ;; synchronize marks.
1722 (when (not (eq (elmo-folder-type-internal
1723 wl-summary-buffer-elmo-folder)
1725 (message "Updating marks...")
1726 (setq importants (elmo-uniq-list
1727 (nconc (elmo-folder-list-importants
1728 wl-summary-buffer-elmo-folder)
1729 ;; XXX Temporal implementation.
1730 ;; It should be merged to the
1731 ;; elmo-folder-list-flagged.
1732 (elmo-folder-list-global-flag-messages
1733 wl-summary-buffer-elmo-folder
1735 unreads (elmo-folder-list-unreads
1736 wl-summary-buffer-elmo-folder)
1737 answereds (elmo-folder-list-answereds
1738 wl-summary-buffer-elmo-folder))
1739 (setq diff (elmo-list-diff importants
1740 (elmo-folder-list-flagged
1741 wl-summary-buffer-elmo-folder
1742 'important 'in-msgdb)))
1743 (setq diffs (cadr diff)) ; important-deletes
1744 (setq mes (format "Updated (-%d" (length diffs)))
1746 (wl-summary-mark-as-important (car diffs)
1747 wl-summary-important-mark
1749 (setq diffs (cdr diffs)))
1750 (setq diffs (car diff)) ; important-appends
1751 (setq mes (concat mes (format "/+%d) important," (length diffs))))
1753 (wl-summary-mark-as-important (car diffs) " " 'no-server)
1754 (setq diffs (cdr diffs)))
1756 (setq diff (elmo-list-diff answereds
1757 (elmo-folder-list-flagged
1758 wl-summary-buffer-elmo-folder
1759 'answered 'in-msgdb)))
1760 (setq diffs (cadr diff))
1761 (setq mes (concat mes (format "(-%d" (length diffs))))
1763 (wl-summary-mark-as-unanswered (car diffs) 'no-modeline)
1764 (setq diffs (cdr diffs)))
1765 (setq diffs (car diff)) ; unread-appends
1766 (setq mes (concat mes (format "/+%d) answered mark(s)," (length diffs))))
1768 (wl-summary-mark-as-answered (car diffs) 'no-modeline)
1769 (setq diffs (cdr diffs)))
1771 (setq diff (elmo-list-diff unreads
1772 (elmo-folder-list-flagged
1773 wl-summary-buffer-elmo-folder
1774 'unread 'in-msgdb)))
1775 (setq diffs (cadr diff))
1776 (setq mes (concat mes (format "(-%d" (length diffs))))
1778 (wl-summary-mark-as-read (car diffs) 'no-folder 'no-modeline)
1779 (setq diffs (cdr diffs)))
1780 (setq diffs (car diff)) ; unread-appends
1781 (setq mes (concat mes (format "/+%d) unread mark(s)." (length diffs))))
1783 (wl-summary-mark-as-unread (car diffs) 'no-folder 'no-modeline)
1784 (setq diffs (cdr diffs)))
1785 (if (interactive-p) (message "%s" mes)))))
1787 (defun wl-summary-sync-update (&optional unset-cursor
1791 "Update the summary view to the newest folder status."
1793 (let* ((folder wl-summary-buffer-elmo-folder)
1794 (elmo-mime-charset wl-summary-buffer-mime-charset)
1795 (inhibit-read-only t)
1796 (buffer-read-only nil)
1800 append-list delete-list crossed
1801 update-thread update-top-list
1802 expunged mes entity)
1805 (unless wl-summary-buffer-elmo-folder
1806 (error "(Internal error) Folder is not set:%s" (buffer-name
1808 ;; Flush pending append operations (disconnected operation).
1810 ;;(wl-summary-flush-pending-append-operations seen-list))
1811 (goto-char (point-max))
1812 (wl-folder-confirm-existence folder (elmo-folder-plugged-p folder))
1813 (setq crossed (elmo-folder-synchronize folder
1820 (if sync-all (wl-summary-sync-all-init))
1821 (setq diff (elmo-list-diff (elmo-folder-list-messages
1823 (not disable-killed)
1825 wl-summary-buffer-number-list))
1826 (setq append-list (car diff))
1827 (setq delete-list (cadr diff))
1830 (wl-summary-delete-messages-on-buffer delete-list))
1831 (unless wl-summary-lazy-update-mark
1832 (wl-summary-update-status-marks (point-min) (point-max)))
1833 (when (and wl-summary-lazy-highlight
1834 wl-summary-lazy-update-mark)
1835 (let (buffer-read-only)
1836 (put-text-property (point-min) (point-max) 'face nil))
1837 (run-hooks 'wl-summary-buffer-window-scroll-functions))
1838 (setq num (length append-list))
1840 (setq wl-summary-delayed-update nil)
1841 (elmo-kill-buffer wl-summary-search-buf-name)
1842 (dolist (number append-list)
1843 (setq entity (elmo-message-entity folder number))
1844 (when (setq update-thread
1845 (wl-summary-insert-message
1848 (wl-append update-top-list update-thread))
1849 (if elmo-use-database
1850 (elmo-database-msgid-put
1851 (car entity) (elmo-folder-name-internal folder)
1852 (elmo-message-entity-number entity)))
1853 (when (> num elmo-display-progress-threshold)
1855 (if (or (zerop (% i 5)) (= i num))
1856 (elmo-display-progress
1857 'wl-summary-sync-update
1858 (if (eq wl-summary-buffer-view 'thread)
1860 "Inserting message...")
1861 (/ (* i 100) num)))))
1862 (when wl-summary-delayed-update
1863 (while wl-summary-delayed-update
1864 (message "Parent (%d) of message %d is no entity"
1865 (caar wl-summary-delayed-update)
1866 (elmo-message-entity-number
1867 (cdar wl-summary-delayed-update)))
1868 (when (setq update-thread
1869 (wl-summary-insert-message
1870 (cdar wl-summary-delayed-update)
1871 wl-summary-buffer-elmo-folder
1873 (wl-append update-top-list update-thread))
1874 (setq wl-summary-delayed-update
1875 (cdr wl-summary-delayed-update))))
1876 (when (and (eq wl-summary-buffer-view 'thread)
1878 (wl-thread-update-indent-string-thread
1879 (elmo-uniq-list update-top-list)))
1880 (message (if (eq wl-summary-buffer-view 'thread)
1881 "Making thread...done"
1882 "Inserting message...done"))
1883 (when (or delete-list append-list)
1884 (wl-summary-set-message-modified))
1885 (when (and sync-all (eq wl-summary-buffer-view 'thread))
1886 (elmo-kill-buffer wl-summary-search-buf-name)
1887 (message "Inserting message...")
1888 (wl-thread-insert-top)
1889 (message "Inserting message...done"))
1890 (if elmo-use-database
1891 (elmo-database-close))
1892 (run-hooks 'wl-summary-sync-updated-hook)
1894 (if (and (eq (length delete-list) 0)
1897 "No updates for \"%s\"" (elmo-folder-name-internal
1899 (format "Updated (-%d/+%d) message(s)"
1900 (length delete-list) num))))
1901 (setq mes "Quit updating.")))
1902 ;; synchronize marks.
1903 (if (and crossed wl-summary-auto-sync-marks)
1904 (wl-summary-sync-marks))
1906 (when wl-use-scoring
1907 (setq wl-summary-scored nil)
1908 (wl-summary-score-headers (and sync-all
1909 (wl-summary-rescore-msgs
1910 wl-summary-buffer-number-list))
1912 (when (and wl-summary-scored
1913 (setq expunged (wl-summary-score-update-all-lines)))
1914 (setq mes (concat mes
1915 (format " (%d expunged)"
1916 (length expunged))))))
1917 (if (and crossed (> crossed 0))
1921 (format " (%d crosspost)" crossed))
1922 (format "%d crosspost message(s)" crossed)))
1923 (and mes (setq mes (concat mes "."))))
1924 ;; Update Folder mode
1925 (wl-folder-set-folder-updated
1926 (elmo-folder-name-internal folder)
1928 (let ((lst (wl-summary-count-unread)))
1929 (+ (car lst) (nth 1 lst)))
1930 (elmo-folder-length folder)))
1931 (wl-summary-update-modeline)
1933 (unless unset-cursor
1934 (goto-char (point-min))
1935 (if (not (wl-summary-cursor-down t))
1937 (goto-char (point-max))
1939 (if (and wl-summary-highlight
1940 (not wl-summary-lazy-highlight)
1941 (not (get-text-property (point) 'face)))
1945 wl-summary-partial-highlight-above-lines
1946 wl-summary-highlight-partial-threshold)))
1947 (wl-highlight-summary (point) (point-max))))))
1948 (wl-delete-all-overlays)
1949 (set-buffer-modified-p nil)
1950 (if mes (message "%s" mes)))))
1952 (defun wl-summary-set-score-mark (mark)
1955 (let ((cur-mark (wl-summary-temp-mark)))
1956 (when (member cur-mark (list " "
1957 wl-summary-score-below-mark
1958 wl-summary-score-over-mark))
1959 (wl-summary-put-temp-mark mark)
1960 (if wl-summary-highlight
1961 (wl-highlight-summary-current-line))
1962 (set-buffer-modified-p nil)))))
1964 (defun wl-summary-get-score-mark (msg-num)
1965 (let ((score (cdr (assq msg-num wl-summary-scored))))
1967 (cond ((< score wl-summary-default-score)
1969 ((> score wl-summary-default-score)
1972 (defun wl-summary-update-modeline ()
1973 (setq wl-summary-buffer-mode-line
1974 (funcall wl-summary-buffer-mode-line-formatter)))
1976 (defun wl-summary-jump-to-msg (&optional number)
1978 (let ((num (or number
1980 (read-from-minibuffer "Jump to Message(No.): ")))))
1981 (setq num (int-to-string num))
1983 (if (or (and (re-search-forward (concat "\r" num "[^0-9]") nil t)
1984 (progn (backward-char 1) t))
1985 (re-search-backward (concat "\r" num "[^0-9]") nil t))
1986 (progn (beginning-of-line) t)
1989 (defun wl-summary-highlight-msgs (msgs)
1991 (let ((len (length msgs))
1993 (message "Hilighting...")
1996 (if (wl-summary-jump-to-msg (car msgs))
1997 (wl-highlight-summary-current-line))
1998 (setq msgs (cdr msgs))
1999 (when (> len elmo-display-progress-threshold)
2001 (if (or (zerop (% i 5)) (= i len))
2002 (elmo-display-progress
2003 'wl-summary-highlight-msgs "Highlighting..."
2004 (/ (* i 100) len)))))
2005 (message "Highlighting...done"))))
2007 (defun wl-summary-message-number ()
2010 (if (or (re-search-forward "\r\\(-?[0-9]+\\)" (point-at-eol) t)
2011 (re-search-forward "^ *\\(-?[0-9]+\\)" (point-at-eol) t))
2012 (string-to-int (wl-match-buffer 1))
2015 (defun wl-summary-delete-all-msgs ()
2017 (let ((cur-buf (current-buffer))
2018 (dels (elmo-folder-list-messages wl-summary-buffer-elmo-folder)))
2019 (set-buffer cur-buf)
2021 (message "No message to delete.")
2022 (if (y-or-n-p (format "%s has %d message(s). Delete all? "
2023 (wl-summary-buffer-folder-name)
2026 (message "Deleting...")
2027 (elmo-folder-move-messages wl-summary-buffer-elmo-folder dels
2029 (wl-summary-set-message-modified)
2030 (wl-folder-set-folder-updated (wl-summary-buffer-folder-name)
2033 ;;; (setq wl-thread-top-entity '(nil t nil nil))
2034 (setq wl-summary-buffer-unread-count 0)
2035 (setq wl-summary-buffer-new-count 0)
2036 (wl-summary-update-modeline)
2037 (set-buffer cur-buf)
2038 (let ((inhibit-read-only t)
2039 (buffer-read-only nil))
2041 ;;; (if wl-summary-cache-use (wl-summary-save-view-cache))
2042 (message "Deleting...done")
2046 (defun wl-summary-toggle-thread (&optional arg)
2047 "Toggle thread status (T)hread and (S)equential.
2048 If ARG, without confirm."
2051 (y-or-n-p (format "Toggle threading? (y=%s): "
2052 (if (eq wl-summary-buffer-view 'thread)
2053 "\"off\"" "\"on\""))))
2054 (if (eq wl-summary-buffer-view 'thread)
2055 (setq wl-summary-buffer-view 'sequence)
2056 (setq wl-summary-buffer-view 'thread))
2057 (wl-summary-update-modeline)
2058 (force-mode-line-update)
2059 (wl-summary-rescan)))
2061 (defun wl-summary-load-file-object (filename)
2062 "Load lisp object from dir."
2064 (let ((tmp-buffer (get-buffer-create " *wl-summary-load-file-object*"))
2065 insert-file-contents-pre-hook ; To avoid autoconv-xmas...
2066 insert-file-contents-post-hook
2068 (if (not (file-readable-p filename))
2070 (set-buffer tmp-buffer)
2071 (as-binary-input-file (insert-file-contents filename))
2074 (read (current-buffer))
2075 (error (error "Reading failed")))))
2076 (kill-buffer tmp-buffer)
2079 (defun wl-summary-goto-folder (&optional arg)
2081 (wl-summary-goto-folder-subr nil nil nil nil t nil arg))
2083 (defun wl-summary-goto-folder-sticky ()
2085 (wl-summary-goto-folder-subr nil nil nil t t))
2087 (defun wl-summary-goto-last-visited-folder ()
2090 (wl-folder-search-entity-by-name wl-summary-last-visited-folder
2093 (if entity (wl-folder-set-current-entity-id
2094 (wl-folder-get-entity-id entity))))
2095 (wl-summary-goto-folder-subr wl-summary-last-visited-folder nil nil nil t))
2097 (defun wl-summary-sticky-p (&optional folder)
2099 (get-buffer (wl-summary-sticky-buffer-name
2100 (elmo-folder-name-internal folder)))
2101 (not (string= wl-summary-buffer-name (buffer-name)))))
2103 (defun wl-summary-always-sticky-folder-p (folder)
2104 (or (eq t wl-summary-always-sticky-folder-list)
2105 (wl-string-match-member
2106 (elmo-folder-name-internal folder)
2107 wl-summary-always-sticky-folder-list)))
2109 (defun wl-summary-stick (&optional force)
2110 "Make current summary buffer sticky."
2112 (if (wl-summary-sticky-p)
2113 (message "Current summary buffer is already sticky.")
2114 (when (or force (y-or-n-p "Stick current summary buffer? "))
2115 (wl-summary-toggle-disp-msg 'off)
2116 (wl-summary-switch-to-clone-buffer
2117 (wl-summary-sticky-buffer-name
2118 (wl-summary-buffer-folder-name)))
2120 ;;; (rename-buffer (wl-summary-sticky-buffer-name
2121 ;;; (wl-summary-buffer-folder-name))))
2122 (message "Folder `%s' is now sticky." (wl-summary-buffer-folder-name)))))
2124 (defun wl-summary-switch-to-clone-buffer (buffer-name)
2125 (let ((cur-buf (current-buffer))
2126 (msg (wl-summary-message-number))
2127 (buf (get-buffer-create buffer-name))
2128 (folder wl-summary-buffer-elmo-folder)
2130 (append '(wl-summary-buffer-view
2131 wl-summary-buffer-temp-mark-list
2132 wl-summary-buffer-target-mark-list
2133 wl-summary-buffer-elmo-folder
2134 wl-summary-buffer-number-column
2135 wl-summary-buffer-temp-mark-column
2136 wl-summary-buffer-persistent-mark-column
2137 wl-summary-buffer-message-modified
2138 wl-summary-buffer-thread-modified
2139 wl-summary-buffer-number-list
2140 wl-summary-buffer-unsync-mark-number-list
2141 wl-summary-buffer-folder-name
2142 wl-summary-buffer-line-formatter)
2143 (and (eq wl-summary-buffer-view 'thread)
2144 '(wl-thread-entity-hashtb
2146 wl-thread-entity-list))
2149 wl-summary-default-score
2150 wl-summary-important-above
2151 wl-summary-target-above
2152 wl-summary-mark-below
2153 wl-summary-expunge-below))
2154 (and (featurep 'wl-score)
2155 '(wl-current-score-file
2159 (wl-summary-buffer-set-folder folder)
2160 (let ((buffer-read-only nil))
2161 (insert-buffer cur-buf))
2162 (set-buffer-modified-p nil)
2163 (while copy-variables
2164 (set (car copy-variables)
2166 (set-buffer cur-buf)
2167 (symbol-value (car copy-variables))))
2168 (setq copy-variables (cdr copy-variables)))
2169 (switch-to-buffer buf)
2170 (kill-buffer cur-buf)
2171 (wl-summary-count-unread)
2172 (wl-summary-update-modeline)
2174 (if (eq wl-summary-buffer-view 'thread)
2175 (wl-thread-jump-to-msg msg)
2176 (wl-summary-jump-to-msg msg))
2177 (goto-char (point-max))
2178 (beginning-of-line))))
2180 (defun wl-summary-get-buffer (folder)
2182 (get-buffer (wl-summary-sticky-buffer-name folder)))
2183 (get-buffer wl-summary-buffer-name)))
2185 (defun wl-summary-get-buffer-create (name &optional force-sticky)
2188 (wl-summary-sticky-buffer-name name))
2189 (or (get-buffer (wl-summary-sticky-buffer-name name))
2190 (get-buffer-create wl-summary-buffer-name))))
2192 (defun wl-summary-make-number-list ()
2194 (goto-char (point-min))
2195 (setq wl-summary-buffer-number-list nil)
2197 (setq wl-summary-buffer-number-list
2198 (cons (wl-summary-message-number)
2199 wl-summary-buffer-number-list))
2201 (setq wl-summary-buffer-number-list
2202 (nreverse wl-summary-buffer-number-list))))
2204 (defun wl-summary-auto-select-msg-p (unread-msg)
2206 (not (elmo-message-flagged-p wl-summary-buffer-elmo-folder
2210 (defsubst wl-summary-open-folder (folder)
2212 (let ((elmo-mime-charset wl-summary-buffer-mime-charset))
2214 (elmo-folder-open folder 'load-msgdb)
2215 ;; For compatibility
2216 (setq wl-summary-buffer-folder-name (elmo-folder-name-internal
2219 (defun wl-summary-goto-folder-subr (&optional name scan-type other-window
2220 sticky interactive scoring
2222 "Display target folder on summary."
2224 (let* ((keep-cursor (memq this-command
2225 wl-summary-keep-cursor-command))
2226 (name (or name (wl-summary-read-folder wl-default-folder)))
2227 (cur-fld wl-summary-buffer-elmo-folder)
2228 folder buf mes hilit reuse-buf
2230 (if (string= name "")
2231 (setq name wl-default-folder))
2232 (setq folder (wl-folder-get-elmo-folder name))
2233 (when (and (not (string=
2234 (and cur-fld (elmo-folder-name-internal cur-fld))
2235 (elmo-folder-name-internal folder))) ; folder is moved.
2236 (eq major-mode 'wl-summary-mode)) ; called in summary.
2237 (setq wl-summary-last-visited-folder (wl-summary-buffer-folder-name))
2238 (run-hooks 'wl-summary-exit-pre-hook)
2239 (if (or force-exit (not (wl-summary-sticky-p)))
2240 (wl-summary-cleanup-temp-marks (wl-summary-sticky-p)))
2241 (wl-summary-save-view)
2242 (elmo-folder-commit wl-summary-buffer-elmo-folder)
2243 (if (and (wl-summary-sticky-p) force-exit)
2244 (kill-buffer (current-buffer))))
2245 (setq buf (wl-summary-get-buffer-create (elmo-folder-name-internal folder)
2250 (string= (elmo-folder-name-internal folder)
2251 (wl-summary-buffer-folder-name))))
2255 (switch-to-buffer buf)
2258 (delete-other-windows))
2260 (unless (eq major-mode 'wl-summary-mode)
2262 (wl-summary-buffer-set-folder folder)
2263 (setq wl-summary-buffer-disp-msg nil)
2264 (setq wl-summary-buffer-last-displayed-msg nil)
2265 (setq wl-summary-buffer-current-msg nil)
2266 (let ((inhibit-read-only t)
2267 (buffer-read-only nil))
2269 ;; Resume summary view
2270 (if wl-summary-cache-use
2271 (let* ((dir (elmo-folder-msgdb-path folder))
2272 (cache (expand-file-name wl-summary-cache-file dir))
2273 (view (expand-file-name wl-summary-view-file dir)))
2274 (when (file-exists-p cache)
2275 (insert-file-contents-as-binary cache)
2276 (elmo-set-buffer-multibyte
2277 default-enable-multibyte-characters)
2278 (decode-mime-charset-region
2279 (point-min)(point-max)
2280 wl-summary-buffer-mime-charset 'LF))
2281 (if (file-exists-p view)
2282 (setq wl-summary-buffer-view
2283 (wl-summary-load-file-object view))
2284 (setq wl-summary-buffer-view
2285 (or (wl-get-assoc-list-value
2286 wl-summary-default-view-alist
2287 (elmo-folder-name-internal folder))
2288 wl-summary-default-view)))
2289 (wl-thread-resume-entity folder)
2290 (wl-summary-open-folder folder)
2291 (wl-summary-detect-mark-position))
2292 (setq wl-summary-buffer-view
2293 (wl-summary-load-file-object
2294 (expand-file-name wl-summary-view-file
2295 (elmo-folder-msgdb-path folder))))
2296 (wl-summary-open-folder folder)
2297 (wl-summary-detect-mark-position)
2298 (wl-summary-rescan))
2299 (wl-summary-count-unread)
2300 (wl-summary-update-modeline)))
2301 (unless (eq wl-summary-buffer-view 'thread)
2302 (wl-summary-make-number-list))
2303 (setq wl-summary-buffer-unsync-mark-number-list
2304 (copy-sequence wl-summary-buffer-number-list))
2305 (when (and wl-summary-cache-use
2306 (or (and wl-summary-check-line-format
2307 (wl-summary-line-format-changed-p))
2308 (wl-summary-view-old-p)))
2309 (wl-summary-rescan))
2310 (wl-summary-toggle-disp-msg (if wl-summary-buffer-disp-msg 'on 'off))
2311 (unless (and reuse-buf keep-cursor)
2313 (let ((wl-use-scoring
2314 (if (or scoring interactive) wl-use-scoring)))
2315 (if (and (not scan-type)
2318 (setq scan-type (wl-summary-get-sync-range folder)))
2321 (wl-summary-sync 'unset-cursor))
2322 ((eq scan-type 'all)
2323 (wl-summary-sync 'unset-cursor "all"))
2324 ((eq scan-type 'no-sync))
2325 ((eq scan-type 'rescan)
2326 (wl-summary-rescan))
2327 ((or (eq scan-type 'force-update)
2328 (eq scan-type 'update))
2329 (setq mes (wl-summary-sync-force-update
2330 'unset-cursor 'no-check)))))
2332 (switch-to-buffer buf)
2334 ;; stick always-sticky-folder
2335 (when (wl-summary-always-sticky-folder-p folder)
2336 (or (wl-summary-sticky-p) (wl-summary-stick t)))
2337 (run-hooks 'wl-summary-prepared-pre-hook)
2338 (set-buffer-modified-p nil)
2339 (goto-char (point-min))
2340 (if (wl-summary-cursor-down t)
2341 (let ((unreadp (wl-summary-next-message
2342 (wl-summary-message-number)
2344 (cond ((and wl-auto-select-first
2345 (wl-summary-auto-select-msg-p unreadp))
2346 ;; wl-auto-select-first is non-nil and
2347 ;; unreadp is non-nil but not important
2348 (setq retval 'disp-msg))
2349 ((and wl-auto-prefetch-first
2350 (wl-summary-auto-select-msg-p unreadp))
2351 ;; wl-auto-select-first is non-nil and
2352 ;; unreadp is non-nil but not important
2353 (setq retval 'prefetch-msg))
2354 ((not (wl-summary-auto-select-msg-p unreadp))
2355 ;; unreadp is nil or important
2356 (setq retval 'more-next))))
2357 (goto-char (point-max))
2358 (if (elmo-folder-plugged-p folder)
2361 (setq retval 'more-next))
2362 (if (and wl-summary-highlight
2363 (not wl-summary-lazy-highlight)
2365 (if (and wl-summary-highlight-partial-threshold
2366 (> (count-lines (point-min) (point-max))
2367 wl-summary-highlight-partial-threshold))
2372 wl-summary-partial-highlight-above-lines
2373 wl-summary-highlight-partial-threshold)))
2374 (wl-highlight-summary (point) (point-max)))
2375 (wl-highlight-summary (point-min) (point-max))))
2376 (if (eq retval 'disp-msg)
2377 (wl-summary-redisplay))
2378 (if (eq retval 'prefetch-msg)
2379 (wl-message-buffer-prefetch
2381 (wl-summary-message-number)
2382 wl-message-buffer-prefetch-depth
2384 wl-summary-buffer-mime-charset))
2385 (if mes (message "%s" mes))
2386 (if (and interactive wl-summary-recenter)
2387 (recenter (/ (- (window-height) 2) 2))))))
2388 ;; set current entity-id
2391 (wl-folder-search-entity-by-name
2392 (elmo-folder-name-internal folder)
2395 ;; entity-id is unknown.
2396 (wl-folder-set-current-entity-id
2397 (wl-folder-get-entity-id entity)))
2398 (when (and wl-summary-buffer-window-scroll-functions
2402 (run-hooks 'wl-summary-prepared-hook)
2403 (set-buffer-modified-p nil))
2406 (defun wl-summary-goto-previous-message-beginning ()
2408 (re-search-backward "\r\\(-?[0-9]+\\)" nil t)
2409 (beginning-of-line))
2411 (defun wl-summary-goto-top-of-current-thread ()
2412 (wl-summary-jump-to-msg
2413 (wl-thread-entity-get-number
2414 (wl-thread-entity-get-top-entity (wl-thread-get-entity
2415 (wl-summary-message-number))))))
2417 (defun wl-summary-goto-bottom-of-sub-thread (&optional depth)
2419 (let ((depth (or depth
2420 (wl-thread-get-depth-of-current-line))))
2422 (while (and (not (eobp))
2423 (>= (wl-thread-get-depth-of-current-line)
2426 (beginning-of-line)))
2428 (defun wl-summary-insert-line (line)
2429 "Insert LINE in the Summary."
2430 (if wl-use-highlight-mouse-line
2431 ;; remove 'mouse-face of current line.
2433 (save-excursion (beginning-of-line)(point))
2434 (save-excursion (end-of-line)(point))
2437 (if wl-use-highlight-mouse-line
2438 ;; remove 'mouse-face of current line.
2440 (save-excursion (beginning-of-line)(point))
2441 (save-excursion (end-of-line)(point))
2444 (run-hooks 'wl-summary-line-inserted-hook)))
2446 (defun wl-summary-insert-sequential (entity folder &rest args)
2448 (let ((inhibit-read-only t)
2449 (number (elmo-message-entity-number entity))
2451 (goto-char (point-max))
2452 (wl-summary-insert-line
2453 (wl-summary-create-line entity nil nil
2455 wl-summary-buffer-elmo-folder
2457 (elmo-message-cached-p
2458 wl-summary-buffer-elmo-folder
2460 (setq wl-summary-buffer-number-list
2461 (wl-append wl-summary-buffer-number-list
2462 (list (elmo-message-entity-number entity))))
2465 (defun wl-summary-default-subject-filter (subject)
2466 (setq subject (elmo-replace-in-string subject "[ \t]*\\(re\\|was\\)[:>]" ""))
2467 (setq subject (elmo-replace-in-string subject "[ \t]" ""))
2468 (elmo-replace-in-string subject "^\\[.*\\]" ""))
2470 (defun wl-summary-subject-equal (subject1 subject2)
2471 (string= (funcall wl-summary-subject-filter-function subject1)
2472 (funcall wl-summary-subject-filter-function subject2)))
2474 (defmacro wl-summary-put-alike (alike)
2475 (` (elmo-set-hash-val (format "#%d" (wl-count-lines))
2477 wl-summary-alike-hashtb)))
2479 (defmacro wl-summary-get-alike ()
2480 (` (elmo-get-hash-val (format "#%d" (wl-count-lines))
2481 wl-summary-alike-hashtb)))
2483 (defun wl-summary-insert-headers (folder func mime-decode)
2484 (let ((numbers (elmo-folder-list-messages folder 'visible t))
2486 (buffer-disable-undo (current-buffer))
2487 (make-local-variable 'wl-summary-alike-hashtb)
2488 (setq wl-summary-alike-hashtb (elmo-make-hash (* (length numbers) 2)))
2490 (elmo-set-buffer-multibyte default-enable-multibyte-characters))
2491 (while (setq ov (elmo-message-entity folder (pop numbers)))
2492 (setq this (funcall func ov))
2493 (and this (setq this (std11-unfold-string this)))
2494 (if (equal last this)
2495 (setq alike (cons ov alike))
2497 (wl-summary-put-alike alike)
2499 (setq alike (list ov)
2502 (wl-summary-put-alike alike)
2505 (decode-mime-charset-region (point-min) (point-max)
2507 (when (eq mime-decode 'mime)
2508 (eword-decode-region (point-min) (point-max))))
2509 (run-hooks 'wl-summary-insert-headers-hook)))
2511 (defun wl-summary-search-by-subject (entity folder)
2512 (let ((summary-buf (current-buffer))
2513 (buf (get-buffer-create wl-summary-search-buf-name))
2514 (folder-name (wl-summary-buffer-folder-name))
2515 match founds result)
2516 (with-current-buffer buf
2517 (let ((case-fold-search t))
2518 (when (or (not (string= wl-summary-search-buf-folder-name folder-name))
2519 (zerop (buffer-size)))
2520 (setq wl-summary-search-buf-folder-name folder-name)
2521 (message "Creating subject cache...")
2522 (wl-summary-insert-headers
2526 (funcall wl-summary-subject-filter-function
2527 (elmo-message-entity-field x 'subject))))
2529 (message "Creating subject cache...done"))
2530 (setq match (funcall wl-summary-subject-filter-function
2531 (elmo-message-entity-field entity 'subject
2533 (if (string= match "")
2535 (goto-char (point-max))
2536 (while (and (null result)
2537 (not (= (point) (point-min)))
2538 (search-backward match nil t))
2539 ;; check exactly match
2540 (when (and (bolp) (= (point-at-eol)(match-end 0)))
2541 (setq founds (wl-summary-get-alike))
2542 (with-current-buffer summary-buf
2545 ;; the first element of found-entity list exists on
2547 (wl-thread-get-entity
2548 (elmo-message-entity-number (car founds)))
2549 ;; message id is not same as myself.
2551 (elmo-message-entity-field entity 'message-id)
2552 (elmo-message-entity-field (car founds)
2554 ;; not a descendant.
2555 (not (wl-thread-descendant-p
2556 (elmo-message-entity-number entity)
2557 (elmo-message-entity-number (car founds)))))
2558 (setq result (car founds)
2560 (setq founds (cdr founds))))))
2563 (defun wl-summary-insert-thread (entity folder update
2564 &optional force-insert)
2566 this-id parent-entity parent-number relatives anumber
2567 cur number cur-entity linked retval delayed-entity
2568 update-list entity-stack thread-entity)
2570 (setq this-id (elmo-message-entity-field entity 'message-id)
2571 number (elmo-message-entity-number entity))
2572 (if (and wl-thread-saved-entity-hashtb-internal
2575 (format "#%d" (elmo-message-entity-number entity))
2576 wl-thread-saved-entity-hashtb-internal)))
2578 (elmo-message-entity
2580 (wl-thread-entity-get-parent thread-entity))
2581 linked (wl-thread-entity-get-linked thread-entity))
2582 (setq parent-entity (elmo-message-entity-parent folder entity)
2584 (setq parent-number (and parent-entity
2585 (elmo-message-entity-number parent-entity)))
2587 ;; If thread loop detected, set parent as nil.
2590 (elmo-message-entity-number
2591 (setq cur (elmo-message-entity-parent folder cur))))
2592 (if (memq anumber relatives)
2593 (setq parent-number nil
2595 (setq relatives (cons anumber relatives))))
2596 (if (and parent-number
2597 (not (wl-thread-get-entity parent-number))
2599 ;; parent exists in overview, but not in wl-thread-entities
2601 (wl-append wl-summary-delayed-update
2602 (list (cons parent-number entity)))
2603 (setq entity nil)) ;; exit loop
2604 ;; Search parent by subject.
2605 (when (and (null parent-number)
2606 wl-summary-search-parent-by-subject-regexp
2608 wl-summary-search-parent-by-subject-regexp
2609 (elmo-message-entity-field entity 'subject)))
2610 (let ((found (wl-summary-search-by-subject entity folder)))
2612 (not (member found wl-summary-delayed-update)))
2613 (setq parent-entity found)
2615 (elmo-message-entity-number parent-entity))
2617 ;; If subject is change, divide thread.
2618 (if (and parent-number
2619 wl-summary-divide-thread-when-subject-changed
2620 (not (wl-summary-subject-equal
2621 (or (elmo-message-entity-field entity
2623 (or (elmo-message-entity-field parent-entity
2625 (setq parent-number nil))
2627 (wl-thread-insert-message entity
2628 number parent-number update linked))
2630 (wl-append update-list (list retval)))
2631 (setq entity nil) ; exit loop
2632 (while (setq delayed-entity (assq number wl-summary-delayed-update))
2633 (setq wl-summary-delayed-update
2634 (delq delayed-entity wl-summary-delayed-update))
2635 ;; update delayed message
2636 (wl-append entity-stack (list (cdr delayed-entity)))))
2637 (if (and (not entity)
2639 (setq entity (pop entity-stack))))
2642 (defun wl-summary-update-thread (entity
2645 (let* ((this-id (elmo-message-entity-field entity 'message-id))
2646 (overview-entity entity)
2647 (parent-id (elmo-message-entity-field parent-entity 'message-id))
2648 (number (elmo-message-entity-number entity))
2649 (parent-number (elmo-message-entity-number parent-entity))
2652 ((or (not parent-id)
2653 (string= this-id parent-id))
2654 (goto-char (point-max))
2656 (setq insert-line t))
2657 ;; parent already exists in buffer.
2658 ((wl-summary-jump-to-msg parent-number)
2659 (wl-thread-goto-bottom-of-sub-thread)
2660 (setq insert-line t)))
2662 (let (buffer-read-only)
2663 (wl-summary-insert-line
2664 (wl-summary-create-line
2668 (elmo-message-flags wl-summary-buffer-elmo-folder number)
2669 (elmo-message-cached-p wl-summary-buffer-elmo-folder number)
2670 (wl-thread-maybe-get-children-num number)
2671 (wl-thread-make-indent-string thr-entity)
2672 (wl-thread-entity-get-linked thr-entity)))))))
2674 (defun wl-summary-target-mark-msgs (msgs)
2675 "Return the number of marked messages."
2677 (dolist (number msgs)
2678 (when (wl-summary-target-mark number)
2682 (defun wl-summary-pick (&optional from-list delete-marks)
2685 (let* ((condition (car (elmo-parse-search-condition
2686 (elmo-read-search-condition
2687 wl-summary-pick-field-default))))
2688 (result (elmo-folder-search wl-summary-buffer-elmo-folder
2693 (let ((mlist wl-summary-buffer-target-mark-list))
2695 (when (wl-summary-jump-to-msg (car mlist))
2696 (wl-summary-unmark))
2697 (setq mlist (cdr mlist)))
2698 (setq wl-summary-buffer-target-mark-list nil)))
2700 (setq num (wl-summary-target-mark-msgs result))
2702 (if (= num (length result))
2703 (message "%d message(s) are picked." num)
2704 (message "%d(%d) message(s) are picked." num
2705 (- (length result) num)))
2706 (message "No message was picked.")))))
2708 (defun wl-summary-unvirtual ()
2709 "Exit from current virtual folder."
2712 (elmo-folder-type-internal wl-summary-buffer-elmo-folder))
2713 (wl-summary-goto-folder-subr
2714 (elmo-folder-name-internal
2715 (elmo-filter-folder-target-internal
2716 wl-summary-buffer-elmo-folder))
2718 (error "This folder is not filtered")))
2720 (defun wl-summary-virtual (&optional arg)
2721 "Goto virtual folder.
2722 If ARG, exit virtual folder."
2725 (wl-summary-unvirtual)
2726 (wl-summary-goto-folder-subr (concat "/"
2727 (elmo-read-search-condition
2728 wl-summary-pick-field-default)
2730 (wl-summary-buffer-folder-name))
2732 (run-hooks 'wl-summary-virtual-hook)))
2734 (defun wl-summary-delete-all-temp-marks (&optional no-msg force)
2735 "Erase all temp marks from buffer."
2737 (when (or wl-summary-buffer-target-mark-list
2738 wl-summary-buffer-temp-mark-list
2741 (goto-char (point-min))
2743 (message "Unmarking..."))
2745 (wl-summary-unset-mark nil nil force)
2748 (message "Unmarking...done"))
2749 (setq wl-summary-buffer-target-mark-list nil)
2750 (setq wl-summary-buffer-temp-mark-list nil))))
2752 (defsubst wl-summary-temp-mark (&optional number)
2753 "Return temp-mark string of current line."
2754 (let ((number (or number (wl-summary-message-number)))
2756 (or (and (wl-summary-have-target-mark-p number)
2758 (and (setq info (wl-summary-registered-temp-mark number))
2760 (wl-summary-get-score-mark number)
2763 (defsubst wl-summary-persistent-mark-string (folder flags cached)
2764 "Return the persistent mark string.
2765 The mark is decided according to the FOLDER, FLAGS and CACHED."
2766 (let ((priorities wl-summary-flag-priority-list)
2768 (while (and (null mark) priorities)
2769 (when (memq (car priorities) flags)
2771 (case (car priorities)
2773 wl-summary-new-mark)
2775 wl-summary-important-mark)
2778 wl-summary-answered-cached-mark
2779 wl-summary-answered-uncached-mark))
2782 wl-summary-unread-cached-mark
2783 wl-summary-unread-uncached-mark)))))
2784 (setq priorities (cdr priorities)))
2786 (if (or cached (elmo-folder-local-p folder))
2788 wl-summary-read-uncached-mark))))
2790 (defsubst wl-summary-message-mark (folder number &optional flags)
2791 "Return mark of the message."
2793 (wl-summary-persistent-mark-string
2795 (or flags (setq flags (elmo-message-flags folder number)))
2796 (memq 'cached flags) ; XXX for speed-up.
2799 (defsubst wl-summary-persistent-mark (&optional number flags)
2800 "Return persistent-mark string of current line."
2801 (or (wl-summary-message-mark wl-summary-buffer-elmo-folder
2802 (or number (wl-summary-message-number))
2806 (defun wl-summary-put-temp-mark (mark)
2807 "Put temp MARK on current line."
2808 (when wl-summary-buffer-temp-mark-column
2811 (let ((inhibit-read-only t)
2812 (buffer-read-only nil))
2813 (move-to-column wl-summary-buffer-temp-mark-column)
2814 (delete-backward-char 1)
2817 (defun wl-summary-next-buffer ()
2818 "Switch to next summary buffer."
2820 (let ((buffers (sort (wl-collect-summary)
2821 (lambda (buffer1 buffer2)
2822 (string-lessp (buffer-name buffer1)
2823 (buffer-name buffer2))))))
2825 (or (cadr (memq (current-buffer) buffers))
2828 (defun wl-summary-previous-buffer ()
2829 "Switch to previous summary buffer."
2831 (let ((buffers (sort (wl-collect-summary)
2832 (lambda (buffer1 buffer2)
2833 (not (string-lessp (buffer-name buffer1)
2834 (buffer-name buffer2)))))))
2836 (or (cadr (memq (current-buffer) buffers))
2839 (defun wl-summary-target-mark-mark-as-read ()
2842 (goto-char (point-min))
2843 (let ((inhibit-read-only t)
2844 (buffer-read-only nil)
2845 wl-summary-buffer-disp-msg)
2846 (wl-summary-mark-as-read wl-summary-buffer-target-mark-list)
2847 (dolist (number wl-summary-buffer-target-mark-list)
2848 (wl-summary-unset-mark number)))))
2850 (defun wl-summary-target-mark-mark-as-unread ()
2853 (goto-char (point-min))
2854 (let ((inhibit-read-only t)
2855 (buffer-read-only nil)
2856 wl-summary-buffer-disp-msg)
2857 (wl-summary-mark-as-unread wl-summary-buffer-target-mark-list)
2858 (dolist (number wl-summary-buffer-target-mark-list)
2859 (wl-summary-unset-mark number)))))
2861 (defun wl-summary-target-mark-mark-as-important ()
2864 (goto-char (point-min))
2865 (let ((inhibit-read-only t)
2866 (buffer-read-only nil)
2867 wl-summary-buffer-disp-msg)
2868 (dolist (number wl-summary-buffer-target-mark-list)
2869 (wl-summary-unset-mark number)
2870 (wl-summary-mark-as-important number))
2871 (wl-summary-count-unread)
2872 (wl-summary-update-modeline))))
2874 (defun wl-summary-target-mark-save ()
2877 (wl-read-directory-name "Save to directory: "
2878 wl-temporary-file-directory))
2880 (if (null (file-exists-p wl-save-dir))
2881 (make-directory wl-save-dir))
2882 (while (setq number (car wl-summary-buffer-target-mark-list))
2883 (wl-thread-jump-to-msg number)
2884 (wl-summary-save t wl-save-dir)
2885 (wl-summary-unmark))))
2887 (defun wl-summary-target-mark-pick ()
2889 (wl-summary-pick wl-summary-buffer-target-mark-list 'delete))
2891 (defun wl-summary-update-persistent-mark (&optional number flags)
2892 "Synch up persistent mark of current line with msgdb's.
2893 Return non-nil if the mark is updated"
2895 (when wl-summary-buffer-persistent-mark-column
2897 (move-to-column wl-summary-buffer-persistent-mark-column)
2898 (let ((inhibit-read-only t)
2899 (buffer-read-only nil)
2900 (mark (buffer-substring (- (point) 1) (point)))
2901 (new-mark (wl-summary-persistent-mark number flags)))
2902 (unless (string= new-mark mark)
2903 (delete-backward-char 1)
2905 (wl-summary-set-message-modified)
2907 (when wl-summary-highlight
2908 (wl-highlight-summary-current-line))
2909 (set-buffer-modified-p nil)))
2911 (defsubst wl-summary-mark-as-read-internal (inverse
2916 (let ((folder wl-summary-buffer-elmo-folder)
2917 unread-message number
2918 number-list visible)
2919 (setq number-list (cond ((numberp number-or-numbers)
2920 (setq unread-message
2921 (elmo-message-flagged-p
2925 (list number-or-numbers))
2926 ((and (not (null number-or-numbers))
2927 (listp number-or-numbers))
2929 ((setq number (wl-summary-message-number))
2931 (setq unread-message
2932 (elmo-message-flagged-p
2937 (if (null number-list)
2938 (message "No message.")
2940 (elmo-folder-unflag-read folder number-list no-folder-mark)
2941 (elmo-folder-flag-as-read folder number-list no-folder-mark))
2942 (dolist (number number-list)
2943 (setq visible (wl-summary-jump-to-msg number))
2945 (when unread-message
2946 (run-hooks 'wl-summary-unread-message-hook)))
2947 ;; set mark on buffer
2949 (wl-summary-update-persistent-mark)))
2950 (unless no-modeline-update
2951 ;; Update unread numbers.
2952 ;; should elmo-folder-flag-as-read return unread numbers?
2953 (wl-summary-count-unread)
2954 (wl-summary-update-modeline)
2955 (wl-folder-update-unread
2956 (wl-summary-buffer-folder-name)
2957 (+ wl-summary-buffer-unread-count
2958 wl-summary-buffer-new-count)))))))
2960 (defun wl-summary-mark-as-read (&optional number-or-numbers
2964 (wl-summary-mark-as-read-internal nil
2967 no-modeline-update))
2969 (defun wl-summary-mark-as-unread (&optional number-or-numbers
2973 (wl-summary-mark-as-read-internal 'inverse
2976 no-modeline-update))
2978 (defsubst wl-summary-mark-as-answered-internal (inverse
2982 (let ((folder wl-summary-buffer-elmo-folder)
2983 number number-list visible)
2984 (setq number-list (cond ((numberp number-or-numbers)
2985 (list number-or-numbers))
2986 ((and (not (null number-or-numbers))
2987 (listp number-or-numbers))
2989 ((setq number (wl-summary-message-number))
2992 (if (null number-list)
2993 (message "No message.")
2995 (elmo-folder-unflag-answered folder number-list)
2996 (elmo-folder-flag-as-answered folder number-list))
2997 (dolist (number number-list)
2998 (setq visible (wl-summary-jump-to-msg number))
2999 ;; set mark on buffer
3001 (wl-summary-update-persistent-mark)))
3002 (unless no-modeline-update
3003 ;; Update unread numbers.
3004 ;; should elmo-flag-mark-as-read return unread numbers?
3005 (wl-summary-count-unread)
3006 (wl-summary-update-modeline)
3007 (wl-folder-update-unread
3008 (wl-summary-buffer-folder-name)
3009 (+ wl-summary-buffer-unread-count
3010 wl-summary-buffer-new-count)))))))
3012 (defun wl-summary-mark-as-answered (&optional number-or-numbers
3015 (wl-summary-mark-as-answered-internal
3016 (and (interactive-p)
3017 (elmo-message-flagged-p wl-summary-buffer-elmo-folder
3018 (wl-summary-message-number)
3021 no-modeline-update))
3023 (defun wl-summary-mark-as-unanswered (&optional number-or-numbers
3025 (wl-summary-mark-as-answered-internal 'inverse
3027 no-modeline-update))
3029 (defun wl-summary-mark-as-important (&optional number
3033 (if (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
3035 (error "Cannot process mark in this folder"))
3037 (let* ((folder wl-summary-buffer-elmo-folder)
3038 message-id visible cur-mark)
3040 (setq visible (wl-summary-jump-to-msg number))
3041 (setq cur-mark (or mark
3042 (wl-summary-message-mark
3043 wl-summary-buffer-elmo-folder number)
3045 ((setq number (wl-summary-message-number))
3047 (setq cur-mark (or mark (wl-summary-persistent-mark))))
3049 (error "No message")))
3051 ;; already exists in msgdb.
3052 (elmo-message-entity wl-summary-buffer-elmo-folder
3054 (setq message-id (elmo-message-field
3055 wl-summary-buffer-elmo-folder
3058 (if (string= cur-mark wl-summary-important-mark)
3062 (elmo-folder-unflag-important folder (list number)
3064 ;; Remove cache if local folder.
3065 (if (and (elmo-folder-local-p folder)
3067 (elmo-folder-type-internal folder))))
3068 (elmo-file-cache-delete
3069 (elmo-file-cache-get-path message-id)))))
3071 (elmo-folder-flag-as-important folder (list number)
3074 (wl-summary-update-persistent-mark))))
3078 (defvar wl-summary-line-formatter nil)
3080 (defun wl-summary-view-old-p ()
3081 "Return non-nil when summary view cache has old format."
3083 (goto-char (point-min))
3084 (and wl-summary-buffer-number-list
3085 (not (re-search-forward "\r-?[0-9]+" (point-at-eol) t)))))
3087 (defun wl-summary-line-format-changed-p ()
3088 "Return non-nil when summary line format is changed."
3090 wl-summary-buffer-line-format
3091 (or (elmo-object-load (expand-file-name
3092 wl-summary-line-format-file
3093 (elmo-folder-msgdb-path
3094 wl-summary-buffer-elmo-folder))
3095 wl-summary-buffer-mime-charset)
3096 wl-summary-buffer-line-format))))
3098 (defun wl-summary-line-format-save ()
3099 "Save current summary line format."
3101 (expand-file-name wl-summary-line-format-file
3102 (elmo-folder-msgdb-path
3103 wl-summary-buffer-elmo-folder))
3104 wl-summary-buffer-line-format
3105 wl-summary-buffer-mime-charset))
3107 (defun wl-summary-line-number ()
3108 (wl-set-string-width
3109 (- wl-summary-buffer-number-column)
3111 (elmo-message-entity-number wl-message-entity))))
3113 (defun wl-summary-line-year ()
3114 (aref wl-datevec 0))
3115 (defun wl-summary-line-month ()
3116 (format "%02d" (aref wl-datevec 1)))
3117 (defun wl-summary-line-day ()
3118 (format "%02d" (aref wl-datevec 2)))
3119 (defun wl-summary-line-day-of-week ()
3121 (elmo-date-get-week (aref wl-datevec 0)
3123 (aref wl-datevec 2))
3125 (defun wl-summary-line-hour ()
3126 (format "%02d" (aref wl-datevec 3)))
3127 (defun wl-summary-line-minute ()
3128 (format "%02d" (aref wl-datevec 4)))
3130 (defun wl-summary-line-size ()
3131 (let ((size (elmo-message-entity-field wl-message-entity 'size)))
3134 ((<= 1 (/ size 1048576))
3135 (format "%.0fM" (/ size 1048576.0)))
3136 ((<= 1 (/ size 1024))
3137 (format "%.0fK" (/ size 1024.0)))
3138 (t (format "%dB" size)))
3141 (defun wl-summary-line-subject ()
3142 (let (no-parent subject parent-raw-subject parent-subject)
3143 (if (string= wl-thr-indent-string "")
3144 (setq no-parent t)) ; no parent
3146 (elmo-delete-char ?\n
3147 (or (elmo-message-entity-field
3150 wl-summary-no-subject-message)))
3151 (setq parent-raw-subject
3152 (elmo-message-entity-field wl-parent-message-entity
3154 (setq parent-subject
3155 (if parent-raw-subject
3156 (elmo-delete-char ?\n parent-raw-subject)))
3158 (null parent-subject)
3159 (not (wl-summary-subject-equal
3160 subject parent-subject)))
3161 (funcall wl-summary-subject-function subject)
3164 (defun wl-summary-line-from ()
3165 (elmo-delete-char ?\n
3166 (funcall wl-summary-from-function
3167 (elmo-message-entity-field
3171 (defun wl-summary-line-list-info ()
3172 (let ((list-info (wl-summary-get-list-info wl-message-entity)))
3174 (format (if (cdr list-info) "(%s %05.0f)" "(%s)")
3175 (car list-info) (cdr list-info))
3178 (defun wl-summary-line-list-count ()
3179 (let ((ml-count (cdr (wl-summary-get-list-info wl-message-entity))))
3181 (format "%.0f" ml-count)
3184 (defun wl-summary-line-attached ()
3185 (let ((content-type (elmo-message-entity-field
3186 wl-message-entity 'content-type))
3187 (case-fold-search t))
3188 (if (and content-type
3189 (string-match "multipart/mixed" content-type))
3194 ;;(defun wl-summary-line-cached ()
3195 ;; (if (elmo-message-cached-p wl-summary-buffer-elmo-folder
3196 ;; (elmo-message-entity-number wl-message-entity))
3200 (defun wl-summary-create-line (wl-message-entity
3201 wl-parent-message-entity
3206 wl-thr-children-number
3207 wl-thr-indent-string
3209 "Create a summary line."
3210 (let ((wl-mime-charset wl-summary-buffer-mime-charset)
3211 (wl-persistent-mark (wl-summary-persistent-mark-string
3212 wl-summary-buffer-elmo-folder
3215 (elmo-mime-charset wl-summary-buffer-mime-charset)
3216 (elmo-lang wl-summary-buffer-weekday-name-lang)
3217 (wl-datevec (or (ignore-errors (timezone-fix-time
3218 (elmo-message-entity-field
3222 wl-summary-fix-timezone))
3224 (entity wl-message-entity) ; backward compatibility.
3226 (if (and wl-thr-indent-string
3227 wl-summary-indent-length-limit
3228 (< wl-summary-indent-length-limit
3229 (string-width wl-thr-indent-string)))
3230 (setq wl-thr-indent-string (wl-set-string-width
3231 wl-summary-indent-length-limit
3232 wl-thr-indent-string)))
3233 (setq line (funcall wl-summary-buffer-line-formatter))
3234 (if wl-summary-width (setq line
3235 (wl-set-string-width
3236 (- wl-summary-width 1) line nil
3238 (setq line (concat line
3241 (elmo-message-entity-number
3242 wl-message-entity))))
3243 (if wl-summary-highlight
3244 (wl-highlight-summary-line-string
3245 (elmo-message-entity-number wl-message-entity)
3249 wl-thr-indent-string))
3252 (defsubst wl-summary-proc-wday (wday-str year month mday)
3254 (if (string-match "\\([A-Z][a-z][a-z]\\).*" wday-str)
3255 (wl-match-string 1 wday-str)
3256 (elmo-date-get-week year month mday))))
3258 (defvar wl-summary-move-spec-alist
3263 (unread . ((t . nil)
3267 (defsubst wl-summary-next-message (num direction hereto)
3268 (if wl-summary-buffer-next-message-function
3269 (funcall wl-summary-buffer-next-message-function num direction hereto)
3270 (let ((cur-spec (cdr (assq wl-summary-move-order
3271 wl-summary-move-spec-alist)))
3272 (nums (memq num (if (eq direction 'up)
3273 (reverse wl-summary-buffer-number-list)
3274 wl-summary-buffer-number-list)))
3276 (unless hereto (setq nums (cdr nums)))
3282 (cond ((eq (car (car cur-spec)) 'p)
3283 (if (setq flagged-list
3284 (elmo-folder-list-flagged
3285 wl-summary-buffer-elmo-folder
3286 (cdr (car cur-spec))))
3288 (if (and (memq (car nums) flagged-list)
3289 (elmo-message-accessible-p
3290 wl-summary-buffer-elmo-folder
3292 (throw 'done (car nums)))
3293 (setq nums (cdr nums)))))
3294 ((eq (car (car cur-spec)) 't)
3295 (if wl-summary-buffer-target-mark-list
3297 (if (memq (car nums)
3298 wl-summary-buffer-target-mark-list)
3299 (throw 'done (car nums)))
3300 (setq nums (cdr nums))))))
3301 (setq cur-spec (cdr cur-spec))))
3304 (defsubst wl-summary-cursor-move (direction hereto)
3305 (when (and (eq direction 'up)
3310 (when (setq num (wl-summary-next-message (wl-summary-message-number)
3313 (wl-thread-jump-to-msg num))
3316 ;; Goto unread or important
3317 ;; returns t if next message exists in this folder.
3318 (defun wl-summary-cursor-down (&optional hereto)
3320 (wl-summary-cursor-move 'down hereto))
3322 (defun wl-summary-cursor-up (&optional hereto)
3324 (wl-summary-cursor-move 'up hereto))
3326 (defun wl-summary-save-view-cache ()
3328 (let* ((dir (elmo-folder-msgdb-path wl-summary-buffer-elmo-folder))
3329 (cache (expand-file-name wl-summary-cache-file dir))
3330 (view (expand-file-name wl-summary-view-file dir))
3331 (save-view wl-summary-buffer-view)
3332 (mark-list (copy-sequence wl-summary-buffer-target-mark-list))
3333 (temp-list (copy-sequence wl-summary-buffer-temp-mark-list))
3334 (tmp-buffer (get-buffer-create " *wl-summary-save-view-cache*"))
3335 (temp-column wl-summary-buffer-temp-mark-column)
3336 (charset wl-summary-buffer-mime-charset))
3338 (if (file-directory-p dir)
3340 (if (file-exists-p dir)
3341 (error "File %s already exists" dir)
3342 (elmo-make-directory dir)))
3343 (if (eq save-view 'thread)
3344 (wl-thread-save-entity dir))
3345 (when wl-summary-check-line-format
3346 (wl-summary-line-format-save))
3349 (when (file-writable-p cache)
3350 (copy-to-buffer tmp-buffer (point-min) (point-max))
3351 (with-current-buffer tmp-buffer
3353 (make-local-variable 'wl-summary-highlight)
3354 (setq wl-summary-highlight nil
3355 wl-summary-buffer-target-mark-list mark-list
3356 wl-summary-buffer-temp-mark-list temp-list
3357 wl-summary-buffer-temp-mark-column temp-column)
3358 (wl-summary-delete-all-temp-marks 'no-msg 'force)
3359 (encode-coding-region
3360 (point-min) (point-max)
3362 ;; one in mcs-ltn1(apel<10.4) cannot take 2 arg.
3363 (mime-charset-to-coding-system charset 'LF))
3364 ;; Mule 2 doesn't have `*ctext*unix'.
3365 (mime-charset-to-coding-system charset)))
3366 (write-region-as-binary (point-min)(point-max)
3367 cache nil 'no-msg)))
3368 (when (file-writable-p view) ; 'thread or 'sequence
3370 (set-buffer tmp-buffer)
3372 (prin1 save-view tmp-buffer)
3373 (princ "\n" tmp-buffer)
3374 (write-region (point-min) (point-max) view nil 'no-msg))))
3376 (kill-buffer tmp-buffer))))))
3378 (defsubst wl-summary-get-sync-range (folder)
3380 (elmo-folder-plugged-p folder)
3381 (wl-get-assoc-list-value
3382 wl-folder-sync-range-alist
3383 (elmo-folder-name-internal folder)
3385 wl-default-sync-range)))
3387 ;; redefined for wl-summary-sync-update
3388 (defun wl-summary-input-range (folder)
3389 "returns update or all or rescan."
3390 ;; for the case when parts are expanded in the bottom of the folder
3391 (let ((input-range-list '("no-sync"
3403 (default (or (wl-get-assoc-list-value
3404 wl-folder-sync-range-alist
3407 wl-default-sync-range))
3410 (completing-read (format "Range (%s): " default)
3412 (function (lambda (x) (cons x x)))
3414 (if (string= range "")
3418 (defun wl-summary-toggle-disp-folder (&optional arg)
3420 (let ((cur-buf (current-buffer))
3421 (summary-win (get-buffer-window (current-buffer)))
3425 (setq wl-summary-buffer-disp-folder t)
3426 ;; hide your folder window
3427 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
3428 (if (setq fld-win (get-buffer-window fld-buf))
3429 (delete-window fld-win))))
3431 (setq wl-summary-buffer-disp-folder nil)
3432 ;; hide your wl-message window!
3433 (when (buffer-live-p wl-message-buffer)
3434 (wl-message-select-buffer wl-message-buffer)
3436 (select-window (get-buffer-window cur-buf))
3437 ;; display wl-folder window!!
3438 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
3439 (if (setq fld-win (get-buffer-window fld-buf))
3440 ;; folder win is already displayed.
3441 (select-window fld-win)
3442 ;; folder win is not displayed.
3443 (switch-to-buffer fld-buf))
3446 ;; temporarily delete summary-win.
3448 (delete-window summary-win))
3449 (split-window-horizontally wl-folder-window-width)
3451 (switch-to-buffer cur-buf))
3453 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
3454 (if (setq fld-win (get-buffer-window fld-buf))
3455 (setq wl-summary-buffer-disp-folder nil)
3456 (setq wl-summary-buffer-disp-folder t)))
3457 (if (not wl-summary-buffer-disp-folder)
3458 ;; hide message window
3459 (let ((mes-win (and wl-message-buffer
3460 (get-buffer-window wl-message-buffer)))
3461 (wl-stay-folder-window t))
3462 (if mes-win (delete-window mes-win))
3463 ;; hide your folder window
3464 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
3465 (if (setq fld-win (get-buffer-window fld-buf))
3467 (delete-window (get-buffer-window cur-buf))
3468 (select-window fld-win)
3469 (switch-to-buffer cur-buf))))
3470 (run-hooks 'wl-summary-toggle-disp-folder-off-hook)
3471 ;; resume message window.
3473 (wl-message-select-buffer wl-message-buffer)
3474 (run-hooks 'wl-summary-toggle-disp-folder-message-resumed-hook)
3475 (select-window (get-buffer-window cur-buf))))
3476 ;; hide message window
3477 (let ((wl-stay-folder-window t)
3478 (mes-win (and wl-message-buffer
3479 (get-buffer-window wl-message-buffer))))
3480 (if mes-win (delete-window mes-win))
3481 (select-window (get-buffer-window cur-buf))
3482 ;; display wl-folder window!!
3483 (if (setq fld-buf (get-buffer wl-folder-buffer-name))
3484 (if (setq fld-win (get-buffer-window fld-buf))
3485 ;; folder win is already displayed.
3486 (select-window fld-win)
3487 ;; folder win is not displayed...occupy all.
3488 (switch-to-buffer fld-buf))
3491 (split-window-horizontally wl-folder-window-width)
3493 (switch-to-buffer cur-buf)
3494 ;; resume message window.
3495 (run-hooks 'wl-summary-toggle-disp-folder-on-hook)
3497 (wl-message-select-buffer wl-message-buffer)
3498 (run-hooks 'wl-summary-toggle-disp-folder-message-resumed-hook)
3499 (select-window (get-buffer-window cur-buf))))))))
3500 (run-hooks 'wl-summary-toggle-disp-folder-hook))
3502 (defun wl-summary-toggle-disp-msg (&optional arg)
3504 (let ((cur-buf (current-buffer))
3509 (setq wl-summary-buffer-disp-msg t)
3511 ;; hide your folder window
3512 (if (and (not wl-stay-folder-window)
3513 (setq fld-buf (get-buffer wl-folder-buffer-name)))
3514 (if (setq fld-win (get-buffer-window fld-buf))
3515 (unless (one-window-p fld-win)
3516 (delete-window fld-win))))))
3518 (wl-delete-all-overlays)
3519 (setq wl-summary-buffer-disp-msg nil)
3521 (when (buffer-live-p wl-message-buffer)
3522 (wl-message-select-buffer wl-message-buffer)
3524 (and (get-buffer-window cur-buf)
3525 (select-window (get-buffer-window cur-buf))))
3526 (run-hooks 'wl-summary-toggle-disp-off-hook)))
3528 (if (and wl-message-buffer
3529 (get-buffer-window wl-message-buffer)) ; already displayed
3530 (setq wl-summary-buffer-disp-msg nil)
3531 (setq wl-summary-buffer-disp-msg t))
3532 (if wl-summary-buffer-disp-msg
3534 (wl-summary-redisplay)
3535 ;;; hide your folder window
3536 ;;; (setq fld-buf (get-buffer wl-folder-buffer-name))
3537 ;;; (if (setq fld-win (get-buffer-window fld-buf))
3538 ;;; (delete-window fld-win)))
3539 (run-hooks 'wl-summary-toggle-disp-on-hook))
3540 (wl-delete-all-overlays)
3542 (wl-message-select-buffer wl-message-buffer)
3544 (select-window (get-buffer-window cur-buf))
3545 (setq wl-message-buffer nil)
3546 (run-hooks 'wl-summary-toggle-disp-off-hook))
3547 ;;; (switch-to-buffer cur-buf)
3549 (run-hooks 'wl-summary-buffer-window-scroll-functions)))
3551 (defun wl-summary-next-line-content ()
3552 "Show next line of the message."
3554 (let ((cur-buf (current-buffer)))
3555 (wl-summary-toggle-disp-msg 'on)
3556 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
3557 (set-buffer cur-buf)
3558 (wl-message-next-page 1))))
3560 (defun wl-summary-prev-line-content ()
3562 (let ((cur-buf (current-buffer)))
3563 (wl-summary-toggle-disp-msg 'on)
3564 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
3565 (set-buffer cur-buf)
3566 (wl-message-prev-page 1))))
3568 (defun wl-summary-next-page ()
3570 (let ((cur-buf (current-buffer)))
3571 (wl-summary-toggle-disp-msg 'on)
3572 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
3573 (set-buffer cur-buf)
3574 (wl-message-next-page))))
3576 (defun wl-summary-prev-page ()
3578 (let ((cur-buf (current-buffer)))
3579 (wl-summary-toggle-disp-msg 'on)
3580 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
3581 (set-buffer cur-buf)
3582 (wl-message-prev-page))))
3584 (defsubst wl-summary-no-mime-p (folder)
3585 (wl-string-match-member (elmo-folder-name-internal folder)
3586 wl-summary-no-mime-folder-list))
3588 (defun wl-summary-set-message-buffer-or-redisplay (&rest args)
3589 "Set message buffer.
3590 If message is not displayed yet, display it.
3591 Return t if message exists."
3592 (let ((folder wl-summary-buffer-elmo-folder)
3593 (number (wl-summary-message-number))
3594 cur-folder cur-number message-last-pos)
3595 (when (buffer-live-p wl-message-buffer)
3596 (save-window-excursion
3597 (wl-message-select-buffer wl-message-buffer)
3598 (setq cur-folder wl-message-buffer-cur-folder)
3599 (setq cur-number wl-message-buffer-cur-number)))
3600 (if (and (string= (elmo-folder-name-internal folder) (or cur-folder ""))
3601 (eq number (or cur-number 0)))
3603 (set-buffer wl-message-buffer)
3605 (if (wl-summary-no-mime-p folder)
3606 (wl-summary-redisplay-no-mime-internal folder number)
3607 (wl-summary-redisplay-internal folder number))
3608 (when (buffer-live-p wl-message-buffer)
3609 (set-buffer wl-message-buffer))
3612 (defun wl-summary-target-mark-forward (&optional arg)
3614 (let ((mlist (nreverse wl-summary-buffer-target-mark-list))
3615 (summary-buf (current-buffer))
3616 (wl-draft-forward t)
3619 (wl-summary-jump-to-msg (car mlist))
3620 (wl-summary-forward t)
3621 (setq start-point (point))
3622 (setq draft-buf (current-buffer))
3623 (setq mlist (cdr mlist))
3624 (save-window-excursion
3627 (set-buffer summary-buf)
3628 (wl-summary-jump-to-msg (car mlist))
3629 (wl-summary-redisplay)
3630 (set-buffer draft-buf)
3631 (goto-char (point-max))
3632 (wl-draft-insert-message)
3633 (setq mlist (cdr mlist)))
3634 (wl-draft-body-goto-top)
3635 (wl-draft-enclose-digest-region (point) (point-max)))
3636 (goto-char start-point)
3638 (set-buffer summary-buf)
3639 (wl-summary-delete-all-temp-marks)))
3640 (run-hooks 'wl-mail-setup-hook)))
3642 (defun wl-summary-target-mark-reply-with-citation (&optional arg)
3644 (let ((mlist (nreverse wl-summary-buffer-target-mark-list))
3645 (summary-buf (current-buffer))
3646 change-major-mode-hook
3649 (wl-summary-jump-to-msg (car mlist))
3650 (when (wl-summary-reply arg t)
3651 (goto-char (point-max))
3652 (setq start-point (point-marker))
3653 (setq draft-buf (current-buffer))
3654 (save-window-excursion
3656 (set-buffer summary-buf)
3657 (delete-other-windows)
3658 (wl-summary-jump-to-msg (car mlist))
3659 (wl-summary-redisplay)
3660 (set-buffer draft-buf)
3661 (goto-char (point-max))
3662 (wl-draft-yank-original)
3663 (setq mlist (cdr mlist)))
3664 (goto-char start-point)
3666 (set-buffer summary-buf)
3667 (wl-summary-delete-all-temp-marks)))
3668 (wl-draft-reply-position wl-draft-reply-default-position)
3669 (run-hooks 'wl-mail-setup-hook))))
3671 (defun wl-summary-reply-with-citation (&optional arg)
3673 (when (wl-summary-reply arg t)
3674 (goto-char (point-max))
3675 (wl-draft-yank-original)
3676 (wl-draft-reply-position wl-draft-reply-default-position)
3677 (run-hooks 'wl-mail-setup-hook)))
3679 (defun wl-summary-jump-to-msg-by-message-id (&optional id)
3681 (let* ((original (wl-summary-message-number))
3682 (msgid (elmo-string (or id (read-from-minibuffer "Message-ID: "))))
3683 (entity (elmo-message-entity wl-summary-buffer-elmo-folder msgid))
3685 (errmsg (format "No message with id \"%s\" in the folder." msgid)))
3686 (if (setq msg (elmo-message-entity-number entity))
3688 (wl-thread-jump-to-msg msg)
3691 (if (and elmo-use-database
3694 "No message with id \"%s\" in the database." msgid))
3695 (setq otherfld (elmo-database-msgid-get msgid)))
3696 (if (cdr (wl-summary-jump-to-msg-internal
3697 (car otherfld) (nth 1 otherfld) 'no-sync))
3699 ;; Back to original.
3700 (wl-summary-jump-to-msg-internal
3701 (wl-summary-buffer-folder-name) original 'no-sync))
3702 (cond ((eq wl-summary-search-via-nntp 'confirm)
3703 (require 'elmo-nntp)
3704 (message "Search message in nntp server \"%s\" <y/n/s(elect)>? "
3705 elmo-nntp-default-server)
3706 (setq schar (let ((cursor-in-echo-area t)) (read-char)))
3707 (cond ((eq schar ?y)
3708 (wl-summary-jump-to-msg-by-message-id-via-nntp msgid))
3710 (wl-summary-jump-to-msg-by-message-id-via-nntp
3712 (read-from-minibuffer "NNTP Server: ")))
3714 (message "%s" errmsg)
3716 ((or (eq wl-summary-search-via-nntp 'force)
3718 (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
3720 wl-summary-search-via-nntp))
3721 (wl-summary-jump-to-msg-by-message-id-via-nntp msgid))
3723 (message "%s" errmsg)
3726 (defun wl-summary-jump-to-msg-by-message-id-via-nntp (&optional id server-spec)
3728 (let* ((msgid (elmo-string (or id (read-from-minibuffer "Message-ID: "))))
3729 newsgroups folder ret
3730 user server port type spec)
3732 (if (string-match "^-" server-spec)
3733 (setq spec (wl-folder-get-elmo-folder server-spec)
3734 user (elmo-net-folder-user-internal spec)
3735 server (elmo-net-folder-server-internal spec)
3736 port (elmo-net-folder-port-internal spec)
3737 type (elmo-net-folder-stream-type-internal spec))
3738 (setq server server-spec)))
3739 (when (setq ret (elmo-nntp-get-newsgroup-by-msgid
3741 (or server elmo-nntp-default-server)
3742 (or user elmo-nntp-default-user)
3743 (or port elmo-nntp-default-port)
3744 (or type elmo-nntp-default-stream-type)))
3745 (setq newsgroups (elmo-nntp-parse-newsgroups ret))
3746 (setq folder (concat "-" (car newsgroups)
3747 (elmo-nntp-folder-postfix user server port type)))
3750 (if (wl-folder-entity-exists-p (car newsgroups)
3751 wl-folder-newsgroups-hashtb)
3753 (setq folder (concat "-" (car newsgroups)
3754 (elmo-nntp-folder-postfix
3755 user server port type)))))
3756 (setq newsgroups (cdr newsgroups)))))
3758 (wl-summary-jump-to-msg-internal folder nil 'update msgid)
3759 (message "No message id \"%s\" in nntp server \"%s\"."
3760 msgid (or server elmo-nntp-default-server))
3763 (defun wl-summary-jump-to-msg-internal (folder msg scan-type &optional msgid)
3764 (let (wl-auto-select-first entity)
3765 (if (or (string= folder (wl-summary-buffer-folder-name))
3768 "Message was found in the folder \"%s\". Jump to it? "
3772 (wl-summary-goto-folder-subr
3773 folder scan-type nil nil t)
3776 (elmo-message-entity-number
3777 (elmo-message-entity
3778 wl-summary-buffer-elmo-folder
3780 (setq entity (wl-folder-search-entity-by-name folder
3784 (wl-folder-set-current-entity-id
3785 (wl-folder-get-entity-id entity))))
3787 (message "Message was not found currently in this folder.")
3788 (setq msg (and (wl-thread-jump-to-msg msg) msg)))
3789 (cons folder msg)))))
3791 (defun wl-summary-jump-to-parent-message (arg)
3793 (let ((cur-buf (current-buffer))
3794 (disp-msg wl-summary-buffer-disp-msg)
3795 (number (wl-summary-message-number))
3796 (regexp "\\(<[^<>]*>\\)[ \t]*$")
3798 msg-id msg-num ref-list ref irt)
3800 (message "No message.")
3801 (when (eq wl-summary-buffer-view 'thread)
3802 (cond ((and arg (not (numberp arg)))
3804 (wl-thread-entity-get-number
3805 (wl-thread-entity-get-top-entity
3806 (wl-thread-get-entity number)))))
3807 ((and arg (numberp arg))
3809 (setq msg-num number)
3812 (wl-thread-entity-get-number
3813 (wl-thread-entity-get-parent-entity
3814 (wl-thread-get-entity msg-num))))
3817 (wl-thread-entity-get-number
3818 (wl-thread-entity-get-parent-entity
3819 (wl-thread-get-entity number)))))))
3820 (when (null msg-num)
3821 (wl-summary-set-message-buffer-or-redisplay)
3822 (set-buffer (wl-message-get-original-buffer))
3823 (message "Searching parent message...")
3824 (setq ref (std11-field-body "References")
3825 irt (std11-field-body "In-Reply-To"))
3827 ((and arg (not (numberp arg)) ref (not (string= ref ""))
3828 (string-match regexp ref))
3829 ;; The first message of the thread.
3830 (setq msg-id (wl-match-string 1 ref)))
3831 ;; "In-Reply-To:" has only one msg-id.
3832 ((and (null arg) irt (not (string= irt ""))
3833 (string-match regexp irt))
3834 (setq msg-id (wl-match-string 1 irt)))
3835 ((and (or (null arg) (numberp arg)) ref (not (string= ref ""))
3836 (string-match regexp ref))
3837 ;; "^" searching parent, "C-u 2 ^" looking for grandparent.
3838 (while (string-match regexp ref)
3841 (wl-match-string 1 ref))
3843 (setq ref (substring ref (match-end 0)))
3846 (if (null arg) (nth 0 ref-list) ;; previous
3847 (if (<= arg i) (nth (1- arg) ref-list)
3848 (nth i ref-list))))))
3849 (set-buffer cur-buf)
3850 (or disp-msg (wl-summary-toggle-disp-msg 'off)))
3851 (cond ((and (null msg-id) (null msg-num))
3852 (message "No parent message!")
3854 ((and msg-id (wl-summary-jump-to-msg-by-message-id msg-id))
3855 (if wl-summary-buffer-disp-msg (wl-summary-redisplay))
3856 (message "Searching parent message...done")
3858 ((and msg-num (wl-summary-jump-to-msg msg-num))
3859 (if wl-summary-buffer-disp-msg (wl-summary-redisplay))
3860 (message "Searching parent message...done")
3863 (message "Parent message was not found.")
3866 (defun wl-summary-reply (&optional arg without-setup-hook)
3867 "Reply to current message. Default is \"wide\" reply.
3868 Reply to author if invoked with ARG."
3870 (let ((folder wl-summary-buffer-elmo-folder)
3871 (number (wl-summary-message-number))
3872 (summary-buf (current-buffer))
3873 (winconf (current-window-configuration))
3877 (wl-summary-redisplay-internal folder number))
3878 (setq mes-buf wl-message-buffer)
3879 (wl-message-select-buffer wl-message-buffer)
3880 (set-buffer mes-buf)
3881 (goto-char (point-min))
3883 (when (setq mes-buf (wl-message-get-original-buffer))
3884 (wl-draft-reply mes-buf arg summary-buf number)
3885 (wl-draft-reply-position wl-draft-reply-default-position)
3886 (unless without-setup-hook
3887 (run-hooks 'wl-mail-setup-hook)))
3888 (error (set-window-configuration winconf)
3889 (signal (car err)(cdr err))))
3890 (with-current-buffer summary-buf
3891 (elmo-folder-flag-as-answered folder (list number))
3892 (wl-summary-update-persistent-mark))
3895 (defun wl-summary-write ()
3896 "Write a new draft from Summary."
3898 (wl-draft (list (cons 'To ""))
3899 nil nil nil nil (wl-summary-buffer-folder-name))
3900 (run-hooks 'wl-mail-setup-hook)
3901 (mail-position-on-field "To"))
3903 (defvar wl-summary-write-current-folder-functions
3904 '(wl-folder-get-newsgroups
3905 wl-folder-guess-mailing-list-by-refile-rule
3906 wl-folder-guess-mailing-list-by-folder-name)
3907 "Newsgroups or Mailing List address guess functions list.
3908 Call from `wl-summary-write-current-folder'.
3909 When guess function return nil, challenge next guess-function.")
3911 (defun wl-summary-write-current-folder (&optional folder)
3912 "Write message to current FOLDER's newsgroup or mailing-list.
3913 Use function list is `wl-summary-write-current-folder-functions'."
3915 ;; default FOLDER is current buffer folder
3916 (setq folder (or folder (wl-summary-buffer-folder-name)))
3917 (let ((func-list wl-summary-write-current-folder-functions)
3918 guess-list guess-func)
3920 (setq guess-list (funcall (car func-list) folder))
3921 (if (null guess-list)
3922 (setq func-list (cdr func-list))
3923 (setq guess-func (car func-list))
3924 (setq func-list nil)))
3925 (if (null guess-func)
3927 (unless (or (stringp (nth 0 guess-list))
3928 (stringp (nth 1 guess-list))
3929 (stringp (nth 2 guess-list)))
3930 (error "Invalid value return guess function `%s'"
3931 (symbol-name guess-func)))
3932 (wl-draft (list (cons 'To (nth 0 guess-list))
3933 (cons 'Cc (nth 1 guess-list))
3934 (cons 'Newsgroups (nth 2 guess-list)))
3935 nil nil nil nil folder)
3936 (run-hooks 'wl-mail-setup-hook)
3937 (mail-position-on-field "Subject"))))
3939 (defun wl-summary-forward (&optional without-setup-hook)
3942 (let ((folder wl-summary-buffer-elmo-folder)
3943 (number (wl-summary-message-number))
3944 (summary-buf (current-buffer))
3945 (wl-draft-forward t)
3949 (message "No message.")
3950 (if (and (elmo-message-use-cache-p folder number)
3951 (eq (elmo-file-cache-status
3952 (elmo-file-cache-get
3953 (elmo-message-field folder number 'message-id)))
3956 (wl-summary-redisplay-internal nil nil 'force-reload)
3957 (wl-summary-redisplay-internal folder number))
3958 (setq mes-buf wl-message-buffer)
3959 (wl-message-select-buffer mes-buf)
3960 ;; get original subject.
3963 (set-buffer summary-buf)
3965 (or (elmo-message-entity-field
3966 (elmo-message-entity folder number) 'subject 'decode)
3968 (set-buffer mes-buf)
3969 (wl-draft-forward subject summary-buf)
3970 (unless without-setup-hook
3971 (run-hooks 'wl-mail-setup-hook)))))
3973 (defun wl-summary-click (e)
3978 (defun wl-summary-read ()
3979 "Proceed reading message in the summary buffer."
3981 (let ((cur-buf (current-buffer)))
3982 (wl-summary-toggle-disp-msg 'on)
3983 (when (wl-summary-set-message-buffer-or-redisplay 'ignore-original)
3984 (set-buffer cur-buf)
3985 (if (wl-message-next-page)
3986 (wl-summary-down t)))))
3988 (defsubst wl-summary-cursor-move-surface (downward interactive)
3989 (if wl-summary-move-direction-toggle
3990 (setq wl-summary-move-direction-downward downward))
3991 (let ((start (point))
3992 (skip-tmark-regexp (wl-regexp-opt wl-summary-skip-mark-list))
3994 (column (current-column))
3995 goto-next next-entity finfo)
3998 (not (if downward (eobp) (bobp))))
4002 (setq skip (or (string-match skip-tmark-regexp
4003 (wl-summary-temp-mark))
4004 (not (elmo-message-accessible-p
4005 wl-summary-buffer-elmo-folder
4006 (wl-summary-message-number))))))
4007 (if (if downward (eobp) (and (bobp) skip)) (setq goto-next t))
4008 (if (or (eobp) (and (bobp) skip))
4010 (move-to-column column)
4013 (if wl-summary-buffer-disp-msg
4014 (wl-summary-redisplay))
4017 ((and (not downward) wl-summary-buffer-prev-folder-function)
4018 (funcall wl-summary-buffer-prev-folder-function))
4019 ((and downward wl-summary-buffer-next-folder-function)
4020 (funcall wl-summary-buffer-next-folder-function))
4022 (when wl-auto-select-next
4025 (wl-summary-get-next-folder)
4026 (wl-summary-get-prev-folder)))
4028 (setq finfo (wl-folder-get-entity-info next-entity))))
4030 '(lambda () (wl-summary-next-folder-or-exit next-entity))
4032 "No more messages. Type SPC to go to %s."
4033 (wl-summary-entity-info-msg next-entity finfo)))))))))
4035 (defun wl-summary-prev (&optional interactive)
4037 (wl-summary-cursor-move-surface nil (or interactive (interactive-p))))
4039 (defun wl-summary-next (&optional interactive)
4041 (wl-summary-cursor-move-surface t (or interactive (interactive-p))))
4043 (defun wl-summary-up (&optional interactive skip-no-unread)
4046 (if wl-summary-move-direction-toggle
4047 (setq wl-summary-move-direction-downward nil))
4048 (if (wl-summary-cursor-up)
4049 (if wl-summary-buffer-disp-msg
4050 (wl-summary-redisplay))
4053 (if wl-summary-buffer-prev-folder-function
4054 (funcall wl-summary-buffer-prev-folder-function)
4055 (let (next-entity finfo)
4056 (when wl-auto-select-next
4058 (setq next-entity (wl-summary-get-prev-unread-folder))
4060 (setq finfo (wl-folder-get-entity-info next-entity)))))
4061 (if (and skip-no-unread
4062 (eq wl-auto-select-next 'skip-no-unread))
4063 (wl-summary-next-folder-or-exit next-entity t)
4065 '(lambda () (wl-summary-next-folder-or-exit next-entity t))
4067 "No more unread messages. Type SPC to go to %s."
4068 (wl-summary-entity-info-msg next-entity finfo)))))))))
4070 (defun wl-summary-get-prev-folder ()
4071 (let ((folder-buf (get-buffer wl-folder-buffer-name))
4074 (setq cur-id (save-excursion (set-buffer folder-buf)
4075 wl-folder-buffer-cur-entity-id))
4076 (wl-folder-get-prev-folder cur-id))))
4078 (defun wl-summary-get-next-folder ()
4079 (let ((folder-buf (get-buffer wl-folder-buffer-name))
4082 (setq cur-id (save-excursion (set-buffer folder-buf)
4083 wl-folder-buffer-cur-entity-id))
4084 (wl-folder-get-next-folder cur-id))))
4086 (defun wl-summary-get-next-unread-folder ()
4087 (let ((folder-buf (get-buffer wl-folder-buffer-name))
4090 (setq cur-id (save-excursion (set-buffer folder-buf)
4091 wl-folder-buffer-cur-entity-id))
4092 (wl-folder-get-next-folder cur-id 'unread))))
4094 (defun wl-summary-get-prev-unread-folder ()
4095 (let ((folder-buf (get-buffer wl-folder-buffer-name))
4098 (setq cur-id (save-excursion (set-buffer folder-buf)
4099 wl-folder-buffer-cur-entity-id))
4100 (wl-folder-get-prev-folder cur-id 'unread))))
4102 (defun wl-summary-down (&optional interactive skip-no-unread)
4104 (if wl-summary-move-direction-toggle
4105 (setq wl-summary-move-direction-downward t))
4106 (if (wl-summary-cursor-down)
4107 (if wl-summary-buffer-disp-msg
4108 (wl-summary-redisplay))
4111 (if wl-summary-buffer-next-folder-function
4112 (funcall wl-summary-buffer-next-folder-function)
4113 (let (next-entity finfo)
4114 (when wl-auto-select-next
4115 (setq next-entity (wl-summary-get-next-unread-folder)))
4117 (setq finfo (wl-folder-get-entity-info next-entity)))
4118 (if (and skip-no-unread
4119 (eq wl-auto-select-next 'skip-no-unread))
4120 (wl-summary-next-folder-or-exit next-entity)
4122 '(lambda () (wl-summary-next-folder-or-exit next-entity))
4124 "No more unread messages. Type SPC to go to %s."
4125 (wl-summary-entity-info-msg next-entity finfo)))))))))
4127 (defun wl-summary-goto-last-displayed-msg ()
4129 (unless wl-summary-buffer-last-displayed-msg
4130 (setq wl-summary-buffer-last-displayed-msg
4131 wl-summary-buffer-current-msg))
4132 (if wl-summary-buffer-last-displayed-msg
4134 (wl-summary-jump-to-msg wl-summary-buffer-last-displayed-msg)
4135 (if wl-summary-buffer-disp-msg
4136 (wl-summary-redisplay)))
4137 (message "No last message.")))
4139 (defun wl-summary-redisplay (&optional arg)
4142 (wl-summary-no-mime-p wl-summary-buffer-elmo-folder))
4143 (wl-summary-redisplay-no-mime)
4144 (wl-summary-redisplay-internal nil nil arg)))
4146 (defsubst wl-summary-redisplay-internal (&optional folder number force-reload)
4148 (let* ((folder (or folder wl-summary-buffer-elmo-folder))
4149 (num (or number (wl-summary-message-number)))
4150 (wl-mime-charset wl-summary-buffer-mime-charset)
4151 (default-mime-charset wl-summary-buffer-mime-charset)
4152 no-folder-mark fld-buf fld-win thr-entity)
4153 (if (and wl-thread-open-reading-thread
4154 (eq wl-summary-buffer-view 'thread)
4155 (not (wl-thread-entity-get-opened
4156 (setq thr-entity (wl-thread-get-entity
4158 (wl-thread-entity-get-children thr-entity))
4159 (wl-thread-force-open))
4162 (setq wl-summary-buffer-disp-msg t)
4163 (setq wl-summary-buffer-last-displayed-msg
4164 wl-summary-buffer-current-msg)
4165 ;; hide folder window
4166 (if (and (not wl-stay-folder-window)
4167 (setq fld-buf (get-buffer wl-folder-buffer-name)))
4168 (if (setq fld-win (get-buffer-window fld-buf))
4169 (delete-window fld-win)))
4170 (setq wl-current-summary-buffer (current-buffer))
4171 (setq no-folder-mark
4172 ;; If cache is used, change folder-mark.
4173 (if (wl-message-redisplay folder num
4177 (string= (elmo-folder-name-internal
4181 ;; plugged, then leave folder-mark.
4182 (if (and (not (elmo-folder-local-p
4183 wl-summary-buffer-elmo-folder))
4184 (elmo-folder-plugged-p
4185 wl-summary-buffer-elmo-folder))
4187 (when (elmo-message-use-cache-p folder num)
4188 (elmo-message-set-cached folder num t))
4190 (if (elmo-message-flagged-p wl-summary-buffer-elmo-folder
4193 (wl-summary-mark-as-read num no-folder-mark)
4194 (wl-summary-update-persistent-mark)))
4195 (setq wl-summary-buffer-current-msg num)
4196 (when wl-summary-recenter
4197 (recenter (/ (- (window-height) 2) 2))
4198 (if (not wl-summary-indent-length-limit)
4199 (wl-horizontal-recenter)))
4200 (wl-highlight-summary-displaying)
4201 (wl-message-buffer-prefetch-next folder num
4202 wl-message-buffer-prefetch-depth
4204 wl-summary-buffer-mime-charset)
4205 (run-hooks 'wl-summary-redisplay-hook))
4206 (message "No message to display."))))
4208 (defun wl-summary-redisplay-no-mime (&optional ask-coding)
4209 "Display message without MIME decoding.
4210 If ASK-CODING is non-nil, coding-system for the message is asked."
4212 (let ((elmo-mime-display-as-is-coding-system
4214 (or (read-coding-system "Coding system: ")
4215 elmo-mime-display-as-is-coding-system)
4216 elmo-mime-display-as-is-coding-system)))
4217 (wl-summary-redisplay-no-mime-internal)))
4219 (defun wl-summary-redisplay-no-mime-internal (&optional folder number)
4220 (let* ((fld (or folder wl-summary-buffer-elmo-folder))
4221 (num (or number (wl-summary-message-number)))
4225 (setq wl-summary-buffer-disp-msg t)
4226 (setq wl-summary-buffer-last-displayed-msg
4227 wl-summary-buffer-current-msg)
4228 (setq wl-current-summary-buffer (current-buffer))
4229 (wl-message-redisplay fld num 'as-is
4230 (string= (elmo-folder-name-internal fld)
4233 (if (elmo-message-flagged-p fld num 'unread)
4234 (wl-summary-mark-as-read num); no-folder-mark)
4235 (wl-summary-update-persistent-mark)))
4236 (setq wl-summary-buffer-current-msg num)
4237 (when wl-summary-recenter
4238 (recenter (/ (- (window-height) 2) 2))
4239 (if (not wl-summary-indent-length-limit)
4240 (wl-horizontal-recenter)))
4241 (wl-highlight-summary-displaying)
4242 (run-hooks 'wl-summary-redisplay-hook))
4243 (message "No message to display.")
4244 (wl-ask-folder 'wl-summary-exit
4245 "No more messages. Type SPC to go to folder mode."))))
4247 (defun wl-summary-redisplay-all-header (&optional folder number)
4249 (let* ((fld (or folder wl-summary-buffer-elmo-folder))
4250 (num (or number (wl-summary-message-number)))
4251 (wl-mime-charset wl-summary-buffer-mime-charset)
4252 (default-mime-charset wl-summary-buffer-mime-charset))
4255 (setq wl-summary-buffer-disp-msg t)
4256 (setq wl-summary-buffer-last-displayed-msg
4257 wl-summary-buffer-current-msg)
4258 (setq wl-current-summary-buffer (current-buffer))
4259 (if (wl-message-redisplay fld num 'all-header
4260 (string= (elmo-folder-name-internal fld)
4262 (wl-summary-mark-as-read num))
4263 (setq wl-summary-buffer-current-msg num)
4264 (when wl-summary-recenter
4265 (recenter (/ (- (window-height) 2) 2))
4266 (if (not wl-summary-indent-length-limit)
4267 (wl-horizontal-recenter)))
4268 (wl-highlight-summary-displaying)
4269 (run-hooks 'wl-summary-redisplay-hook))
4270 (message "No message to display."))))
4272 (defun wl-summary-jump-to-current-message ()
4273 "Jump into Message buffer."
4275 (let (message-buf message-win)
4276 (if (setq message-buf wl-message-buffer)
4277 (if (setq message-win (get-buffer-window message-buf))
4278 (select-window message-win)
4279 (wl-message-select-buffer wl-message-buffer))
4280 (wl-summary-redisplay)
4281 (wl-message-select-buffer wl-message-buffer))))
4283 (defun wl-summary-cancel-message ()
4284 "Cancel an article on news."
4286 (if (null (wl-summary-message-number))
4287 (message "No message.")
4288 (let ((summary-buf (current-buffer))
4290 (wl-summary-set-message-buffer-or-redisplay)
4291 (if (setq message-buf (wl-message-get-original-buffer))
4292 (set-buffer message-buf))
4293 (unless (wl-message-news-p)
4294 (set-buffer summary-buf)
4295 (if (and (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
4297 (y-or-n-p "Cannot get Newsgroups. Fetch again? "))
4299 (wl-summary-redisplay t)
4300 (wl-summary-supersedes-message))
4301 (error "This is not a news article; supersedes is impossible")))
4302 (when (yes-or-no-p "Do you really want to cancel this article? ")
4303 (let (from newsgroups message-id distribution buf)
4305 (setq from (std11-field-body "from")
4306 newsgroups (std11-field-body "newsgroups")
4307 message-id (std11-field-body "message-id")
4308 distribution (std11-field-body "distribution"))
4309 ;; Make sure that this article was written by the user.
4310 (unless (wl-address-user-mail-address-p
4311 (wl-address-header-extract-address
4312 (car (wl-parse-addresses from))))
4313 (error "This article is not yours"))
4314 ;; Make control message.
4315 (setq buf (set-buffer (get-buffer-create " *message cancel*")))
4316 (setq wl-draft-buffer-cur-summary-buffer summary-buf)
4317 (buffer-disable-undo (current-buffer))
4319 (insert "Newsgroups: " newsgroups "\n"
4320 "From: " (wl-address-header-extract-address
4322 "Subject: cmsg cancel " message-id "\n"
4323 "Control: cancel " message-id "\n"
4325 (concat "Distribution: " distribution "\n")
4327 mail-header-separator "\n"
4328 wl-summary-cancel-message)
4329 (message "Canceling your message...")
4330 (wl-draft-raw-send t t) ; kill when done, force-pre-hooks.
4331 (message "Canceling your message...done")))))))
4333 (defun wl-summary-supersedes-message ()
4334 "Supersede current message."
4336 (wl-summary-toggle-disp-msg 'off)
4337 (let ((summary-buf (current-buffer))
4339 (wl-summary-set-message-buffer-or-redisplay)
4340 (if (setq message-buf (wl-message-get-original-buffer))
4341 (set-buffer message-buf))
4342 (unless (wl-message-news-p)
4343 (set-buffer summary-buf)
4344 (if (and (eq (elmo-folder-type-internal wl-summary-buffer-elmo-folder)
4346 (y-or-n-p "Cannot get Newsgroups. Fetch again? "))
4348 (wl-summary-redisplay t)
4349 (wl-summary-supersedes-message))
4350 (error "This is not a news article; supersedes is impossible")))
4352 (setq from (std11-field-body "from"))
4353 ;; Make sure that this article was written by the user.
4354 (unless (wl-address-user-mail-address-p
4355 (wl-address-header-extract-address
4356 (car (wl-parse-addresses from))))
4357 (error "This article is not yours"))
4358 (let* ((message-id (std11-field-body "message-id"))
4359 (followup-to (std11-field-body "followup-to"))
4360 (mail-default-headers
4361 (concat mail-default-headers
4362 "Supersedes: " message-id "\n"
4364 (concat "Followup-To: " followup-to "\n")))))
4365 (if message-buf (set-buffer message-buf))
4366 (wl-draft-edit-string (buffer-substring (point-min) (point-max)))))))
4368 (defun wl-summary-save (&optional arg wl-save-dir)
4369 "Save current message to disk."
4372 (num (wl-summary-message-number)))
4373 (if (null wl-save-dir)
4374 (setq wl-save-dir wl-temporary-file-directory))
4377 (setq filename (expand-file-name
4381 (null (file-exists-p filename))))
4383 (read-file-name "Save to file: " filename)))
4385 (wl-summary-set-message-buffer-or-redisplay)
4386 (set-buffer (wl-message-get-original-buffer))
4387 (if (and (null arg) (file-exists-p filename))
4388 (if (y-or-n-p "File already exists. override it? ")
4389 (write-region (point-min) (point-max) filename))
4390 (write-region (point-min) (point-max) filename)))
4391 (message "No message to save."))
4394 (defun wl-summary-save-region (beg end)
4398 (wl-summary-narrow-to-region beg end)
4399 (goto-char (point-min))
4401 (wl-read-directory-name "Save to directory: "
4402 wl-temporary-file-directory)))
4403 (if (null (file-exists-p wl-save-dir))
4404 (make-directory wl-save-dir))
4405 (if (eq wl-summary-buffer-view 'thread)
4408 (let* ((number (wl-summary-message-number))
4409 (entity (wl-thread-get-entity number)))
4410 (if (wl-thread-entity-get-opened entity)
4411 (wl-summary-save t wl-save-dir)
4413 (wl-summary-save t wl-save-dir))
4416 (wl-summary-save t wl-save-dir)
4417 (forward-line 1)))))))
4419 ;; mew-summary-pipe-message()
4420 (defun wl-summary-pipe-message (prefix command)
4421 "Send this message via pipe."
4422 (interactive (list current-prefix-arg nil))
4423 (if (null (wl-summary-message-number))
4424 (message "No message.")
4425 (setq command (read-string "Shell command on message: "
4426 wl-summary-shell-command-last))
4427 (if (y-or-n-p "Send this message to pipe? ")
4428 (wl-summary-pipe-message-subr prefix command))))
4430 (defun wl-summary-target-mark-pipe (prefix command)
4431 "Send each marked messages via pipe."
4432 (interactive (list current-prefix-arg nil))
4433 (if (null wl-summary-buffer-target-mark-list)
4434 (message "No marked message.")
4435 (setq command (read-string "Shell command on each marked message: "
4436 wl-summary-shell-command-last))
4437 (when (y-or-n-p "Send each marked message to pipe? ")
4438 (while (car wl-summary-buffer-target-mark-list)
4439 (let ((num (car wl-summary-buffer-target-mark-list)))
4440 (wl-thread-jump-to-msg num)
4441 (wl-summary-pipe-message-subr prefix command)
4442 (wl-summary-unmark))))))
4444 (defun wl-summary-pipe-message-subr (prefix command)
4446 (wl-summary-set-message-buffer-or-redisplay)
4447 (set-buffer (wl-message-get-original-buffer))
4448 (if (string= command "")
4449 (setq command wl-summary-shell-command-last))
4450 (goto-char (point-min)) ; perhaps this line won't be necessary
4452 (search-forward "\n\n"))
4453 (shell-command-on-region (point) (point-max) command nil)
4454 (setq wl-summary-shell-command-last command)))
4456 (defun wl-summary-print-message (&optional arg)
4458 (if (null (wl-summary-message-number))
4459 (message "No message.")
4461 (wl-summary-set-message-buffer-or-redisplay)
4462 (if (or (not (interactive-p))
4463 (y-or-n-p "Print ok? "))
4465 (let ((buffer (generate-new-buffer " *print*")))
4466 (copy-to-buffer buffer (point-min) (point-max))
4468 (funcall wl-print-buffer-function)
4469 (kill-buffer buffer)))
4472 (defun wl-summary-print-message-with-ps-print (&optional filename)
4473 "Print message via ps-print."
4475 (if (null (wl-summary-message-number))
4476 (message "No message.")
4477 (setq filename (ps-print-preprint current-prefix-arg))
4478 (if (or (not (interactive-p))
4479 (y-or-n-p "Print ok? "))
4480 (let ((summary-buffer (current-buffer))
4483 (wl-summary-set-message-buffer-or-redisplay)
4484 ;; (wl-summary-redisplay-internal)
4485 (let* ((buffer (generate-new-buffer " *print*"))
4487 (set-buffer summary-buffer)
4488 (elmo-message-entity
4489 wl-summary-buffer-elmo-folder
4490 (wl-summary-message-number))))
4493 (or (elmo-message-entity-field entity 'subject t)
4497 (or (elmo-message-entity-field entity 'from t) "")))
4500 (or (elmo-message-entity-field entity 'date) ""))))
4501 (run-hooks 'wl-ps-preprint-hook)
4502 (set-buffer wl-message-buffer)
4503 (copy-to-buffer buffer (point-min) (point-max))
4506 (let ((ps-left-header
4507 (list (concat "(" wl-ps-subject ")")
4508 (concat "(" wl-ps-from ")")))
4510 (list "/pagenumberstring load"
4511 (concat "(" wl-ps-date ")"))))
4512 (run-hooks 'wl-ps-print-hook)
4513 (funcall wl-ps-print-buffer-function filename))
4514 (kill-buffer buffer)))))
4517 (if (featurep 'ps-print) ; ps-print is available.
4518 (fset 'wl-summary-print-message 'wl-summary-print-message-with-ps-print))
4520 (defun wl-summary-target-mark-print ()
4522 (if (null wl-summary-buffer-target-mark-list)
4523 (message "No marked message.")
4524 (when (y-or-n-p "Print all marked messages. OK? ")
4525 (while (car wl-summary-buffer-target-mark-list)
4526 (let ((num (car wl-summary-buffer-target-mark-list)))
4527 (wl-thread-jump-to-msg num)
4528 (wl-summary-print-message)
4529 (wl-summary-unmark))))))
4531 (defun wl-summary-folder-info-update ()
4532 (wl-folder-set-folder-updated
4533 (elmo-string (wl-summary-buffer-folder-name))
4535 (+ wl-summary-buffer-unread-count
4536 wl-summary-buffer-new-count)
4538 wl-summary-buffer-elmo-folder))))
4540 (defun wl-summary-get-original-buffer ()
4541 "Get original buffer for the current summary."
4543 (wl-summary-set-message-buffer-or-redisplay)
4544 (wl-message-get-original-buffer)))
4546 (defun wl-summary-pack-number (&optional arg)
4548 (elmo-folder-pack-numbers wl-summary-buffer-elmo-folder)
4549 (let (wl-use-scoring)
4550 (wl-summary-rescan)))
4552 (defun wl-summary-target-mark-uudecode ()
4554 (let ((mlist (reverse wl-summary-buffer-target-mark-list))
4555 (summary-buf (current-buffer))
4556 (tmp-buf (get-buffer-create "*WL UUENCODE*"))
4557 orig-buf i k filename rc errmsg)
4559 (setq k (length mlist))
4560 (set-buffer tmp-buf)
4562 (save-window-excursion
4564 (set-buffer summary-buf)
4565 (wl-summary-jump-to-msg (car mlist))
4566 (wl-summary-redisplay)
4567 (set-buffer (setq orig-buf (wl-summary-get-original-buffer)))
4568 (goto-char (point-min))
4569 (cond ((= i 1) ; first
4570 (if (setq filename (wl-message-uu-substring
4574 (error "Can't find begin line")))
4576 (wl-message-uu-substring orig-buf tmp-buf))
4578 (wl-message-uu-substring orig-buf tmp-buf nil t)))
4580 (setq mlist (cdr mlist)))
4581 (set-buffer tmp-buf)
4582 (message "Exec %s..." wl-prog-uudecode)
4584 (let ((decode-dir wl-temporary-file-directory))
4585 (if (not wl-prog-uudecode-no-stdout-option)
4586 (setq filename (read-file-name "Save to file: "
4588 (elmo-safe-filename filename)
4589 wl-temporary-file-directory)))
4591 (wl-read-directory-name "Save to directory: "
4592 wl-temporary-file-directory))
4593 (setq filename (expand-file-name filename decode-dir)))
4594 (if (file-exists-p filename)
4595 (or (yes-or-no-p (format "File %s exists. Save anyway? "
4598 (elmo-bind-directory
4602 (apply 'call-process-region (point-min) (point-max)
4603 wl-prog-uudecode t (current-buffer) nil
4604 wl-prog-uudecode-arg))))
4605 (when (not (= 0 rc))
4606 (setq errmsg (buffer-substring (point-min)(point-max)))
4607 (error "Uudecode error: %s" errmsg))
4608 (if (not wl-prog-uudecode-no-stdout-option)
4609 (let (file-name-handler-alist) ;; void jka-compr
4610 (as-binary-output-file
4611 (write-region (point-min) (point-max)
4612 filename nil 'no-msg))))
4614 (set-buffer summary-buf)
4615 (wl-summary-delete-all-temp-marks))
4616 (if (file-exists-p filename)
4617 (message "Saved as %s" filename)))
4618 (kill-buffer tmp-buf)))))
4621 ;; (defun wl-summary-drop-unsync ()
4622 ;; "Drop all unsync messages."
4624 ;; (if (elmo-folder-pipe-p (wl-summary-buffer-folder-name))
4625 ;; (error "You cannot drop unsync messages in this folder"))
4626 ;; (if (or (not (interactive-p))
4627 ;; (y-or-n-p "Drop all unsync messages? "))
4628 ;; (let* ((folder-list (elmo-folder-get-primitive-folder-list
4629 ;; (wl-summary-buffer-folder-name)))
4630 ;; (is-multi (elmo-multi-p (wl-summary-buffer-folder-name)))
4634 ;; (message "Dropping...")
4635 ;; (while folder-list
4636 ;; (setq pair (elmo-folder-message-numbers (car folder-list)))
4637 ;; (when is-multi ;; dirty hack...
4639 ;; (setcar pair (+ (* multi-num elmo-multi-divide-number)
4641 ;; (elmo-msgdb-set-number-alist
4642 ;; (wl-summary-buffer-msgdb)
4644 ;; (elmo-msgdb-get-number-alist (wl-summary-buffer-msgdb))
4645 ;; (list (cons (car pair) nil))))
4646 ;; (setq sum (+ sum (cdr pair)))
4647 ;; (setq folder-list (cdr folder-list)))
4648 ;; (wl-summary-set-message-modified)
4649 ;; (wl-folder-set-folder-updated (wl-summary-buffer-folder-name)
4651 ;; (+ wl-summary-buffer-unread-count
4652 ;; wl-summary-buffer-new-count)
4654 ;; (message "Dropping...done"))))
4656 (defun wl-summary-default-get-next-msg (msg)
4657 (or (wl-summary-next-message msg
4658 (if wl-summary-move-direction-downward 'down
4661 (cadr (memq msg (if wl-summary-move-direction-downward
4662 wl-summary-buffer-number-list
4663 (reverse wl-summary-buffer-number-list))))))
4665 (defun wl-summary-save-current-message ()
4666 "Save current message for `wl-summary-yank-saved-message'."
4668 (let ((number (wl-summary-message-number)))
4669 (setq wl-summary-buffer-saved-message number)
4670 (and number (message "No: %s is saved." number))))
4672 (defun wl-summary-yank-saved-message ()
4673 "Set current message as a parent of the saved message."
4675 (if wl-summary-buffer-saved-message
4676 (let ((number (wl-summary-message-number)))
4677 (if (eq wl-summary-buffer-saved-message number)
4678 (message "Cannot set itself as a parent.")
4680 (wl-thread-jump-to-msg wl-summary-buffer-saved-message)
4681 (wl-thread-set-parent number)
4682 (wl-summary-set-thread-modified))
4683 (setq wl-summary-buffer-saved-message nil)))
4684 (message "There's no saved message.")))
4686 (defun wl-summary-toggle-header-narrowing ()
4687 "Toggle message header narrowing."
4689 (when wl-message-use-header-narrowing
4690 (save-selected-window
4691 (let* ((mbuf wl-message-buffer)
4692 (mwin (when mbuf (get-buffer-window mbuf)))
4693 (wpos (when mwin (window-start mwin))))
4696 (wl-message-header-narrowing-toggle)
4697 (and wpos (set-window-start mwin wpos)))))))
4699 (autoload 'elmo-folder-list-global-flag-messages "elmo-flag")
4702 (product-provide (provide 'wl-summary) (require 'wl-version))
4704 ;;; wl-summary.el ends here