1 ;;; emu-x20.el --- emu API implementation for XEmacs with mule
3 ;; Copyright (C) 1994,1995,1996,1997,1998 MORIOKA Tomohiko
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: emulation, compatibility, Mule, XEmacs
8 ;; This file is part of emu.
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; This module requires XEmacs 20.3-b5 or later with mule.
31 (and (coding-system-property 'iso-2022-jp 'input-charset-conversion)
32 (copy-coding-system 'iso-2022-7bit 'iso-2022-jp))
38 (defun insert-file-contents-as-binary (filename
39 &optional visit beg end replace)
40 "Like `insert-file-contents', q.v., but don't code and format conversion.
41 Like `insert-file-contents-literary', but it allows find-file-hooks,
42 automatic uncompression, etc.
44 Namely this function ensures that only format decoding and character
45 code conversion will not take place."
46 (let ((coding-system-for-read 'binary)
48 (insert-file-contents filename visit beg end replace)
51 (define-obsolete-function-alias 'insert-binary-file-contents
52 'insert-file-contents-as-binary)
54 (defun insert-binary-file-contents-literally (filename
55 &optional visit beg end replace)
56 "Like `insert-file-contents-literally', q.v., but don't code conversion.
57 A buffer may be modified in several ways after reading into the buffer due
58 to advanced Emacs features, such as file-name-handlers, format decoding,
60 This function ensures that none of these modifications will take place."
61 (let ((coding-system-for-read 'binary))
62 (insert-file-contents-literally filename visit beg end replace)
69 (defun encode-mime-charset-region (start end charset)
70 "Encode the text between START and END as MIME CHARSET."
71 (let ((cs (mime-charset-to-coding-system charset)))
73 (encode-coding-region start end cs)
76 (defcustom mime-charset-decoder-alist
77 '((iso-2022-jp . decode-mime-charset-region-with-iso646-unification)
78 (iso-2022-jp-2 . decode-mime-charset-region-with-iso646-unification)
79 (x-ctext . decode-mime-charset-region-with-iso646-unification)
80 (hz-gb-2312 . decode-mime-charset-region-for-hz)
81 (t . decode-mime-charset-region-default))
82 "Alist MIME-charset vs. decoder function."
84 :type '(repeat (cons mime-charset function)))
86 (defsubst decode-mime-charset-region-default (start end charset)
87 (let ((cs (mime-charset-to-coding-system charset)))
89 (decode-coding-region start end cs)
92 (defcustom mime-iso646-character-unification-alist
97 (cons (cons (char-to-string (make-char 'latin-jisx0201 i))
104 (cons (cons (char-to-string (make-char 'latin-jisx0201 i))
109 "Alist unified string vs. canonical string."
111 :type '(repeat (cons string string)))
113 (defcustom mime-unified-character-face nil
114 "*Face of unified character."
118 (defun decode-mime-charset-region-with-iso646-unification (start end charset)
119 (decode-mime-charset-region-default start end charset)
121 (let ((rest mime-iso646-character-unification-alist))
123 (let ((pair (car rest)))
124 (goto-char (point-min))
125 (while (search-forward (car pair) nil t)
126 (let ((str (cdr pair)))
127 (put-text-property 0 (length str)
128 'face mime-unified-character-face str)
129 (replace-match str 'fixed-case 'literal)
132 (setq rest (cdr rest))))))
134 (defun decode-mime-charset-region-for-hz (start end charset)
135 (decode-hz-region start end))
137 (defun decode-mime-charset-region (start end charset)
138 "Decode the text between START and END as MIME CHARSET."
139 (if (stringp charset)
140 (setq charset (intern (downcase charset)))
142 (let ((func (cdr (or (assq charset mime-charset-decoder-alist)
143 (assq t mime-charset-decoder-alist)))))
144 (funcall func start end charset)
147 (defsubst encode-mime-charset-string (string charset)
148 "Encode the STRING as MIME CHARSET."
149 (let ((cs (mime-charset-to-coding-system charset)))
151 (encode-coding-string string cs)
154 ;; (defsubst decode-mime-charset-string (string charset)
155 ;; "Decode the STRING as MIME CHARSET."
156 ;; (let ((cs (mime-charset-to-coding-system charset)))
158 ;; (decode-coding-string string cs)
160 (defun decode-mime-charset-string (string charset)
161 "Decode the STRING as MIME CHARSET."
164 (decode-mime-charset-region (point-min)(point-max) charset)
169 (defvar charsets-mime-charset-alist
170 '(((ascii) . us-ascii)
171 ((ascii latin-iso8859-1) . iso-8859-1)
172 ((ascii latin-iso8859-2) . iso-8859-2)
173 ((ascii latin-iso8859-3) . iso-8859-3)
174 ((ascii latin-iso8859-4) . iso-8859-4)
175 ((ascii cyrillic-iso8859-5) . iso-8859-5)
176 ;;; ((ascii cyrillic-iso8859-5) . koi8-r)
177 ((ascii arabic-iso8859-6) . iso-8859-6)
178 ((ascii greek-iso8859-7) . iso-8859-7)
179 ((ascii hebrew-iso8859-8) . iso-8859-8)
180 ((ascii latin-iso8859-9) . iso-8859-9)
181 ((ascii latin-jisx0201
182 japanese-jisx0208-1978 japanese-jisx0208) . iso-2022-jp)
183 ((ascii latin-jisx0201
184 katakana-jisx0201 japanese-jisx0208) . shift_jis)
185 ((ascii korean-ksc5601) . euc-kr)
186 ((ascii chinese-gb2312) . cn-gb-2312)
187 ((ascii chinese-big5-1 chinese-big5-2) . cn-big5)
188 ((ascii latin-iso8859-1 greek-iso8859-7
189 latin-jisx0201 japanese-jisx0208-1978
190 chinese-gb2312 japanese-jisx0208
191 korean-ksc5601 japanese-jisx0212) . iso-2022-jp-2)
192 ((ascii latin-iso8859-1 greek-iso8859-7
193 latin-jisx0201 japanese-jisx0208-1978
194 chinese-gb2312 japanese-jisx0208
195 korean-ksc5601 japanese-jisx0212
196 chinese-cns11643-1 chinese-cns11643-2) . iso-2022-int-1)
197 ((ascii latin-iso8859-1 latin-iso8859-2
198 cyrillic-iso8859-5 greek-iso8859-7
199 latin-jisx0201 japanese-jisx0208-1978
200 chinese-gb2312 japanese-jisx0208
201 korean-ksc5601 japanese-jisx0212
202 chinese-cns11643-1 chinese-cns11643-2
203 chinese-cns11643-3 chinese-cns11643-4
204 chinese-cns11643-5 chinese-cns11643-6
205 chinese-cns11643-7) . iso-2022-int-1)
212 (defmacro char-next-index (char index)
213 "Return index of character succeeding CHAR whose index is INDEX."
216 ;;; @@ Mule emulating aliases
218 ;;; You should not use them.
220 ;;(defalias 'char-leading-char 'char-charset)
222 (defun char-category (character)
223 "Return string of category mnemonics for CHAR in TABLE.
224 CHAR can be any multilingual character
225 TABLE defaults to the current buffer's category table."
226 (mapconcat (lambda (chr)
227 (char-to-string (int-char chr))
229 (char-category-list character)
236 (defun string-to-int-list (str)
237 (mapcar #'char-int str)
240 (defalias 'looking-at-as-unibyte 'looking-at)
248 ;;; emu-x20.el ends here