tm4.7.0.
[elisp/tm.git] / mime-setup.el
1 ;;;
2 ;;; $Id: mime-setup.el,v 1.14 1994/08/01 05:12:01 morioka Exp $
3 ;;;
4
5 (provide 'mime-setup)
6
7
8 ;;; @ for Emacs 18
9 ;;;
10 (if (< (string-to-int emacs-version) 19)
11     (progn
12       (require 'tl-18)
13       (defvar buffer-undo-list nil)
14       ))
15
16
17 ;;; @ variables
18 ;;;
19 (defvar mime-setup-use-sc t)
20
21
22 ;;; @ for Edit MIME mode
23 ;;;
24 (autoload 'mime-mode "mime" "Edit MIME message." t)
25 (autoload 'mime-convert-buffer "mime" "convert to MIME." t)
26
27 (autoload 'mime/encode-message-header "tiny-mime"
28           "convert message header to MIME style." t)
29
30 (autoload 'insert-signature "signature" "Insert signature" t)
31
32 (add-hook 'mime-mode-hook
33           (function
34            (lambda ()
35              (define-key (current-local-map)
36                "\C-c\C-s" (function insert-signature))
37              )))
38 (setq mime-translate-hook (function mime/encode-message-header))
39
40 (if (boundp 'MULE)
41     (progn
42       (defun mime-header-charset-chooser-for-mule-no-encode-ISO-2022-JP (begin end)
43         (let ((lclist (find-charset-region begin end)))
44           (cond ((null lclist) nil)             ;US-ASCII requres no encoding.
45                 ((memq lc-ltn1 lclist)
46                  '("ISO-8859-1" . "Q"))
47                 ((memq lc-ltn2 lclist)
48                  '("ISO-8859-2" . "Q"))
49                 ((memq lc-ltn3 lclist)
50                  '("ISO-8859-3" . "Q"))
51                 ((memq lc-ltn4 lclist)
52                  '("ISO-8859-4" . "Q"))
53                 ((memq lc-crl lclist)
54                  '("ISO-8859-5" . "Q"))
55                 ;;((memq lc-arb lclist)
56                 ;; '("ISO-8859-6" . "Q"))
57                 ((memq lc-grk lclist)
58                  '("ISO-8859-7" . "Q"))
59                 ((memq lc-hbw lclist)
60                  '("ISO-8859-8" . "Q"))
61                 ((memq lc-ltn5 lclist)
62                  '("ISO-8859-9" . "Q"))
63                 ((memq lc-jp lclist) nil)
64                 (t                              ;Unknown charset.  It must be Mule!
65                  '("X-ISO-2022-JP-2" . "B"))
66                 )))
67       (setq mime-header-charset-chooser
68             'mime-header-charset-chooser-for-mule-no-encode-ISO-2022-JP)
69       )
70   (progn
71     (defun mime-header-charset-chooser-for-nemacs-no-encode-ISO-2022-JP (begin end))
72     (setq mime-header-charset-chooser
73           'mime-header-charset-chooser-for-nemacs-no-encode-ISO-2022-JP)
74     ))
75
76 (setq mime-content-types
77       '(("text"
78          ;; Charset parameter need not to be specified, since it is
79          ;; defined automatically while translation.
80          ("plain"
81           ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8")
82           )
83          ("richtext"
84           ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8")
85           )
86          ("x-latex"
87           ("x-name")
88           ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8")
89           ))
90         ("message"
91          ("external-body"
92           ("access-type"
93            ("anon-ftp"
94             ("site" "wnoc-fuk.wide.ad.jp" "nic.karrn.ad.jp")
95             ("directory")
96             ("name")
97             ("mode" "binary" "ascii"))
98            ("ftp"
99             ("site")
100             ("directory")
101             ("name")
102             ("mode" "binary" "ascii"))
103            ("tftp"
104             ("site")
105             ("name"))
106            ("afs"
107             ("site")
108             ("name"))
109            ("local-file"
110             ("site")
111             ("name"))
112            ("mail-server"
113             ("server"))))
114          ("rfc822"))
115         ("application"
116          ("octet-stream"
117           ("name")
118           ("type" "" "tar" "shar")
119           ("conversions"))
120          ("postscript")
121          ("x-kiss"
122           ("x-name")
123           ("x-cnf")))
124         ("image"
125          ("gif"  ("x-name"))
126          ("jpeg" ("x-name"))
127          ("x-pic"  ("x-name"))
128          ("x-xwd")
129          ("x-xbm"))
130         ("audio"
131          ("basic"))
132         ("video"
133          ("mpeg")))
134       )
135
136 (setq mime-file-types
137       '(("\\.rtf$"      "text"  "richtext"      nil     nil)
138         ("\\.ps$"       "application"   "postscript"    nil     "quoted-printable")
139         ("\\.gif$"      "image"         "gif"   nil     "base64")
140         ("\\.jpg$"      "image"         "jpeg"  nil     "base64")
141         ("\\.xwd$"      "image"         "x-xwd" nil     "base64")
142         ("\\.xbm$"      "image"         "x-xbm" nil     "base64")
143         ("\\.PIC$"      "image"         "x-pic" nil     "base64")
144         ("\\.pic$"      "image"         "x-pic" nil     "base64")
145         ("\\.tiff$"     "image"        "x-tiff" nil     "base64")
146         ("\\.au$"       "audio"         "basic" nil     "base64")
147         ("\\.mpg$"      "video"         "mpeg"  nil     "base64")
148         ("\\.el$"       "application"   "octet-stream"  nil     "7bit")
149         ("\\.signature" "text"  "plain" nil     nil)
150         (".*"   nil             nil     nil     nil))
151       )
152
153 (add-hook 'news-reply-mode-hook (function mime/decode-message-header))
154
155
156 ;;; @ about SuperCite
157 ;;;
158 (if mime-setup-use-sc
159     (progn
160       ;;
161       ;; SuperCite
162       ;;
163       (autoload 'sc-cite-original "sc" nil t)
164       (setq sc-citation-leader "")
165       (if (and (boundp 'MULE) MULE)
166           ;; for MULE
167           (setq sc-cite-regexp
168                 "\\s *\\([a-zA-Z0-9]\\|\\cj\\)*>+\\s *")
169         ;; for Nemacs
170         (setq sc-cite-regexp
171               "\\s *\\([a-zA-Z0-9]\\|\\cc\\|\\cC\\|\\ch\\|\\cH\\|\\ck\\|\\cK\\)*>+\\s *")
172         )
173       
174       (defun my-sc-overload-hook ()
175         (require 'sc-oloads)
176         (sc-overload-functions)
177         )
178       
179       ;; for all but MH-E
180       (setq mail-yank-hooks 'sc-cite-original)
181       
182       ;; for RMAIL, PCMAIL, GNUS
183       (add-hook 'mail-setup-hook (function my-sc-overload-hook))
184       
185       ;; for Gnus
186       (add-hook 'news-reply-mode-hook (function my-sc-overload-hook))
187       (add-hook 'gnews-ready-hook (function my-sc-overload-hook))
188       
189       ;; for mh-e
190       (add-hook 'mh-letter-mode-hook (function my-sc-overload-hook))
191       (setq mh-yank-hooks 'sc-cite-original)  ; for MH-E only
192       
193       ;;
194       ;; sc-register
195       ;;
196       ;; (setq sc-load-hook
197       ;;       '(lambda ()
198       ;;          (require 'sc-register)
199       ;;          (setq sc-rewrite-header-list
200       ;;                (append sc-rewrite-header-list
201       ;;                        (list (list 'sc-header-in-Japanese))
202       ;;                        ))
203       ;;          (setq sc-preferred-header-style
204       ;;                (- (length sc-rewrite-header-list) 1))
205       ;;          ))
206       (setq sc-preferred-attribution 'registeredname)
207       ))
208
209
210 ;;; @ for mh-e
211 ;;;
212 (add-hook 'mh-folder-mode-hook
213           (function
214            (lambda ()
215              (require 'tm-mh-e)
216              )))
217 (if (boundp 'NEMACS)
218     (add-hook 'mh-letter-mode-hook
219               (function
220                (lambda ()
221                  (setq kanji-fileio-code 2)
222                  )))
223   )
224 (add-hook 'mh-letter-mode-hook (function mime/decode-message-header))
225 (add-hook 'mh-letter-mode-hook
226           (function
227            (lambda ()
228              (mime-mode)
229              (make-local-variable 'mail-header-separator)
230              (setq mail-header-separator "--------"))
231            ))
232
233
234 ;;; @ for GNUS
235 ;;;
236 (let ((le (function
237            (lambda ()
238              (require 'tm-gnus)
239              )))
240       )
241   (if (boundp 'MULE)
242       (progn
243         (add-hook 'gnus-Group-mode-hook (function gnusutil-initialize))
244         (add-hook 'gnus-group-mode-hook (function gnusutil-initialize))
245         (autoload 'gnusutil-initialize "gnusutil")
246         (autoload 'gnusutil-add-group "gnusutil")
247         (add-hook 'gnusutil-initialize-hook le)
248         )
249     (progn
250       (add-hook 'gnus-Startup-hook le)
251       (add-hook 'gnus-startup-hook le)
252       )))
253
254 (add-hook 'news-reply-mode-hook (function mime-mode))
255 (setq gnus-signature-file nil)
256
257
258 ;;; @ for RMAIL
259 ;;;
260 (autoload 'rmail-show-mime              "rmailmime" "Show MIME messages."  t)
261 (autoload 'rmail-convert-mime-header    "rmailmime" "Convert MIME header." nil)
262 (setq rmail-message-filter 'mime/decode-message-header)
263 (add-hook 'rmail-mode-hook
264           (function
265            (lambda ()
266              ;; Forward mail using MIME.
267              (require 'mime)
268              (substitute-key-definition 'rmail-forward
269                                         'mime-forward-from-rmail-using-mail
270                                         (current-local-map))
271              (local-set-key "v" 'rmail-show-mime)
272              )))
273
274
275 ;;; @ for Mail mode (includes VM mode)
276 ;;;
277 (add-hook 'mail-mode-hook (function mime-mode))
278 (add-hook 'mail-setup-hook (function mime/decode-message-header))
279
280 ;;; @@ In VM, the following definitions may be requried:
281 ;;; 
282 (if (boundp 'vm-visible-headers)
283     (progn
284       (setq vm-preview-lines nil)
285       (setq vm-invisible-header-regexp nil)
286       (setq vm-visible-headers
287             (append vm-visible-headers
288                     '("Mime-Version:"
289                       "Content-Type:"
290                       "Content-Transfer-Encoding:")))
291       ))
292
293 ;;; Local Variables:
294 ;;; mode: emacs-lisp
295 ;;; mode: outline-minor
296 ;;; outline-regexp: ";;; @+\\|(......"
297 ;;; End: