1 ;;; emu-x20.el --- emu API implementation for XEmacs 20 with mule
3 ;; Copyright (C) 1994,1995,1996,1997 MORIOKA Tomohiko
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Version: $Id: emu-x20.el,v 7.52 1997/03/10 11:47:18 morioka Exp $
7 ;; Keywords: emulation, compatibility, Mule, XEmacs
9 ;; This file is part of XEmacs.
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.
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.
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.
28 ;; This module requires XEmacs 20.1 b6 or later with mule.
39 (defconst *noconv* 'no-conversion)
41 (defalias 'set-buffer-file-coding-system 'set-file-coding-system)
43 (defmacro as-binary-process (&rest body)
44 `(let (selective-display ; Disable ^M to nl translation.
45 (coding-system-for-write 'no-conversion)
46 process-input-coding-system
47 process-output-coding-system)
50 (defmacro as-binary-input-file (&rest body)
51 `(let ((coding-system-for-read 'no-conversion))
54 (defmacro as-binary-output-file (&rest body)
55 `(let ((coding-system-for-write 'no-conversion))
62 (defun insert-binary-file-contents-literally
63 (filename &optional visit beg end replace)
64 "Like `insert-file-contents-literally', q.v., but don't code conversion.
65 A buffer may be modified in several ways after reading into the buffer due
66 to advanced Emacs features, such as file-name-handlers, format decoding,
68 This function ensures that none of these modifications will take place."
69 (let ((coding-system-for-read 'no-conversion))
70 (insert-file-contents-literally filename visit beg end replace)
77 (defvar charsets-mime-charset-alist
78 '(((ascii) . us-ascii)
79 ((ascii latin-iso8859-1) . iso-8859-1)
80 ((ascii latin-iso8859-2) . iso-8859-2)
81 ((ascii latin-iso8859-3) . iso-8859-3)
82 ((ascii latin-iso8859-4) . iso-8859-4)
83 ;;; ((ascii cyrillic-iso8859-5) . iso-8859-5)
84 ((ascii cyrillic-iso8859-5) . koi8-r)
85 ((ascii arabic-iso8859-6) . iso-8859-6)
86 ((ascii greek-iso8859-7) . iso-8859-7)
87 ((ascii hebrew-iso8859-8) . iso-8859-8)
88 ((ascii latin-iso8859-9) . iso-8859-9)
89 ((ascii latin-jisx0201
90 japanese-jisx0208-1978 japanese-jisx0208) . iso-2022-jp)
91 ((ascii korean-ksc5601) . euc-kr)
92 ((ascii chinese-gb2312) . cn-gb-2312)
93 ((ascii chinese-big5-1 chinese-big5-2) . cn-big5)
94 ((ascii latin-iso8859-1 greek-iso8859-7
95 latin-jisx0201 japanese-jisx0208-1978
96 chinese-gb2312 japanese-jisx0208
97 korean-ksc5601 japanese-jisx0212) . iso-2022-jp-2)
98 ((ascii latin-iso8859-1 greek-iso8859-7
99 latin-jisx0201 japanese-jisx0208-1978
100 chinese-gb2312 japanese-jisx0208
101 korean-ksc5601 japanese-jisx0212
102 chinese-cns11643-1 chinese-cns11643-2) . iso-2022-int-1)
103 ((ascii latin-iso8859-1 latin-iso8859-2
104 cyrillic-iso8859-5 greek-iso8859-7
105 latin-jisx0201 japanese-jisx0208-1978
106 chinese-gb2312 japanese-jisx0208
107 korean-ksc5601 japanese-jisx0212
108 chinese-cns11643-1 chinese-cns11643-2
109 chinese-cns11643-3 chinese-cns11643-4
110 chinese-cns11643-5 chinese-cns11643-6
111 chinese-cns11643-7) . iso-2022-int-1)
114 (defvar default-mime-charset 'x-ctext)
116 (defvar mime-charset-coding-system-alist
117 '((iso-8859-1 . ctext)
120 (cn-gb-2312 . euc-china)
124 (iso-2022-jp-2 . iso-2022-ss2-7)
127 (defun mime-charset-to-coding-system (charset)
128 "Return coding-system by MIME charset. [emu-x20.el]"
129 (if (stringp charset)
130 (setq charset (intern (downcase charset)))
132 (or (cdr (assq charset mime-charset-coding-system-alist))
133 (and (memq charset (coding-system-list)) charset)
136 (defun detect-mime-charset-region (start end)
137 "Return MIME charset for region between START and END.
139 (charsets-to-mime-charset (charsets-in-region start end)))
141 (defun encode-mime-charset-region (start end charset)
142 "Encode the text between START and END as MIME CHARSET.
144 (let ((cs (mime-charset-to-coding-system charset)))
146 (encode-coding-region start end cs)
149 (defun decode-mime-charset-region (start end charset)
150 "Decode the text between START and END as MIME CHARSET.
152 (let ((cs (mime-charset-to-coding-system charset)))
154 (decode-coding-region start end cs)
157 (defun encode-mime-charset-string (string charset)
158 "Encode the STRING as MIME CHARSET. [emu-x20.el]"
159 (let ((cs (mime-charset-to-coding-system charset)))
161 (encode-coding-string string cs)
164 (defun decode-mime-charset-string (string charset)
165 "Decode the STRING as MIME CHARSET. [emu-x20.el]"
166 (let ((cs (mime-charset-to-coding-system charset)))
168 (decode-coding-string string cs)
175 ;;; @@ Mule emulating aliases
177 ;;; You should not use them.
179 (defalias 'char-leading-char 'char-charset)
181 (defun char-category (character)
182 "Return string of category mnemonics for CHAR in TABLE.
183 CHAR can be any multilingual character
184 TABLE defaults to the current buffer's category table.
185 \[emu-x20.el; Mule emulating function]"
186 (mapconcat (lambda (chr)
187 (char-to-string (int-char chr))
189 (char-category-list character)
196 (defun string-to-int-list (str)
197 (mapcar #'char-int str)
206 ;;; emu-x20.el ends here