1 ;;; mew-mule2.el --- Environment of Mule version 2 for Mew
3 ;; Author: Kazu Yamamoto <Kazu@Mew.org>
4 ;; Created: Mar 20, 1997
5 ;; Revised: Aug 30, 1999
9 (defconst mew-mule2-version "mew-mule2.el version 0.09")
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)))
16 ;; In the context of Mew, 'charset' means MIME charset.
17 ;; 'cs' means the internal representation of Emacs (was known as Mule).
20 ;; User CS definitions
23 (define-ccl-program mew-ccl-*-to-lf
33 (write-read-repeat r0)))))
34 "Read text with any eol converting to the LF eol.")
36 (define-ccl-program mew-ccl-lf-to-lf
40 (write-read-repeat r0))))
41 "Write text with the LF eol.")
43 (define-ccl-program mew-ccl-lf-to-crlf
50 "Write text with the CRLF eol.")
52 (define-ccl-program mew-ccl-lf-to-cr
59 "Write text with the CR eol.")
61 (make-coding-system 'mew-cs-text
62 4 ?= "No conversion" nil
63 (cons mew-ccl-*-to-lf mew-ccl-lf-to-lf))
65 (make-coding-system 'mew-cs-text-lf
66 4 ?= "No conversion" nil
67 (cons mew-ccl-*-to-lf mew-ccl-lf-to-lf))
69 (make-coding-system 'mew-cs-text-crlf
70 4 ?= "No conversion" nil
71 (cons mew-ccl-*-to-lf mew-ccl-lf-to-crlf))
73 (make-coding-system 'mew-cs-text-cr
74 4 ?= "No conversion" nil
75 (cons mew-ccl-*-to-lf mew-ccl-lf-to-cr))
77 (defvar mew-cs-dummy '*noconv*)
78 (defvar mew-cs-binary '*noconv*)
79 (defvar mew-cs-text-for-read 'mew-cs-text)
80 (defvar mew-cs-text-for-write 'mew-cs-text-lf)
81 (defvar mew-cs-autoconv '*autoconv*)
82 (defvar mew-cs-7bit '*iso-2022-ss2-7*)
83 (defvar mew-cs-7bit-crlf '*iso-2022-ss2-7*dos)
84 (defvar mew-cs-mime-trans '*iso-2022-ss2-7*)
85 (defvar mew-cs-rfc822-trans '*iso-2022-ss2-7*)
86 (defvar mew-cs-draft '*iso-2022-ss2-7*)
87 (defvar mew-cs-scan '*ctext*)
88 (defvar mew-cs-infile '*autoconv*)
89 (defvar mew-cs-outfile '*iso-2022-ss2-7*)
90 (defvar mew-cs-virtual (if (mew-coding-system-p '*ctext*unix)
91 '*ctext*unix '*ctext*)) ;; ^M as it is
92 (defvar mew-cs-pick '*euc-japan*)
94 (defvar mew-cs-database
95 '(("us-ascii" (0) nil "7bit"
97 ("iso-8859-1" (0 129) *iso-8859-1* "quoted-printable"
99 ("iso-8859-2" (0 130) *iso-8859-2* "quoted-printable"
101 ("iso-8859-3" (0 131) *iso-8859-3* "quoted-printable"
103 ("iso-8859-4" (0 132) *iso-8859-4* "quoted-printable"
105 ("koi8-r" (0 140) *koi8* "quoted-printable"
107 ("iso-8859-6" (0 135) *iso-8859-6* "base64"
109 ("iso-8859-7" (0 134) *iso-8859-7* "base64"
111 ("iso-8859-8" (0 136) *iso-8859-8* "base64"
113 ("iso-8859-9" (0 141) *iso-8859-9* "quoted-printable"
115 ("tis-620" (0 133 128) *tis620* "base64"
117 ("iso-2022-jp" (0 138 146 144) *iso-2022-jp* "7bit"
119 ("euc-kr" (0 147) *euc-kr* "base64"
121 ("iso-2022-kr" (0 147) *iso-2022-kr* "7bit"
123 ("gb2312" (0 145) *euc-china* "base64"
125 ("hz-gb-2312" (0 145) *hz* "base64"
127 ("big5" (0 152 153) *big5* "base64"
129 ("iso-2022-jp-2" (0 138 146 144 145 147 148 129 134)
130 *iso-2022-ss2-7* "7bit" *iso-2022-ss2-7* "B")
131 ;; charset-to-cs purpose only
132 ("euc-jp" nil *euc-japan*)
133 ("shift_jis" nil *sjis*)
134 ("cn-gb" nil *euc-china*) ;; the same as gb2312 above
135 ("cn-big5" nil *big5*) ;; the same as big5 above
136 ; ("iso-2022-cn" nil xxx)
137 ; ("iso-2022-cn-ext" nil xxx)
138 ("iso-2022-int-1" nil *iso-2022-int-1*)
142 ;; Leading characters
145 (defvar mew-lc-ascii 0)
146 (defvar mew-lc-kana 137)
147 (defvar mew-lc-jp 146)
148 (fset 'mew-make-char (symbol-function 'make-character))
150 (defun mew-char-charset (char)
153 (t (aref (char-to-string char) 0))))
159 (defun mew-find-cs-region (beg end)
162 (narrow-to-region beg end)
163 (goto-char (point-min))
164 (let ((re-official "[^\232-\235\240-\377")
165 (re-private "\\|[\232-\235][^\000-\237")
167 (while (re-search-forward (concat re-official "]" re-private "]")
169 (setq lc (preceding-char))
173 (setq re-official (concat re-official "\000-\177")))
175 (setq re-official (concat re-official (char-to-string lc))))
177 (setq re-private (concat re-private (char-to-string lc))))
179 (setq lclist (cons lc lclist)))
183 (defun mew-cs-decode-region (beg end cs)
184 (if cs (code-convert-region beg end cs '*internal*)))
187 (defun mew-cs-encode-region (beg end cs)
188 (if cs (code-convert-region beg end '*internal* cs)))
191 (defun mew-cs-decode-string (str cs)
192 (if cs (code-convert-string str cs '*internal*) str))
195 (defun mew-cs-encode-string (str cs)
196 (if cs (code-convert-string str '*internal* cs) str))
199 ;; Process environment
202 (defun mew-set-process-cs (pro from-pro to-pro)
203 (set-process-coding-system pro from-pro to-pro))
205 (defmacro mew-plet (&rest body)
206 (` (let ((call-process-hook nil)
207 (default-process-coding-system
208 (cons '*noconv* '*noconv*)))
211 (defmacro mew-piolet (input output &rest body)
212 (` (let ((call-process-hook nil)
213 (default-process-coding-system
214 (cons (, input) (, output))))
217 (defmacro mew-pioalet (input output arg &rest body)
218 (` (let ((call-process-hook nil)
219 (default-process-coding-system
220 (cons (, input) (, output)))
221 (pathname-coding-system (, arg)))
224 (defmacro mew-flet (&rest body)
225 (` (let ((file-coding-system '*noconv*)
226 (file-coding-system-for-read '*noconv*)
227 jam-zcat-filename-list
228 jka-compr-compression-info-list)
231 (defmacro mew-frwlet (read write &rest body)
232 (` (let ((file-coding-system (, write))
233 (file-coding-system-for-read (, read))
234 jam-zcat-filename-list
235 jka-compr-compression-info-list)
242 (defmacro mew-cs-post-conv (cs)
243 (` (get (, cs) 'post-read-conversion)))
249 (fset 'mew-aref (symbol-function 'sref))
250 (fset 'mew-charlen (symbol-function 'char-bytes))
259 ;;; Copyright Notice:
261 ;; Copyright (C) 1997, 1998, 1999 Mew developing team.
262 ;; All rights reserved.
264 ;; Redistribution and use in source and binary forms, with or without
265 ;; modification, are permitted provided that the following conditions
268 ;; 1. Redistributions of source code must retain the above copyright
269 ;; notice, this list of conditions and the following disclaimer.
270 ;; 2. Redistributions in binary form must reproduce the above copyright
271 ;; notice, this list of conditions and the following disclaimer in the
272 ;; documentation and/or other materials provided with the distribution.
273 ;; 3. Neither the name of the team nor the names of its contributors
274 ;; may be used to endorse or promote products derived from this software
275 ;; without specific prior written permission.
277 ;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
278 ;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
279 ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
280 ;; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE
281 ;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
282 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
283 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
284 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
285 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
286 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
287 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
289 ;;; mew-mule2.el ends here