tm4.7.0.
[elisp/tm.git] / tm-mh-e.el
1 ;;;
2 ;;; A MIME extender for mh-e
3 ;;;
4 ;;; by Morioka Tomohiko, 1993/11/21
5 ;;;
6
7 (provide 'tm-mh-e)
8
9 ;;; @ version
10 ;;;
11 (defconst tm-mh-e/RCS-ID
12   "$Id: tm-mh-e.el,v 2.2 1994/07/25 16:13:03 morioka Exp $")
13
14 (defconst tm-mh-e/version
15   (and (string-match "[0-9][0-9.]*" tm-mh-e/RCS-ID)
16        (substring tm-mh-e/RCS-ID (match-beginning 0)(match-end 0))
17        ))
18
19
20 ;;; @ require modules
21 ;;;
22 (require 'tm-misc)
23 (require 'mh-e)
24 (if (not (boundp 'mh-e-version))
25     (require 'tm-mh-e3)
26   )
27
28
29 ;;; @ MIME header decoding mode
30 ;;;
31 (defun tm-mh-e/toggle-header-decoding-mode (arg)
32   "Toggle MIME header processing.
33 With arg, turn MIME processing on if arg is positive."
34   (interactive "P")
35   (setq mime/header-decoding-mode
36         (if (null arg)
37             (not mime/header-decoding-mode)
38           arg))
39   (mh-invalidate-show-buffer)
40   (mh-show-msg (mh-get-msg-num t))
41   )
42
43
44 ;;; @ MIME body players
45 ;;;
46 (defun tm-mh-e/play-message (arg)
47   "MIME decode and play this message."
48   (interactive "P")
49   (mh-invalidate-show-buffer)
50   (let ((mime/body-decoding-mode "play"))
51     (mh-show-msg (mh-get-msg-num t))
52     )
53   (mime/show-body-decoded-result)
54   )
55
56 (defun tm-mh-e/extract-message (arg)
57   "MIME decode and extract files from this message."
58   (interactive "P")
59   (mh-invalidate-show-buffer)
60   (let ((mime/body-decoding-mode "extract"))
61     (mh-show-msg (mh-get-msg-num t))
62     )
63   (mime/show-body-decoded-result)
64   )
65
66 (defun tm-mh-e/print-message (arg)
67   "MIME decode and extract files from this message."
68   (interactive "P")
69   (mh-invalidate-show-buffer)
70   (let ((mime/body-decoding-mode "print"))
71     (mh-show-msg (mh-get-msg-num t))
72     )
73   (mime/show-body-decoded-result)
74   )
75
76
77 ;;; @ set up
78 ;;;
79 (add-hook 'mh-show-mode-hook
80           (function
81            (lambda ()
82              (make-local-variable 'minor-mode-alist)
83              (mime/add-header-decoding-mode-to-mode-line)
84              (let ((buffer-read-only nil))
85                (if mime/header-decoding-mode
86                    (mime/decode-message-header)
87                  )
88                (if mime/body-decoding-mode
89                    (funcall mime/body-decoding-method)
90                  )
91                (set-buffer-modified-p nil)
92                ))))
93
94 (define-key mh-folder-mode-map "\et" 'tm-mh-e/toggle-header-decoding-mode)
95 (define-key mh-folder-mode-map "v" 'tm-mh-e/play-message)
96 (define-key mh-folder-mode-map "e" 'tm-mh-e/extract-message)
97 (define-key mh-folder-mode-map "\C-cp" 'tm-mh-e/print-message)