667e81abbe02361f23b29ef6f88f6f7d0a69315f
[elisp/tm.git] / mime-setup.el
1 ;;;
2 ;;; mime-setup.el --- setup file to use tm and mime.el.
3 ;;;
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1994,1995 MORIOKA Tomohiko
6 ;;;
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Version:
9 ;;;     $Id: mime-setup.el,v 7.4 1995/10/17 16:20:39 morioka Exp $
10 ;;; Keywords: mail, news, MIME, multimedia, multilingual, encoded-word
11 ;;;
12 ;;; This file is part of tm (Tools for MIME).
13 ;;;
14
15 (require 'tm-setup)
16
17
18 ;;; @ variables
19 ;;;
20
21 (defvar mime-setup-use-sc nil)
22 (defvar mime-setup-use-signature t)
23 (defvar mime-setup-default-signature-key "\C-c\C-s")
24 (defvar mime-setup-signature-key-alist
25   '((mail-mode . "\C-c\C-w")))
26
27
28 ;;; @ for Edit MIME mode
29 ;;;
30
31 (autoload 'mime-mode "mime" "Edit MIME message." t)
32 (autoload 'mime-convert-buffer "mime" "convert to MIME." t)
33
34 (setq mime-content-types
35       '(("text"
36          ;; Charset parameter need not to be specified, since it is
37          ;; defined automatically while translation.
38          ("plain"
39           ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8")
40           )
41          ("richtext"
42           ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8")
43           )
44          ("enriched"
45           ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8")
46           )
47          ("x-latex"
48           ("x-name")
49           ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8")
50           )
51          ("html"
52           ("x-name")
53           ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8")
54           ))
55         ("message"
56          ("external-body"
57           ("access-type"
58            ("anon-ftp"
59             ("site" "ftp.jaist.ac.jp" "wnoc-fuk.wide.ad.jp" "nic.karrn.ad.jp")
60             ("directory" "/pub/GNU/elisp/mime")
61             ("name")
62             ("mode" "binary" "ascii"))
63            ("ftp"
64             ("site")
65             ("directory")
66             ("name")
67             ("mode" "binary" "ascii"))
68            ("tftp"
69             ("site")
70             ("name"))
71            ("afs"
72             ("site")
73             ("name"))
74            ("local-file"
75             ("site")
76             ("name"))
77            ("mail-server"
78             ("server"))))
79          ("rfc822"))
80         ("application"
81          ("octet-stream"
82           ("name")
83           ("type" "" "tar" "shar")
84           ("conversions"))
85          ("postscript")
86          ("x-kiss"
87           ("x-name")
88           ("x-cnf")))
89         ("image"
90          ("gif"  ("x-name"))
91          ("jpeg" ("x-name"))
92          ("x-pic"  ("x-name"))
93          ("x-xwd")
94          ("x-xbm"))
95         ("audio"
96          ("basic"))
97         ("video"
98          ("mpeg")))
99       )
100
101
102 ;;; @ for signature
103 ;;;
104
105 (if mime-setup-use-signature
106     (progn
107       (autoload 'insert-signature "signature" "Insert signature" t)
108       
109       (add-hook 'mime-mode-hook
110                 (function
111                  (lambda ()
112                    (let ((key (or (cdr
113                                    (assq major-mode
114                                          mime-setup-signature-key-alist)
115                                    )
116                                   mime-setup-default-signature-key)))
117                      (define-key (current-local-map)
118                        key (function insert-signature))
119                      ))))
120       
121       (setq gnus-signature-file nil)
122       ))
123
124
125 ;;; @ for encoded-word
126 ;;;
127
128 (autoload 'mime/encode-message-header "tm-eword"
129   "convert message header to MIME style." t)
130
131 (add-hook 'mime-translate-hook (function mime/encode-message-header))
132
133 (setq mime-header-charset-chooser
134       (function
135        (lambda (begin end)
136          )))
137
138
139 ;;; @ for tm-comp
140 ;;;
141
142 (call-after-loaded
143  'tm-comp
144  (function
145   (lambda ()
146     (setq mime-transfer-encoders
147           '(("base64"           "mmencode")
148             ("quoted-printable" "mmencode" "-q")
149             ("7bit"             nil)    ;Default
150             ("8bit"             nil)
151             ("binary"           nil)
152             ("x-uue"            "uuencode" "-")
153             ))
154     
155     (setq mime-file-types
156           '(("\\.rtf$"
157              "text"     "richtext"      nil     nil)
158             ("\\.html$"
159              "text"     "html"          nil     nil)
160             ("\\.ps$"
161              "application" "postscript" nil     "quoted-printable")
162             ("\\.gif$"
163              "image"    "gif"           nil     "base64")
164             ("\\.jpg$"
165              "image"    "jpeg"          nil     "base64")
166             ("\\.xwd$"
167              "image"    "x-xwd"         nil     "base64")
168             ("\\.xbm$"
169              "image"    "x-xbm"         nil     "base64")
170             ("\\.pic$"
171              "image"    "x-pic"         nil     "base64")
172             ("\\.tiff$"
173              "image"    "tiff"          nil     "base64")
174             ("\\.au$"
175              "audio"    "basic"         nil     "base64")
176             ("\\.mpg$"
177              "video"    "mpeg"          nil     "base64")
178             ("\\.el$"
179              "application" "octet-stream" (("name" . file)
180                                            ("type" . "emacs-lisp")) "7bit")
181             ("\\.tar.gz$"
182              "application" "octet-stream" (("name" . file)
183                                            ("type" . "tar")
184                                            ("conversions" . "gzip")) nil)
185             ("\\.diff$"
186              "application" "octet-stream" (("name" . file)
187                                            ("type" . "patch")) nil)
188             ("\\.signature"
189              "text"     "plain"         nil     nil)
190             (".*"       nil             nil     nil     nil))
191           )
192     )))
193
194
195 ;;; @ about SuperCite
196 ;;;
197
198 (if mime-setup-use-sc
199     (require 'sc-setup)
200   )
201
202
203 ;;; @ for mh-e
204 ;;;
205
206 (add-hook 'mh-letter-mode-hook
207           (function
208            (lambda ()
209              (mime/decode-message-header)
210              (mime-mode)
211              (make-local-variable 'mail-header-separator)
212              (setq mail-header-separator "--------")
213              (save-excursion
214                (goto-char (point-min))
215                (if (re-search-forward "^-*$" nil t)
216                    (progn
217                      (replace-match mail-header-separator)
218                      (set-buffer-modified-p (buffer-modified-p))
219                      ))
220                )
221              )))
222
223
224 ;;; @ for GNUS
225 ;;;
226
227 (add-hook 'news-reply-mode-hook
228           (function
229            (lambda ()
230              (mime/decode-message-header)
231              (set-buffer-modified-p nil)
232              (mime-mode)
233              )))
234
235 ;;; for Gnus 5.* and September Gnus
236 ;;;
237 (add-hook 'news-inews-hook
238           (function
239            (lambda ()
240              (if mime-mode-flag
241                  (mime-mode-exit)
242                ))))
243 (add-hook 'mail-send-hook
244           (function
245            (lambda ()
246              (if mime-mode-flag
247                  (mime-mode-exit)
248                ))))
249
250
251 ;;; @ for Mail mode (includes VM mode)
252 ;;;
253
254 (add-hook 'mail-mode-hook (function mime-mode))
255 (add-hook 'mail-setup-hook (function mime/decode-message-header))
256
257 ;;; @@ In VM, the following definitions may be requried:
258 ;;; 
259
260 (if (boundp 'vm-visible-headers)
261     (progn
262       (setq vm-preview-lines nil)
263       (setq vm-invisible-header-regexp nil)
264       (setq vm-visible-headers
265             (append vm-visible-headers
266                     '("Mime-Version:"
267                       "Content-Type:"
268                       "Content-Transfer-Encoding:")))
269       ))
270
271
272 ;;; @ end
273 ;;;
274
275 (provide 'mime-setup)
276
277 ;;; Local Variables:
278 ;;; mode: emacs-lisp
279 ;;; mode: outline-minor
280 ;;; outline-regexp: ";;; @+\\|(......"
281 ;;; End: