tm 6.67
[elisp/tm.git] / tm-rmail.el
1 ;;;
2 ;;; $Id: tm-rmail.el,v 6.6 1995/06/26 22:52:13 morioka Exp $
3 ;;;
4
5 (require 'tl-header)
6 (require 'tl-list)
7 (require 'tl-misc)
8
9 (autoload 'mime/viewer-mode "tm-view" "View MIME message." t)
10 (autoload 'mime/Content-Type "tm-view" "parse Content-Type field.")
11 (autoload 'mime/decode-message-header "tiny-mime" "Decode MIME header." t)
12
13 (defun tm-rmail/show-all-header-p ()
14   (save-restriction
15     (narrow-to-region (point-min)
16                       (and (re-search-forward "^$" nil t)
17                            (match-beginning 0)))
18     (goto-char (point-min))
19     (re-search-forward rmail-ignored-headers nil t)
20     ))
21
22 (defun tm-rmail/view-message ()
23   (interactive)
24   (let ((ret (rmail-widen-to-current-msgbeg
25               (function
26                (lambda ()
27                  (cons (mime/Content-Type)
28                        (mail-fetch-field "Content-Transfer-Encoding"))
29                  )))))
30     (mime/viewer-mode nil (car ret)(cdr ret))
31     ))
32
33 (defun tm-rmail/quitting-method-to-summary ()
34   (mime-viewer/kill-buffer)
35   (rmail-summary)
36   (delete-other-windows)
37   )
38
39 (defun tm-rmail/quitting-method-to-article ()
40   (mime-viewer/kill-buffer)
41   )
42
43 (defalias 'tm-rmail/quitting-method 'tm-rmail/quitting-method-to-article)
44
45 (add-hook 'rmail-show-message-hook
46           (function
47            (lambda ()
48              (let ((mf (buffer-modified-p))
49                    (buffer-read-only nil))
50                (mime/decode-message-header)
51                (set-buffer-modified-p mf)
52                ))))
53
54 (add-hook 'rmail-mode-hook
55           (function
56            (lambda ()
57              (local-set-key "v" (function tm-rmail/view-message))
58              )))
59
60 (add-hook 'rmail-summary-mode-hook
61           (function
62            (lambda ()
63              (local-set-key "v"
64                             (function
65                              (lambda ()
66                                (interactive)
67                                (pop-to-buffer rmail-buffer)
68                                (tm-rmail/view-message)
69                                )))
70              )))
71
72 (call-after-loaded 'tm-view
73                    (function
74                     (lambda ()
75                       (set-alist 'mime-viewer/quitting-method
76                                  'rmail-mode
77                                  (function tm-rmail/quitting-method))
78                       )))
79
80 (provide 'tm-rmail)
81
82 (run-hooks 'tm-rmail-load-hook)