tm 7.19.
[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.3 1995/10/23 08:53:47 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
16 (autoload 'mime/viewer-mode "tm-view" "View MIME message." t)
17 (autoload 'mime/Content-Type "tm-view" "parse Content-Type field.")
18 (autoload 'mime/decode-message-header "tm-ew-d" "Decode MIME encoded-word." t)
19
20 (setq rmail-message-filter
21       (function
22        (lambda ()
23          (let ((mf (buffer-modified-p))
24                (buffer-read-only nil))
25            (mime/decode-message-header)
26            (set-buffer-modified-p mf)
27            ))))
28
29 (defun tm-rmail/show-all-header-p ()
30   (save-restriction
31     (narrow-to-region (point-min)
32                       (and (re-search-forward "^$" nil t)
33                            (match-beginning 0)))
34     (goto-char (point-min))
35     (re-search-forward rmail-ignored-headers nil t)
36     ))
37
38 (defun tm-rmail/view-message ()
39   (interactive)
40   (let ((ret (rmail-widen-to-current-msgbeg
41               (function
42                (lambda ()
43                  (cons (mime/Content-Type)
44                        (mail-fetch-field "Content-Transfer-Encoding"))
45                  )))))
46     (mime/viewer-mode nil (car ret)(cdr ret))
47     ))
48
49 (defun tm-rmail/quitting-method-to-summary ()
50   (mime-viewer/kill-buffer)
51   (rmail-summary)
52   (delete-other-windows)
53   )
54
55 (defun tm-rmail/quitting-method-to-article ()
56   (mime-viewer/kill-buffer)
57   )
58
59 (defalias 'tm-rmail/quitting-method 'tm-rmail/quitting-method-to-article)
60
61 (add-hook 'rmail-mode-hook
62           (function
63            (lambda ()
64              (local-set-key "v" (function tm-rmail/view-message))
65              )))
66
67 (add-hook 'rmail-summary-mode-hook
68           (function
69            (lambda ()
70              (local-set-key "v"
71                             (function
72                              (lambda ()
73                                (interactive)
74                                (pop-to-buffer rmail-buffer)
75                                (tm-rmail/view-message)
76                                )))
77              )))
78
79 (call-after-loaded 'tm-view
80                    (function
81                     (lambda ()
82                       (set-alist 'mime-viewer/quitting-method-alist
83                                  'rmail-mode
84                                  (function tm-rmail/quitting-method))
85                       )))
86
87
88 ;;; @ for tm-partial
89 ;;;
90
91 (call-after-loaded
92  'tm-partial
93  (function
94   (lambda ()
95     (set-atype 'mime/content-decoding-condition
96                '((type . "message/partial")
97                  (method . mime-article/grab-message/partials)
98                  (major-mode . rmail-mode)
99                  (summary-buffer-exp
100                   . (progn
101                       (rmail-summary)
102                       (pop-to-buffer rmail-buffer)
103                       rmail-summary-buffer))
104                  ))
105     (set-alist 'tm-partial/preview-article-method-alist
106                'rmail-mode
107                (function
108                 (lambda ()
109                   (rmail-summary-goto-msg (count-lines 1 (point)))
110                   (pop-to-buffer rmail-buffer)
111                   (tm-rmail/view-message)
112                   )))
113     )))
114
115
116 ;;; @ end
117 ;;;
118
119 (provide 'tm-rmail)
120
121 (run-hooks 'tm-rmail-load-hook)