Initial Commit
[packages] / xemacs-packages / mew / mew / mew-mule3.el
1 ;;; mew-mule3.el --- Environment of Mule version 3 for Mew
2
3 ;; Author:  Kazu Yamamoto <Kazu@Mew.org>
4 ;; Created: Mar 20, 1997
5 ;; Revised: Aug 30, 1999
6
7 ;;; Code:
8
9 (defconst mew-mule3-version "mew-mule3.el version 0.14")
10
11 ;; must be here
12 (if (fboundp 'find-coding-system)
13     (fset 'mew-coding-system-p (symbol-function 'find-coding-system))
14   (fset 'mew-coding-system-p (symbol-function 'coding-system-p)))
15
16 ;; In the context of Mew, 'charset' means MIME charset.
17 ;; 'cs' means the internal representation of Emacs (was known as Mule).
18
19 ;;
20 ;; User CS definitions
21 ;;
22
23 ;; iso-2022-7bit-ss2 is iso-2022-jp-2
24
25 (cond
26  (mew-xemacs-p
27   (copy-coding-system 'no-conversion      'mew-cs-text)
28   (copy-coding-system 'no-conversion-unix 'mew-cs-text-lf)
29   (copy-coding-system 'no-conversion-dos  'mew-cs-text-crlf)
30   (copy-coding-system 'no-conversion-mac  'mew-cs-text-cr))
31  (t
32   (define-coding-system-alias 'mew-cs-text      'raw-text)
33   (define-coding-system-alias 'mew-cs-text-lf   'raw-text-unix)
34   (define-coding-system-alias 'mew-cs-text-crlf 'raw-text-dos)
35   (define-coding-system-alias 'mew-cs-text-cr   'raw-text-mac)))
36
37 (defvar mew-cs-dummy          'binary)
38 (defvar mew-cs-binary         'binary)
39 (defvar mew-cs-text-for-read  'mew-cs-text)
40 (defvar mew-cs-text-for-write 'mew-cs-text-lf)
41 (defvar mew-cs-autoconv       'undecided)
42 (defvar mew-cs-7bit           'iso-2022-7bit-ss2)
43 (defvar mew-cs-7bit-crlf      'iso-2022-7bit-ss2-dos)
44 (defvar mew-cs-mime-trans     'iso-2022-7bit-ss2)
45 (defvar mew-cs-rfc822-trans   'iso-2022-7bit-ss2)
46 (defvar mew-cs-draft          'iso-2022-7bit-ss2)
47 (defvar mew-cs-scan           'ctext)
48 (defvar mew-cs-infile         'undecided) ;; guess in +draft
49 (defvar mew-cs-outfile        'iso-2022-7bit-ss2)
50 (defvar mew-cs-virtual        (if (mew-coding-system-p 'ctext-unix)
51                                   'ctext-unix 'ctext)) ;; ^M as it is
52 (defvar mew-cs-pick           'euc-jp)
53
54 (defvar mew-cs-database
55   '(("us-ascii"    (ascii)                    nil        "7bit"
56                                               nil        "Q")
57     ("iso-8859-1"  (ascii latin-iso8859-1)    iso-8859-1 "quoted-printable"
58                                               iso-8859-1 "Q")
59     ("iso-8859-2"  (ascii latin-iso8859-2)    iso-8859-2 "quoted-printable"
60                                               iso-8859-2 "Q")
61     ("iso-8859-3"  (ascii latin-iso8859-3)    iso-8859-3 "quoted-printable"
62                                               iso-8859-3 "Q")
63     ("iso-8859-4"  (ascii latin-iso8859-4)    iso-8859-4 "quoted-printable"
64                                               iso-8859-4 "Q")
65     ("koi8-r"      (ascii cyrillic-iso8859-5) koi8-r     "quoted-printable"
66                                               koi8-r     "Q")
67     ("iso-8859-6"  (ascii arabic-iso8859-6)   iso-8859-6 "base64"
68                                               iso-8859-6 "B")
69     ("iso-8859-7"  (ascii greek-iso8859-7)    iso-8859-7 "base64"
70                                               iso-8859-7 "B")
71     ("iso-8859-8"  (ascii hebrew-iso8859-8)   iso-8859-8 "base64"
72                                               iso-8859-8 "B")
73     ("iso-8859-9"  (ascii latin-iso8859-9)    iso-8859-9 "quoted-printable"
74                                               iso-8859-9 "Q")
75     ("tis-620"     (ascii thai-tis620)        tis620     "base64"
76                                               tis620     "B")
77     ("iso-2022-jp"
78      (ascii latin-jisx0201 japanese-jisx0208 japanese-jisx0208-1978)
79                                               iso-2022-jp "7bit"
80                                               iso-2022-jp "B")
81     ("euc-kr" (ascii korean-ksc5601)          euc-kr      "base64"
82                                               euc-kr      "B")
83     ("iso-2022-kr" (ascii korean-ksc5601)     iso-2022-kr "7bit"
84                                               euc-kr      "B")
85     ("gb2312" (ascii chinese-gb2312)          cn-gb-2312  "base64"
86                                               cn-gb-2312  "B")
87     ("hz-gb-2312" (ascii chinese-gb2312)      hz-gb-2312  "7bit"
88                                               hz-gb-2312  "B")
89     ("big5" (ascii chinese-big5-1 chinese-big5-2)
90                                               chinese-big5 "base64"
91                                               chinese-big5 "B")
92     ("iso-2022-jp-2" 
93      (ascii
94       latin-jisx0201 japanese-jisx0208 japanese-jisx0208-1978 japanese-jisx0212
95       chinese-gb2312 korean-ksc5601 latin-iso8859-1 greek-iso8859-7)
96                                               iso-2022-7bit-ss2 "7bit"
97                                               iso-2022-7bit-ss2 "B")
98     ;; charset-to-cs purpose only
99     ("euc-jp"          nil euc-japan)
100     ("shift_jis"       nil shift_jis)
101     ("cn-gb"           nil cn-gb-2312)   ;; the same as gb2312 above
102     ("cn-big5"         nil chinese-big5) ;; the same as big5 above
103     ("iso-2022-cn"     nil iso-2022-cn)
104     ("iso-2022-cn-ext" nil iso-2022-cn-ext)
105     ("iso-2022-int-1"  nil iso-2022-int-1)
106     ))
107
108 ;;
109 ;; Leading characters
110 ;;
111
112 (defvar mew-lc-ascii 'ascii)
113 (defvar mew-lc-jp    'japanese-jisx0208)
114 (defvar mew-lc-kana  'katakana-jisx0201)
115 (defalias 'mew-make-char 'make-char)
116 (defalias 'mew-char-charset 'char-charset)
117
118 ;;
119 ;; CS
120 ;;
121
122 (defalias 'mew-find-cs-region 'find-charset-region)
123
124 ;; to internal
125 (defun mew-cs-decode-region (beg end cs)
126   (if cs (decode-coding-region beg end cs)))
127
128 ;; to extenal
129 (defun mew-cs-encode-region (beg end cs)
130   (if cs (encode-coding-region beg end cs)))
131
132 ;; to internal
133 (defun mew-cs-decode-string (str cs)
134   (if cs (decode-coding-string str cs) str))
135
136 ;; to external
137 (defun mew-cs-encode-string (str cs)
138   (if cs (encode-coding-string str cs) str))
139
140 ;;
141 ;; Process environment
142 ;;
143
144 (defun mew-set-process-cs (process read write)
145   (set-process-coding-system process read write))
146
147 (defmacro mew-plet (&rest body)
148   `(let ((call-process-hook nil)
149          (coding-system-for-read  'binary)
150          (coding-system-for-write 'binary))
151      ,@body))
152
153 (defmacro mew-piolet (read write &rest body)
154   `(let ((call-process-hook nil)
155          (coding-system-for-read  ,read)
156          (coding-system-for-write ,write))
157      ,@body))
158
159 (defmacro mew-pioalet (read write arg &rest body)
160   `(let ((call-process-hook nil)
161          (coding-system-for-read  ,read)
162          (coding-system-for-write ,write)
163          (file-name-coding-system ,arg))
164      ,@body))
165
166 (defmacro mew-flet (&rest body)
167   `(let ((coding-system-for-read  'binary)
168          (coding-system-for-write 'binary)
169           jam-zcat-filename-list
170           jka-compr-compression-info-list)
171      ,@body))
172
173 (defmacro mew-frwlet (read write &rest body)
174   `(let ((coding-system-for-read  ,read)
175          (coding-system-for-write ,write)
176           jam-zcat-filename-list
177           jka-compr-compression-info-list)
178      ,@body))
179
180 ;;
181 ;; Post conversion
182 ;;
183
184 (defun mew-cs-post-conv (cs) ()) ;; not necessary because internally applied
185
186 ;;
187 ;;
188 ;;
189
190 (cond
191  ((and mew-temacs-p (string< emacs-version "20.2.90"))
192   (fset 'mew-aref (symbol-function 'sref))
193   (fset 'mew-charlen (symbol-function 'char-bytes)))
194  (t
195   (fset 'mew-aref (symbol-function 'aref))
196   (defmacro mew-charlen (c) (` 1)))
197  )
198
199 ;;
200 ;;
201 ;;
202
203 (require 'mew-mule)
204 (provide 'mew-mule3)
205
206 ;;; Copyright Notice:
207
208 ;; Copyright (C) 1997, 1998, 1999 Mew developing team.
209 ;; All rights reserved.
210
211 ;; Redistribution and use in source and binary forms, with or without
212 ;; modification, are permitted provided that the following conditions
213 ;; are met:
214 ;; 
215 ;; 1. Redistributions of source code must retain the above copyright
216 ;;    notice, this list of conditions and the following disclaimer.
217 ;; 2. Redistributions in binary form must reproduce the above copyright
218 ;;    notice, this list of conditions and the following disclaimer in the
219 ;;    documentation and/or other materials provided with the distribution.
220 ;; 3. Neither the name of the team nor the names of its contributors
221 ;;    may be used to endorse or promote products derived from this software
222 ;;    without specific prior written permission.
223 ;; 
224 ;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
225 ;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
226 ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
227 ;; PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE
228 ;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
229 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
230 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
231 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
232 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
233 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
234 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
235
236 ;;; mew-mule3.el ends here