tm 7.20.
[elisp/tm.git] / tm-rmail.el
1 ;;;
2 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
3 ;;; Copyright (C) 1994,1995 MORIOKA Tomohiko
4 ;;;
5 ;;; Author:   MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;;; Version:
7 ;;;     $Id: tm-rmail.el,v 7.4 1995/10/24 00:19:52 morioka Exp $
8 ;;; Keywords: mail, MIME, multimedia, multilingual, encoded-word
9 ;;;
10 ;;; This file is part of tm (Tools for MIME).
11 ;;;
12
13 (require 'tl-list)
14 (require 'tl-misc)
15 (require 'rmail)
16
17 (autoload 'mime/viewer-mode "tm-view" "View MIME message." t)
18 (autoload 'mime/Content-Type "tm-view" "parse Content-Type field.")
19 (autoload 'mime/decode-message-header "tm-ew-d" "Decode MIME encoded-word." t)
20
21 (setq rmail-message-filter
22       (function
23        (lambda ()
24          (let ((mf (buffer-modified-p))
25                (buffer-read-only nil))
26            (mime/decode-message-header)
27            (set-buffer-modified-p mf)
28            ))))
29
30 (defun tm-rmail/show-all-header-p ()
31   (save-restriction
32     (narrow-to-region (point-min)
33                       (and (re-search-forward "^$" nil t)
34                            (match-beginning 0)))
35     (goto-char (point-min))
36     (re-search-forward rmail-ignored-headers nil t)
37     ))
38
39 (defun tm-rmail/view-message ()
40   (interactive)
41   (let ((ret (rmail-widen-to-current-msgbeg
42               (function
43                (lambda ()
44                  (cons (mime/Content-Type)
45                        (mail-fetch-field "Content-Transfer-Encoding"))
46                  )))))
47     (mime/viewer-mode nil (car ret)(cdr ret))
48     ))
49
50 (defun tm-rmail/quitting-method-to-summary ()
51   (mime-viewer/kill-buffer)
52   (rmail-summary)
53   (delete-other-windows)
54   )
55
56 (defun tm-rmail/quitting-method-to-article ()
57   (mime-viewer/kill-buffer)
58   )
59
60 (defalias 'tm-rmail/quitting-method 'tm-rmail/quitting-method-to-article)
61
62 (define-key rmail-mode-map "v" (function tm-rmail/view-message))
63
64 (add-hook 'rmail-summary-mode-hook
65           (function
66            (lambda ()
67              (local-set-key "v"
68                             (function
69                              (lambda ()
70                                (interactive)
71                                (pop-to-buffer rmail-buffer)
72                                (tm-rmail/view-message)
73                                )))
74              )))
75
76 (call-after-loaded 'tm-view
77                    (function
78                     (lambda ()
79                       (set-alist 'mime-viewer/quitting-method-alist
80                                  'rmail-mode
81                                  (function tm-rmail/quitting-method))
82                       )))
83
84
85 ;;; @ for tm-partial
86 ;;;
87
88 (call-after-loaded
89  'tm-partial
90  (function
91   (lambda ()
92     (set-atype 'mime/content-decoding-condition
93                '((type . "message/partial")
94                  (method . mime-article/grab-message/partials)
95                  (major-mode . rmail-mode)
96                  (summary-buffer-exp
97                   . (progn
98                       (rmail-summary)
99                       (pop-to-buffer rmail-buffer)
100                       rmail-summary-buffer))
101                  ))
102     (set-alist 'tm-partial/preview-article-method-alist
103                'rmail-mode
104                (function
105                 (lambda ()
106                   (rmail-summary-goto-msg (count-lines 1 (point)))
107                   (pop-to-buffer rmail-buffer)
108                   (tm-rmail/view-message)
109                   )))
110     )))
111
112
113 ;;; @ end
114 ;;;
115
116 (provide 'tm-rmail)
117
118 (run-hooks 'tm-rmail-load-hook)