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