70
|
1 ;;; emu-x20.el --- emu API implementation for XEmacs 20 with mule
|
|
2
|
86
|
3 ;; Copyright (C) 1994,1995,1996,1997 MORIOKA Tomohiko
|
70
|
4
|
|
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
|
110
|
6 ;; Version: $Id: emu-x20.el,v 1.5 1997/03/16 03:05:43 steve Exp $
|
70
|
7 ;; Keywords: emulation, compatibility, Mule, XEmacs
|
|
8
|
86
|
9 ;; This file is part of XEmacs.
|
70
|
10
|
|
11 ;; This program is free software; you can redistribute it and/or
|
|
12 ;; modify it under the terms of the GNU General Public License as
|
|
13 ;; published by the Free Software Foundation; either version 2, or (at
|
|
14 ;; your option) any later version.
|
|
15
|
|
16 ;; This program is distributed in the hope that it will be useful, but
|
|
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
19 ;; General Public License for more details.
|
|
20
|
|
21 ;; You should have received a copy of the GNU General Public License
|
|
22 ;; along with GNU XEmacs; see the file COPYING. If not, write to the
|
|
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
24 ;; Boston, MA 02111-1307, USA.
|
|
25
|
110
|
26 ;;; Commentary:
|
|
27
|
|
28 ;; This module requires XEmacs 20.1 b6 or later with mule.
|
|
29
|
|
30 ;;; Commentary:
|
|
31
|
|
32 ;; This module requires XEmacs 20.1 b6 or later with mule.
|
|
33
|
70
|
34 ;;; Code:
|
|
35
|
|
36 (require 'cyrillic)
|
|
37 (require 'emu-xemacs)
|
|
38
|
|
39
|
|
40 ;;; @ coding-system
|
|
41 ;;;
|
|
42
|
|
43 (defconst *noconv* 'no-conversion)
|
|
44
|
|
45 (defmacro as-binary-process (&rest body)
|
|
46 `(let (selective-display ; Disable ^M to nl translation.
|
110
|
47 (coding-system-for-write 'no-conversion)
|
70
|
48 process-input-coding-system
|
|
49 process-output-coding-system)
|
|
50 ,@body))
|
|
51
|
|
52 (defmacro as-binary-input-file (&rest body)
|
110
|
53 `(let ((coding-system-for-read 'no-conversion))
|
70
|
54 ,@body))
|
|
55
|
98
|
56 (defmacro as-binary-output-file (&rest body)
|
110
|
57 `(let ((coding-system-for-write 'no-conversion))
|
98
|
58 ,@body))
|
|
59
|
|
60
|
|
61 ;;; @ binary access
|
|
62 ;;;
|
|
63
|
|
64 (defun insert-binary-file-contents-literally
|
|
65 (filename &optional visit beg end replace)
|
|
66 "Like `insert-file-contents-literally', q.v., but don't code conversion.
|
|
67 A buffer may be modified in several ways after reading into the buffer due
|
|
68 to advanced Emacs features, such as file-name-handlers, format decoding,
|
|
69 find-file-hooks, etc.
|
|
70 This function ensures that none of these modifications will take place."
|
110
|
71 (let ((coding-system-for-read 'no-conversion))
|
98
|
72 (insert-file-contents-literally filename visit beg end replace)
|
|
73 ))
|
|
74
|
70
|
75
|
|
76 ;;; @ MIME charset
|
|
77 ;;;
|
|
78
|
|
79 (defvar charsets-mime-charset-alist
|
|
80 '(((ascii) . us-ascii)
|
74
|
81 ((ascii latin-iso8859-1) . iso-8859-1)
|
|
82 ((ascii latin-iso8859-2) . iso-8859-2)
|
|
83 ((ascii latin-iso8859-3) . iso-8859-3)
|
|
84 ((ascii latin-iso8859-4) . iso-8859-4)
|
|
85 ;;; ((ascii cyrillic-iso8859-5) . iso-8859-5)
|
|
86 ((ascii cyrillic-iso8859-5) . koi8-r)
|
|
87 ((ascii arabic-iso8859-6) . iso-8859-6)
|
|
88 ((ascii greek-iso8859-7) . iso-8859-7)
|
|
89 ((ascii hebrew-iso8859-8) . iso-8859-8)
|
|
90 ((ascii latin-iso8859-9) . iso-8859-9)
|
86
|
91 ((ascii latin-jisx0201
|
|
92 japanese-jisx0208-1978 japanese-jisx0208) . iso-2022-jp)
|
70
|
93 ((ascii korean-ksc5601) . euc-kr)
|
86
|
94 ((ascii chinese-gb2312) . cn-gb-2312)
|
|
95 ((ascii chinese-big5-1 chinese-big5-2) . cn-big5)
|
|
96 ((ascii latin-iso8859-1 greek-iso8859-7
|
|
97 latin-jisx0201 japanese-jisx0208-1978
|
|
98 chinese-gb2312 japanese-jisx0208
|
|
99 korean-ksc5601 japanese-jisx0212) . iso-2022-jp-2)
|
|
100 ((ascii latin-iso8859-1 greek-iso8859-7
|
|
101 latin-jisx0201 japanese-jisx0208-1978
|
|
102 chinese-gb2312 japanese-jisx0208
|
|
103 korean-ksc5601 japanese-jisx0212
|
|
104 chinese-cns11643-1 chinese-cns11643-2) . iso-2022-int-1)
|
|
105 ((ascii latin-iso8859-1 latin-iso8859-2
|
|
106 cyrillic-iso8859-5 greek-iso8859-7
|
|
107 latin-jisx0201 japanese-jisx0208-1978
|
|
108 chinese-gb2312 japanese-jisx0208
|
|
109 korean-ksc5601 japanese-jisx0212
|
74
|
110 chinese-cns11643-1 chinese-cns11643-2
|
86
|
111 chinese-cns11643-3 chinese-cns11643-4
|
|
112 chinese-cns11643-5 chinese-cns11643-6
|
|
113 chinese-cns11643-7) . iso-2022-int-1)
|
70
|
114 ))
|
|
115
|
86
|
116 (defvar default-mime-charset 'x-ctext)
|
70
|
117
|
|
118 (defvar mime-charset-coding-system-alist
|
86
|
119 '((iso-8859-1 . ctext)
|
|
120 (x-ctext . ctext)
|
|
121 (hz-gb-2312 . hz)
|
|
122 (cn-gb-2312 . euc-china)
|
|
123 (gb2312 . euc-china)
|
|
124 (cn-big5 . big5)
|
|
125 (koi8-r . koi8)
|
|
126 (iso-2022-jp-2 . iso-2022-ss2-7)
|
70
|
127 ))
|
|
128
|
|
129 (defun mime-charset-to-coding-system (charset)
|
|
130 "Return coding-system by MIME charset. [emu-x20.el]"
|
|
131 (if (stringp charset)
|
|
132 (setq charset (intern (downcase charset)))
|
|
133 )
|
|
134 (or (cdr (assq charset mime-charset-coding-system-alist))
|
|
135 (and (memq charset (coding-system-list)) charset)
|
|
136 ))
|
|
137
|
|
138 (defun detect-mime-charset-region (start end)
|
|
139 "Return MIME charset for region between START and END.
|
|
140 \[emu-x20.el]"
|
|
141 (charsets-to-mime-charset (charsets-in-region start end)))
|
|
142
|
|
143 (defun encode-mime-charset-region (start end charset)
|
|
144 "Encode the text between START and END as MIME CHARSET.
|
|
145 \[emu-x20.el]"
|
|
146 (let ((cs (mime-charset-to-coding-system charset)))
|
|
147 (if cs
|
|
148 (encode-coding-region start end cs)
|
|
149 )))
|
|
150
|
|
151 (defun decode-mime-charset-region (start end charset)
|
|
152 "Decode the text between START and END as MIME CHARSET.
|
|
153 \[emu-x20.el]"
|
|
154 (let ((cs (mime-charset-to-coding-system charset)))
|
|
155 (if cs
|
|
156 (decode-coding-region start end cs)
|
|
157 )))
|
|
158
|
|
159 (defun encode-mime-charset-string (string charset)
|
|
160 "Encode the STRING as MIME CHARSET. [emu-x20.el]"
|
|
161 (let ((cs (mime-charset-to-coding-system charset)))
|
|
162 (if cs
|
|
163 (encode-coding-string string cs)
|
|
164 string)))
|
|
165
|
|
166 (defun decode-mime-charset-string (string charset)
|
|
167 "Decode the STRING as MIME CHARSET. [emu-x20.el]"
|
|
168 (let ((cs (mime-charset-to-coding-system charset)))
|
|
169 (if cs
|
|
170 (decode-coding-string string cs)
|
|
171 string)))
|
|
172
|
|
173
|
|
174 ;;; @ character
|
|
175 ;;;
|
|
176
|
|
177 ;;; @@ Mule emulating aliases
|
|
178 ;;;
|
|
179 ;;; You should not use them.
|
|
180
|
|
181 (defalias 'char-leading-char 'char-charset)
|
|
182
|
|
183 (defun char-category (character)
|
|
184 "Return string of category mnemonics for CHAR in TABLE.
|
|
185 CHAR can be any multilingual character
|
|
186 TABLE defaults to the current buffer's category table.
|
|
187 \[emu-x20.el; Mule emulating function]"
|
|
188 (mapconcat (lambda (chr)
|
|
189 (char-to-string (int-char chr))
|
|
190 )
|
|
191 (char-category-list character)
|
|
192 ""))
|
|
193
|
|
194
|
|
195 ;;; @ string
|
|
196 ;;;
|
|
197
|
|
198 (defun string-to-int-list (str)
|
|
199 (mapcar #'char-int str)
|
|
200 )
|
|
201
|
|
202
|
|
203 ;;; @ end
|
|
204 ;;;
|
|
205
|
|
206 (provide 'emu-x20)
|
|
207
|
|
208 ;;; emu-x20.el ends here
|