Debian Codegraph @

mew-summary2.el

raw
1 ;;; mew-summary2.el --- Summary mode for Mew
2
3 ;; Author: Kazu Yamamoto <[email protected]>
4 ;; Created: Oct 2, 1996
5
6 ;;; Code:
7
8 (require 'mew)
9 (eval-when-compile
10 (require 'mew-env0))
11
12 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13 ;;;
14 ;;; End of
15 ;;;
16
17 (defun mew-message-set-end-of ()
18 (save-restriction
19 (widen)
20 (save-excursion
21 (mew-elet
22 (goto-char (point-max))
23 (unless (bolp) (insert "\n"))
24 (mew-message-clear-end-of)
25 (when (or mew-end-of-message-string mew-end-of-part-string)
26 (move-overlay (mew-minfo-get-eom) (point-max) (point-max))
27 (if (mew-decode-syntax-p)
28 (if (mew-summary-end-of-message-p)
29 (mew-message-set-end-of-message)
30 (mew-message-set-end-of-part))
31 (mew-message-set-end-of-message)))))))
32
33 (defun mew-message-clear-end-of ()
34 (unless (overlayp (mew-minfo-get-eom))
35 (mew-minfo-set-eom (mew-overlay-make (point-max) (point-max))))
36 (mew-message-set-end-of-nil))
37
38 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
39 ;;;
40 ;;; Prefetch
41 ;;;
42
43 (defun mew-summary-cache-prefetch ()
44 (let ((mew-inherit-prefetching t)
45 fld next)
46 (save-excursion
47 (mew-redraw) ;; need to display
48 (mew-summary-goto-message)
49 (cond
50 ((eq (mew-sinfo-get-direction) 'up)
51 (when (re-search-backward mew-regex-msg-show nil t)
52 (setq fld (mew-summary-folder-name))
53 (setq next (mew-summary-message-number))))
54 ((eq (mew-sinfo-get-direction) 'down)
55 (if (mew-decode-syntax-end)
56 (goto-char (mew-decode-syntax-end))
57 (forward-line))
58 (when (re-search-forward mew-regex-msg-show nil t)
59 (setq fld (mew-summary-folder-name))
60 (setq next (mew-summary-message-number))))))
61 ;; should get the cursor back for display
62 (save-excursion
63 (if (and fld next
64 (not (mew-cache-hit fld next))
65 (not (string= fld mew-draft-folder))
66 (not (mew-summary-message-toobig fld next)))
67 (mew-cache-message fld next nil 'no-err)))))
68
69 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
70 ;;;
71 ;;; Caching
72 ;;;
73
74 (defun mew-summary-cache-message (fld msg sumbuf &optional unlimit nodisplay)
75 "Create a cache for the message specified with FLD and MSG.
76 If UNLIMIT is non-nil, decodes it without limitations.
77 If nodisplay is non-nil, displays the cached message."
78 ;; message buffer
79 (mew-elet
80 (mew-summary-display-preamble)
81 (let ((cache (mew-cache-message fld msg unlimit)))
82 (mew-decode-syntax-copy cache)
83 (unless nodisplay
84 (mew-mime-message/rfc822 cache mew-decode-syntax))
85 ;; Must print the syntax before mew-summary-display-postscript
86 ;; to tell the end of message.
87 (mew-decode-syntax-print sumbuf
88 mew-decode-syntax
89 (mew-xinfo-get-multi-form)
90 (mew-xinfo-get-icon-spec))
91 (unless nodisplay
92 (mew-summary-display-postscript))
93 cache)))
94
95 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
96 ;;;
97 ;;; After step
98 ;;;
99
100 (defun mew-summary-display-after (direction)
101 (cond
102 ((eq direction 'down)
103 (mew-summary-display-down))
104 ((eq direction 'up)
105 (mew-summary-display-up))
106 ((eq direction 'next)
107 (mew-summary-display-next))
108 (t ()))) ;; 'stop
109
110 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
111 ;;;
112 ;;; Preamble and postscript
113 ;;;
114
115 (defun mew-summary-recenter ()
116 "Make the current line to the center of Summary mode."
117 (interactive)
118 (if (or mew-summary-recenter-p (mew-called-interactively-p))
119 (recenter (/ (- (window-height) 2) 2))))
120
121 (defun mew-summary-display-preamble ()
122 ;; message buffer
123 (mew-erase-buffer)
124 (mew-message-clear-end-of)
125 (mew-overlay-delete-buffer) ;; veil, xxx also delete extents?
126 ;; kill mark for cite
127 (and (mark-marker) (set-marker (mark-marker) nil))
128 (mew-normal-line))
129
130 (defvar mew-message-last-buffer nil)
131
132 (defun mew-summary-display-postscript (&optional no-hook)
133 ;; message buffer
134 (unless no-hook (run-hooks 'mew-message-hook))
135 (mew-minfo-set-reob nil)
136 (setq mew-message-last-buffer (current-buffer))
137 (mew-message-set-end-of)
138 (set-buffer-modified-p nil))
139
140 (defun mew-summary-cursor-postscript ()
141 (mew-summary-mode-line)
142 (mew-summary-recenter)
143 (mew-thread-move-cursor)
144 (mew-highlight-cursor-line)
145 (when (and mew-use-unread-mark
146 (mew-summary-message-number)
147 ;; mark would be nil. MUST be equal
148 (equal (mew-summary-get-mark) mew-mark-unread))
149 (unless (and mew-inherit-after-marking
150 (not mew-delete-unread-mark-by-mark))
151 (mew-mark-put-mark mew-mark-read 'no-msg)))
152 (set-buffer-modified-p nil))
153
154 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
155 ;;;
156 ;;; Displaying
157 ;;;
158
159 (defun mew-summary-message-toobig (fld msg)
160 (let ((file (mew-expand-msg fld msg)))
161 (and (file-readable-p file)
162 (> (mew-file-get-size file) mew-file-max-size))))
163
164 (defun mew-summary-display (&optional redisplay)
165 " (1) If called interactively, this command lets you read
166 through messages. That is, display a message, scroll it, and
167 move-then-display another message or part.
168
169 See 'mew-summary-show-direction' to set the direction that the
170 cursor moves. You can select a value out of 'up, 'down,
171 'next(current direction) or 'stop. Default is
172 'down. 'mew-summary-show-direction' is valid in this case only
173 because the cursor stays in the other cases.
174
175 (2) If called interactively with '\\[universal-argument]' (i.e.
176 REDISPLAY is non-nil), this command displays the current message
177 or part again. This is a convenient way to get back to the
178 beginning of the current message or part.
179
180 (3) If called internally, this function displays the current
181 message or part. If it is already displayed, nothing changes.
182
183 (4) If called internally and REDISPLAY is 'non-nil', this
184 function displays the current message or part. Even if it is
185 already displayed, this function displays it again getting back
186 to the beginning."
187 (interactive "P")
188 (when (or redisplay (mew-sinfo-get-disp-msg) (mew-called-interactively-p))
189 (mew-summary-msg-or-part
190 (let* ((fld (mew-summary-folder-name))
191 (vfld (mew-summary-folder-name 'ext))
192 (msg (mew-summary-message-number))
193 (part (mew-syntax-nums))
194 (fid (mew-frame-id))
195 (ofld (mew-current-get-fld fid))
196 (omsg (mew-current-get-msg fid))
197 (opart (mew-current-get-part fid))
198 (cache (mew-cache-hit fld (or msg omsg)))
199 (win (selected-window))
200 (read-through (mew-called-interactively-p))
201 (sumbuf (current-buffer))
202 next prefetch)
203 (unwind-protect
204 (progn
205 (mew-summary-toggle-disp-msg 'on)
206 (mew-window-configure 'message)
207 ;; message buffer
208 (mew-current-set fld (or msg omsg) part)
209 (mew-minfo-set-summary vfld)
210 (cond
211 ((null cache)
212 (mew-decode-syntax-delete)
213 (cond
214 ((string= fld mew-draft-folder)
215 (if (and (string= fld ofld) (string= msg omsg)
216 (not redisplay))
217 (if read-through
218 (if (mew-message-next-page)
219 (setq next t)))
220 (mew-decode-syntax-clear)
221 (mew-summary-display-draft fld msg)
222 (setq prefetch t)))
223 ((mew-summary-message-toobig fld msg)
224 (if (and (string= fld ofld) (string= msg omsg)
225 (not redisplay))
226 (if read-through
227 (if (mew-message-next-page)
228 (setq next t)))
229 (mew-decode-syntax-clear)
230 (mew-summary-display-raw fld msg mew-file-max-size)
231 (setq prefetch t)
232 (mew-message-for-summary
233 "Too large, truncated. To see the entire message, type '\\[mew-summary-analyze-again]'")))
234 (t
235 (mew-decode-syntax-clear)
236 (mew-summary-cache-message fld msg sumbuf)
237 (setq prefetch t))))
238 (msg
239 (cond
240 ((or (null ofld)
241 (not (and (string= fld ofld) (string= msg omsg)))
242 opart redisplay)
243 (mew-decode-syntax-clear)
244 (mew-decode-syntax-delete)
245 (mew-summary-display-message cache sumbuf)
246 (setq prefetch t))
247 (read-through
248 (if (mew-message-next-page)
249 (setq next t)))))
250 (part
251 (cond
252 ((or (null opart)
253 (not (equal opart part))
254 redisplay)
255 (mew-summary-display-part cache part))
256 ;; If called internally, never match below
257 (read-through
258 (if (mew-message-next-page)
259 (setq next t)))))))
260 (if (mew-xinfo-get-decode-err)
261 (message "MIME decoding error: %s" (mew-xinfo-get-decode-err)))
262 (if (mew-xinfo-get-action)
263 (message "%s" (mew-xinfo-get-action)))
264 (mew-message-mode-line fld msg)
265 (select-window win)
266 ;; summary buffer
267 (mew-summary-cursor-postscript)
268 (if prefetch (mew-summary-cache-prefetch))
269 (if next (mew-summary-display-after mew-summary-show-direction)))))))
270
271 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
272 ;;;
273 ;;; Displaying message or part
274 ;;;
275
276 (defun mew-summary-display-message (cache sumbuf)
277 "Display a message from the CACHE."
278 ;; message buffer
279 (mew-elet
280 (mew-summary-display-preamble)
281 (mew-decode-syntax-copy cache)
282 (mew-mime-message/rfc822 cache mew-decode-syntax)
283 ;; Must print the syntax before mew-summary-display-postscript
284 ;; to tell the end of message.
285 (mew-decode-syntax-print sumbuf
286 mew-decode-syntax
287 (mew-xinfo-get-multi-form)
288 (mew-xinfo-get-icon-spec))
289 (mew-summary-display-postscript)))
290
291 (defun mew-summary-display-part (cache nums)
292 "Display a part from the CACHE."
293 ;; message buffer
294 (mew-elet
295 (mew-summary-display-preamble)
296 (mew-decode-syntax-copy cache)
297 (mew-mime-part cache mew-decode-syntax nums)
298 (mew-summary-display-postscript)))
299
300 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
301 ;;;
302 ;;; Displaying draft
303 ;;;
304
305 (defun mew-summary-display-draft (fld msg)
306 "Display the message in +draft specified by FLD and MSG.
307 The message is not in the MIME form. So, it cannot be decoded as MIME.
308 Just display it as is. This function does not create a cache."
309 ;; message buffer
310 (mew-elet
311 (mew-summary-display-preamble)
312 (mew-insert-message fld msg mew-cs-m17n nil)
313 (mew-header-goto-end)
314 (mew-highlight-header-region (point-min) (point))
315 (mew-summary-display-postscript)))
316
317 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
318 ;;;
319 ;;; Displaying draft
320 ;;;
321
322 (defun mew-summary-display-raw (fld msg size)
323 "Display the message specified by FLD and MSG as is.
324 If SIZE is specified, truncates it with the size.
325 This function does not create a cache."
326 ;; message buffer
327 (mew-elet
328 (mew-summary-display-preamble)
329 (mew-insert-message fld msg mew-cs-binary size)
330 (goto-char (point-min))
331 (when (re-search-forward mew-eoh nil t)
332 (let ((beg (point)))
333 (goto-char (point-max))
334 (mew-cs-decode-region beg (point) mew-cs-autoconv)))
335 (goto-char (point-min))
336 (condition-case nil
337 (progn
338 (mew-decode-rfc822-header) ;; xxx limit..
339 (mew-decode-syntax-arrange-warning)
340 (mew-header-goto-end)
341 (mew-header-arrange (point-min) (point))
342 (setq mew-decode-syntax (mew-decode-syntax-rfc822)))
343 (error ()))
344 (mew-summary-display-postscript 'no-hook)))
345
346 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
347 ;;;
348 ;;; Analyze again
349 ;;;
350
351 (defun mew-summary-analyze-again-alternative (&optional arg)
352 "This command analyzes the message again with
353 'mew-use-alternative' and 'mew-use-text-body' reversed."
354 (interactive "P")
355 (mew-summary-goto-message)
356 (let ((mew-use-alternative (not mew-use-alternative))
357 (mew-use-text-body (not mew-use-text-body)))
358 (mew-summary-analyze-again arg)))
359
360 (defun mew-summary-analyze-again (&optional arg)
361 "1) If this command executed on a message, the cache of the
362 message is removed and the message is analyzed then displayed.
363
364 1a) If the size of the current message exceeds
365 'mew-file-max-size', MIME analysis is skipped then the beginning
366 of the raw message is displayed. In this situation, this command
367 analyzes the current message without the limitation then displays
368 it.
369
370 1b) If the length of a header exceeds 'mew-header-max-length', a
371 broken message is displayed. In this situation, this command
372 analyzes the current message without the limitation then displays
373 it.
374
375 1c) If the current message is displayed by '\\<mew-summary-mode-map>\\[mew-summary-analyze-again-alternative]', this command gets it back to
376 the normal display.
377
378 1d) If 'mew-use-text/html' is nil, its HTML body is displayed as
379 is. In this situation, this command analyzes the HTML body and
380 displays it.
381
382 1e) If called with '\\[universal-argument]', analyze the message
383 with 'mew-decode-broken' reversed.
384
385 2) If this command is called on a part, the part is displayed again.
386
387 2a) If 'mew-use-text/html' is nil, its HTML part is displayed as
388 is. In this situation, this command analyzes the HTML part and
389 displays it."
390 (interactive "P")
391 (mew-summary-msg-or-part
392 (if (mew-folder-draftp (mew-summary-folder-name))
393 (mew-summary-display 'redisplay)
394 (let ((mew-decode-broken
395 (if arg (not mew-decode-broken) mew-decode-broken))
396 (mew-use-text/html t)
397 (mew-use-text/xml t)
398 (fld (mew-summary-folder-name))
399 (vfld (mew-summary-folder-name 'ext))
400 (msg (mew-summary-message-number2))
401 (part (mew-syntax-nums))
402 (win (selected-window))
403 (sumbuf (current-buffer))
404 cache)
405 (unwind-protect
406 (progn
407 (mew-summary-toggle-disp-msg 'on)
408 (mew-window-configure 'message)
409 ;; message buffer
410 (if part
411 (progn
412 (setq cache (mew-cache-hit fld msg))
413 (mew-summary-display-part cache part))
414 (mew-cache-delete2 fld msg)
415 (mew-summary-goto-message)
416 (mew-current-set fld msg part)
417 (mew-minfo-set-summary vfld)
418 (mew-decode-syntax-clear)
419 (mew-decode-syntax-delete)
420 (mew-summary-cache-message fld msg sumbuf 'unlimit)))
421 (if (mew-xinfo-get-decode-err)
422 (message "MIME decoding error: %s" (mew-xinfo-get-decode-err)))
423 (mew-message-mode-line fld msg)
424 (select-window win)
425 ;; summary buffer
426 (mew-summary-cursor-postscript))))))
427
428 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
429 ;;;
430 ;;; Display ASIS
431 ;;;
432
433 (defun mew-summary-display-asis ()
434 "Insert this message or part into Message mode in the raw format.
435 This command treats PGP/MIME transparent. That is an encrypted/signed
436 part is displayed as a decrypted/verified part. Also, if this command
437 is used for a message whose entire body is encrypted/signed,
438 a decrypted/verified body is displayed."
439 (interactive)
440 (mew-summary-msg-or-part
441 (let* ((fld (mew-summary-folder-name))
442 (vfld (mew-summary-folder-name 'ext))
443 (msg (mew-summary-message-number2))
444 (nums (mew-syntax-nums))
445 (win (selected-window))
446 (buf (generate-new-buffer mew-buffer-prefix))
447 (cbuf (mew-cache-hit fld msg))
448 (alt (if cbuf
449 (mew-cache-dinfo-get-use-alt cbuf)
450 mew-use-alternative))
451 syntax ct begin end)
452 (with-current-buffer buf
453 (mew-erase-buffer)
454 (mew-insert-message fld msg mew-cs-text-for-read nil)
455 (mew-dinfo-set nil t nil alt)
456 (mew-decode-for-edit)
457 (setq syntax (mew-syntax-get-entry mew-decode-syntax nums)))
458 (setq ct (mew-syntax-get-value (mew-syntax-get-ct syntax) 'cap))
459 (setq begin (mew-syntax-get-begin syntax))
460 (setq end (mew-syntax-get-end syntax))
461 (unwind-protect
462 (progn
463 (mew-summary-toggle-disp-msg 'on)
464 (mew-window-configure 'message)
465 ;; message buffer
466 (mew-current-set fld msg nums)
467 (mew-minfo-set-summary vfld)
468 ;; The following codes are not necessary.
469 ;; (mew-decode-syntax-clear)
470 ;; (mew-decode-syntax-delete)
471 (mew-elet
472 (mew-summary-display-preamble)
473 (mew-decode-syntax-copy buf)
474 (cond
475 ((string= ct mew-ct-msg)
476 (if nums
477 (setq end (mew-syntax-get-end (mew-syntax-get-part syntax)))
478 (setq end nil))
479 ;; We need to keep properties of a header.
480 ;; This must be "insert-buffer-substring".
481 (insert-buffer-substring buf begin end)
482 (goto-char (point-min))
483 (mew-header-goto-end)
484 (mew-header-arrange (point-min) (point))
485 (setq mew-decode-syntax (mew-decode-syntax-rfc822)))
486 (t
487 ;; We need to keep composite properties of charset.
488 ;; This must be "insert-buffer-substring".
489 (insert-buffer-substring buf begin end)
490 (goto-char (point-min)))))
491 (mew-summary-display-postscript 'no-hook))
492 (mew-remove-buffer buf)
493 (mew-message-mode-line fld msg)
494 (select-window win)
495 ;; summary buffer
496 (mew-summary-cursor-postscript)))))
497
498 (defun mew-summary-find-file (&optional arg)
499 "Open this message and makes it read-only.
500 If called with '\\[universal-argument]', it stays writable."
501 (interactive "P")
502 (mew-summary-msg-or-part
503 (let* ((fld (mew-summary-folder-name))
504 (msg (mew-summary-message-number2))
505 (file (mew-expand-msg fld msg)))
506 (when (mew-sinfo-get-disp-msg)
507 (mew-summary-toggle-disp-msg))
508 (mew-frwlet (if (mew-folder-draftp fld) mew-cs-m17n mew-cs-autoconv) mew-cs-dummy
509 (if arg
510 (switch-to-buffer (mew-find-file-noselect2 file))
511 (view-buffer (mew-find-file-noselect2 file) 'kill-buffer))))))
512
513 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
514 ;;;
515 ;;; Trace Path
516 ;;;
517
518 (defun mew-summary-trace-path ()
519 "Parse the Received: fields and display them in Message mode."
520 (interactive)
521 (mew-summary-msg-or-part
522 (let* ((win (selected-window))
523 (fld (mew-summary-folder-name))
524 (msg (mew-summary-message-number2))
525 lst svr-date (snd "?") (rcv "?") last svr date tmp)
526 (mew-summary-set-message-buffer fld msg)
527 ;; message buffer or cache buffer
528 (setq lst (nreverse (mew-header-get-value mew-received: 'as-list)))
529 (set-buffer (mew-buffer-message))
530 ;; message buffer
531 (mew-summary-display-preamble)
532 (save-excursion
533 (dolist (ent lst)
534 (while (string-match "\n" ent)
535 (setq ent (replace-match "" nil t ent)))
536 (setq svr-date (mew-split ent ?\;))
537 (mew-set '(svr date) svr-date)
538 (unless date
539 ;; for broken MTAs
540 (if (string-match "Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\|Sun" ent)
541 (setq date (substring ent (match-beginning 0)))))
542 (if date (setq date (mew-time-rfc-to-sortkey date 'tzadj)))
543 (unless date (setq date "19700101000000"))
544 (setq tmp (cons (list date svr) tmp))
545 (cond
546 ((string-match "(\\(qmail [0-9]+\\)" svr)
547 (setq rcv (match-string 1 svr)))
548 ((string-match "by[ \t]+\\([^() \t\n]+\\)" svr)
549 (setq rcv (match-string 1 svr))
550 (if (string-match "from[ \t]+\\([^() \t\n]+\\).*\\([[][.0-9]+[]]\\)" svr)
551 (setq snd (format "%s %s" (match-string 1 svr) (match-string 2 svr)))
552 (if (string-match "from[ \t]+\\([^() \t\n]+\\)" svr)
553 (setq snd (match-string 1 svr))))
554 (when (and (string= snd "unknown")
555 (string-match "from unknown (HELO \\([^() \t\n]+\\))" svr))
556 (setq snd (concat (match-string 1 svr) "(unknown)"))))
557 ((string-match "[ \t]*\\([^() \t\n]+\\)" svr)
558 (setq rcv (match-string 1 svr))
559 (if (string-match "from[ \t]*\\([^() \t\n]+\\)" svr)
560 (setq snd (match-string 1 svr)))))
561 (mew-elet
562 (insert date)
563 (beginning-of-line)
564 (forward-char 4)
565 (insert "/")
566 (forward-char 2)
567 (insert "/")
568 (forward-char 2)
569 (insert " ")
570 (forward-char 2)
571 (insert ":")
572 (forward-char 2)
573 (insert ":")
574 (forward-char 2)
575 (insert " (" (mew-time-tmzn-int) ") ")
576 (if (and snd (not (string= snd last))) (insert snd))
577 (insert " => ")
578 (if rcv (insert rcv))
579 (insert "\n")
580 (setq last rcv)
581 (setq snd "?" rcv "?"))))
582 (mew-summary-display-postscript 'no-hook)
583 (select-window win))))
584
585 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
586 ;;;
587 ;;; Direction
588 ;;;
589
590 (defun mew-summary-next ()
591 (if (eq (mew-sinfo-get-direction) 'up)
592 (mew-summary-up)
593 (mew-summary-down)))
594
595 (defvar mew-summary-down-function 'forward-line
596 "This function is called by mew-summary-down(). This is a very
597 ad-hoc solution for putting the review mark on a thread.")
598
599 (defun mew-re-search-forward-visibile (regex)
600 (catch 'loop
601 (while (re-search-forward regex nil t)
602 (unless (eq (get-text-property (point) 'invisible) t)
603 (throw 'loop t)))))
604
605 (defun mew-re-search-backward-visible (regex)
606 (catch 'loop
607 (while (re-search-backward regex nil t)
608 (unless (eq (get-text-property (point) 'invisible) t)
609 (throw 'loop t)))))
610
611 (defun mew-summary-down ()
612 (funcall mew-summary-down-function)
613 (cond
614 ((mew-re-search-forward-visibile mew-regex-msg-or-part)
615 (mew-thread-move-cursor)
616 (mew-sinfo-set-direction 'down)
617 t)
618 (t
619 (mew-decode-syntax-delete)
620 (forward-line -1) ;; for invisible
621 (unless (pos-visible-in-window-p)
622 ;; This ensures that some messages are displayed in Summary.
623 (recenter))
624 (mew-thread-move-cursor)
625 (mew-summary-reset)
626 (message "No more messages")
627 nil)))
628
629 (defun mew-summary-up ()
630 (beginning-of-line)
631 (cond
632 ((mew-re-search-backward-visible mew-regex-msg-or-part)
633 (mew-thread-move-cursor)
634 (mew-sinfo-set-direction 'up)
635 t)
636 (t
637 (mew-thread-move-cursor)
638 (mew-decode-syntax-delete)
639 (mew-summary-reset)
640 (message "No more messages")
641 nil)))
642
643 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
644 ;;;
645 ;;; Direction 2
646 ;;;
647
648 (defun mew-summary-display-next ()
649 (if (mew-summary-next) (mew-summary-display)))
650
651 (defun mew-summary-display-up (&optional arg)
652 "Move to above then display. Targets includes parts, messages
653 marked with '*', and non-marked messages. When called with '\\[universal-argument]',
654 parts are skipped."
655 (interactive "P")
656 (beginning-of-line)
657 (when arg
658 (mew-summary-goto-message)
659 (mew-decode-syntax-delete))
660 (if (mew-summary-up) (mew-summary-display)))
661
662 (defun mew-summary-display-down (&optional arg)
663 "Move to below then display. Targets includes parts, messages
664 marked with '*', and non-marked messages. When called with '\\[universal-argument]',
665 parts are skipped."
666 (interactive "P")
667 (when arg
668 (mew-summary-goto-message)
669 (mew-decode-syntax-delete))
670 (if (mew-summary-down) (mew-summary-display)))
671
672 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
673 ;;;
674 ;;; Paging
675 ;;;
676
677 (defun mew-summary-prev-page ()
678 "\\<mew-summary-mode-map>Back-scroll this message. Unnecessary header fields are hidden
679 over the window. Type '\\[mew-summary-prev-page]' to see them when a message is displayed."
680 (interactive)
681 (mew-summary-scroll-down 'fullpage))
682
683 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
684 ;;;
685 ;;; Scrolling
686 ;;;
687
688 (defun mew-summary-scroll-up ()
689 "Make this message scroll up with one line."
690 (interactive)
691 (mew-summary-msg-or-part
692 (let* ((win (selected-window))
693 (msg (mew-summary-message-number))
694 (part (mew-syntax-nums))
695 (fid (mew-frame-id))
696 (omsg (mew-current-get-msg fid))
697 (opart (mew-current-get-part fid)))
698 ;; xxx how about folder check?
699 (if (or (and msg (string= msg omsg) (null part) (null opart))
700 (and part (equal part opart))) ;; MUST be equal
701 (unwind-protect
702 (progn
703 (mew-summary-toggle-disp-msg 'on)
704 (mew-window-configure 'message)
705 ;; message buffer
706 (mew-message-next-page 1))
707 (select-window win))
708 (call-interactively 'mew-summary-display)))))
709
710 (defun mew-summary-scroll-down (&optional fullpage)
711 "Make this message scroll down with one line."
712 (interactive)
713 (mew-summary-msg-or-part
714 (let* ((win (selected-window))
715 (msg (mew-summary-message-number))
716 (part (mew-syntax-nums))
717 (fid (mew-frame-id))
718 (omsg (mew-current-get-msg fid))
719 (opart (mew-current-get-part fid)))
720 ;; xxx how about folder check?
721 (if (or (and msg (string= msg omsg) (null part) (null opart))
722 (and part (equal part opart))) ;; MUST be equal
723 (unwind-protect
724 (progn
725 (mew-summary-toggle-disp-msg 'on)
726 (mew-window-configure 'message)
727 ;; message buffer
728 (mew-message-prev-page (if fullpage nil 1)))
729 (select-window win))
730 (call-interactively 'mew-summary-display)))))
731
732 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
733 ;;;
734 ;;; Cursor motion
735 ;;;
736
737 (defun mew-summary-next-line (&optional arg)
738 "Go to the next line."
739 (interactive "p")
740 (or arg (setq arg 1))
741 (if (< arg 0)
742 (mew-summary-previous-line (- arg))
743 (let (col)
744 (if (eq last-command this-command)
745 (setq col (mew-sinfo-get-column)))
746 (unless col
747 (setq col (current-column))
748 (mew-sinfo-set-column col))
749 (while (> arg 0)
750 (forward-line)
751 (while (or (looking-at mew-regex-thread-separator)
752 (eq (get-text-property (point) 'invisible) t))
753 (forward-line))
754 (setq arg (1- arg)))
755 (move-to-column col))))
756
757 (defun mew-summary-previous-line (&optional arg)
758 "Go to the previous line."
759 (interactive "p")
760 (or arg (setq arg 1))
761 (if (< arg 0)
762 (mew-summary-next-line (- arg))
763 (let (col)
764 (if (eq last-command this-command)
765 (setq col (mew-sinfo-get-column)))
766 (unless col
767 (setq col (current-column))
768 (mew-sinfo-set-column col))
769 (while (> arg 0)
770 (forward-line -1) ;; for invisible
771 (while (or (looking-at mew-regex-thread-separator)
772 (eq (get-text-property (point) 'invisible) t))
773 (forward-line -1))
774 (setq arg (1- arg)))
775 (move-to-column col))))
776
777 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
778 ;;;
779 ;;; Mouse
780 ;;;
781
782 (defun mew-summary-mouse-show (e)
783 "Mouse version of 'mew-summary-display'."
784 (interactive "e")
785 (mouse-set-point e)
786 (beginning-of-line)
787 (call-interactively 'mew-summary-display))
788
789 (provide 'mew-summary2)
790
791 ;;; Copyright Notice:
792
793 ;; Copyright (C) 1996-2015 Mew developing team.
794 ;; All rights reserved.
795
796 ;; Redistribution and use in source and binary forms, with or without
797 ;; modification, are permitted provided that the following conditions
798 ;; are met:
799 ;;
800 ;; 1. Redistributions of source code must retain the above copyright
801 ;; notice, this list of conditions and the following disclaimer.
802 ;; 2. Redistributions in binary form must reproduce the above copyright
803 ;; notice, this list of conditions and the following disclaimer in the
804 ;; documentation and/or other materials provided with the distribution.
805 ;; 3. Neither the name of the team nor the names of its contributors
806 ;; may be used to endorse or promote products derived from this software
807 ;; without specific prior written permission.
808 ;;
809 ;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
810 ;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
811 ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
812 ;; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE
813 ;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
814 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
815 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
816 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
817 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
818 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
819 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
820
821 ;;; mew-summary2.el ends here