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 ;; (require 'emu-xemacs)
35 (and (coding-system-property 'iso-2022-jp 'input-charset-conversion)
36 (copy-coding-system 'iso-2022-7bit 'iso-2022-jp))
42 (defun insert-file-contents-as-binary (filename
43 &optional visit beg end replace)
44 "Like `insert-file-contents', q.v., but don't code and format conversion.
45 Like `insert-file-contents-literary', but it allows find-file-hooks,
46 automatic uncompression, etc.
48 Namely this function ensures that only format decoding and character
49 code conversion will not take place."
50 (let ((coding-system-for-read 'binary)
52 (insert-file-contents filename visit beg end replace)
55 (define-obsolete-function-alias 'insert-binary-file-contents
56 'insert-file-contents-as-binary)
58 (defun insert-binary-file-contents-literally (filename
59 &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,
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)
73 (defun encode-mime-charset-region (start end charset)
74 "Encode the text between START and END as MIME CHARSET."
75 (let ((cs (mime-charset-to-coding-system charset)))
77 (encode-coding-region start end cs)
80 (defun decode-mime-charset-region (start end charset)
81 "Decode the text between START and END as MIME CHARSET."
82 (let ((cs (mime-charset-to-coding-system charset)))
84 (decode-coding-region start end cs)
87 (defsubst encode-mime-charset-string (string charset)
88 "Encode the STRING as MIME CHARSET."
89 (let ((cs (mime-charset-to-coding-system charset)))
91 (encode-coding-string string cs)
94 (defsubst decode-mime-charset-string (string charset)
95 "Decode the STRING as MIME CHARSET."
96 (let ((cs (mime-charset-to-coding-system charset)))
98 (decode-coding-string string cs)
102 (defvar charsets-mime-charset-alist
103 '(((ascii) . us-ascii)
104 ((ascii latin-iso8859-1) . iso-8859-1)
105 ((ascii latin-iso8859-2) . iso-8859-2)
106 ((ascii latin-iso8859-3) . iso-8859-3)
107 ((ascii latin-iso8859-4) . iso-8859-4)
108 ((ascii cyrillic-iso8859-5) . iso-8859-5)
109 ;;; ((ascii cyrillic-iso8859-5) . koi8-r)
110 ((ascii arabic-iso8859-6) . iso-8859-6)
111 ((ascii greek-iso8859-7) . iso-8859-7)
112 ((ascii hebrew-iso8859-8) . iso-8859-8)
113 ((ascii latin-iso8859-9) . iso-8859-9)
114 ((ascii latin-jisx0201
115 japanese-jisx0208-1978 japanese-jisx0208) . iso-2022-jp)
116 ((ascii korean-ksc5601) . euc-kr)
117 ((ascii chinese-gb2312) . cn-gb-2312)
118 ((ascii chinese-big5-1 chinese-big5-2) . cn-big5)
119 ((ascii latin-iso8859-1 greek-iso8859-7
120 latin-jisx0201 japanese-jisx0208-1978
121 chinese-gb2312 japanese-jisx0208
122 korean-ksc5601 japanese-jisx0212) . iso-2022-jp-2)
123 ((ascii latin-iso8859-1 greek-iso8859-7
124 latin-jisx0201 japanese-jisx0208-1978
125 chinese-gb2312 japanese-jisx0208
126 korean-ksc5601 japanese-jisx0212
127 chinese-cns11643-1 chinese-cns11643-2) . iso-2022-int-1)
128 ((ascii latin-iso8859-1 latin-iso8859-2
129 cyrillic-iso8859-5 greek-iso8859-7
130 latin-jisx0201 japanese-jisx0208-1978
131 chinese-gb2312 japanese-jisx0208
132 korean-ksc5601 japanese-jisx0212
133 chinese-cns11643-1 chinese-cns11643-2
134 chinese-cns11643-3 chinese-cns11643-4
135 chinese-cns11643-5 chinese-cns11643-6
136 chinese-cns11643-7) . iso-2022-int-1)
139 (defun detect-mime-charset-region (start end)
140 "Return MIME charset for region between START and END."
141 (charsets-to-mime-charset (charsets-in-region start end)))
147 (defmacro char-next-index (char index)
148 "Return index of character succeeding CHAR whose index is INDEX."
151 ;;; @@ Mule emulating aliases
153 ;;; You should not use them.
155 ;;(defalias 'char-leading-char 'char-charset)
157 (defun char-category (character)
158 "Return string of category mnemonics for CHAR in TABLE.
159 CHAR can be any multilingual character
160 TABLE defaults to the current buffer's category table."
161 (mapconcat (lambda (chr)
162 (char-to-string (int-char chr))
164 (char-category-list character)
171 (defun string-to-int-list (str)
172 (mapcar #'char-int str)
181 ;;; emu-x20.el ends here