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.53 1997/03/12 14:18:27 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 (defmacro as-binary-process (&rest body)
42 `(let (selective-display ; Disable ^M to nl translation.
43 (coding-system-for-write 'no-conversion)
44 process-input-coding-system
45 process-output-coding-system)
48 (defmacro as-binary-input-file (&rest body)
49 `(let ((coding-system-for-read 'no-conversion))
52 (defmacro as-binary-output-file (&rest body)
53 `(let ((coding-system-for-write 'no-conversion))
60 (defun insert-binary-file-contents-literally
61 (filename &optional visit beg end replace)
62 "Like `insert-file-contents-literally', q.v., but don't code conversion.
63 A buffer may be modified in several ways after reading into the buffer due
64 to advanced Emacs features, such as file-name-handlers, format decoding,
66 This function ensures that none of these modifications will take place."
67 (let ((coding-system-for-read 'no-conversion))
68 (insert-file-contents-literally filename visit beg end replace)
75 (defvar charsets-mime-charset-alist
76 '(((ascii) . us-ascii)
77 ((ascii latin-iso8859-1) . iso-8859-1)
78 ((ascii latin-iso8859-2) . iso-8859-2)
79 ((ascii latin-iso8859-3) . iso-8859-3)
80 ((ascii latin-iso8859-4) . iso-8859-4)
81 ;;; ((ascii cyrillic-iso8859-5) . iso-8859-5)
82 ((ascii cyrillic-iso8859-5) . koi8-r)
83 ((ascii arabic-iso8859-6) . iso-8859-6)
84 ((ascii greek-iso8859-7) . iso-8859-7)
85 ((ascii hebrew-iso8859-8) . iso-8859-8)
86 ((ascii latin-iso8859-9) . iso-8859-9)
87 ((ascii latin-jisx0201
88 japanese-jisx0208-1978 japanese-jisx0208) . iso-2022-jp)
89 ((ascii korean-ksc5601) . euc-kr)
90 ((ascii chinese-gb2312) . cn-gb-2312)
91 ((ascii chinese-big5-1 chinese-big5-2) . cn-big5)
92 ((ascii latin-iso8859-1 greek-iso8859-7
93 latin-jisx0201 japanese-jisx0208-1978
94 chinese-gb2312 japanese-jisx0208
95 korean-ksc5601 japanese-jisx0212) . iso-2022-jp-2)
96 ((ascii latin-iso8859-1 greek-iso8859-7
97 latin-jisx0201 japanese-jisx0208-1978
98 chinese-gb2312 japanese-jisx0208
99 korean-ksc5601 japanese-jisx0212
100 chinese-cns11643-1 chinese-cns11643-2) . iso-2022-int-1)
101 ((ascii latin-iso8859-1 latin-iso8859-2
102 cyrillic-iso8859-5 greek-iso8859-7
103 latin-jisx0201 japanese-jisx0208-1978
104 chinese-gb2312 japanese-jisx0208
105 korean-ksc5601 japanese-jisx0212
106 chinese-cns11643-1 chinese-cns11643-2
107 chinese-cns11643-3 chinese-cns11643-4
108 chinese-cns11643-5 chinese-cns11643-6
109 chinese-cns11643-7) . iso-2022-int-1)
112 (defvar default-mime-charset 'x-ctext)
114 (defvar mime-charset-coding-system-alist
115 '((iso-8859-1 . ctext)
118 (cn-gb-2312 . euc-china)
122 (iso-2022-jp-2 . iso-2022-ss2-7)
125 (defun mime-charset-to-coding-system (charset)
126 "Return coding-system by MIME charset. [emu-x20.el]"
127 (if (stringp charset)
128 (setq charset (intern (downcase charset)))
130 (or (cdr (assq charset mime-charset-coding-system-alist))
131 (and (memq charset (coding-system-list)) charset)
134 (defun detect-mime-charset-region (start end)
135 "Return MIME charset for region between START and END.
137 (charsets-to-mime-charset (charsets-in-region start end)))
139 (defun encode-mime-charset-region (start end charset)
140 "Encode the text between START and END as MIME CHARSET.
142 (let ((cs (mime-charset-to-coding-system charset)))
144 (encode-coding-region start end cs)
147 (defun decode-mime-charset-region (start end charset)
148 "Decode the text between START and END as MIME CHARSET.
150 (let ((cs (mime-charset-to-coding-system charset)))
152 (decode-coding-region start end cs)
155 (defun encode-mime-charset-string (string charset)
156 "Encode the STRING as MIME CHARSET. [emu-x20.el]"
157 (let ((cs (mime-charset-to-coding-system charset)))
159 (encode-coding-string string cs)
162 (defun decode-mime-charset-string (string charset)
163 "Decode the STRING as MIME CHARSET. [emu-x20.el]"
164 (let ((cs (mime-charset-to-coding-system charset)))
166 (decode-coding-string string cs)
173 ;;; @@ Mule emulating aliases
175 ;;; You should not use them.
177 (defalias 'char-leading-char 'char-charset)
179 (defun char-category (character)
180 "Return string of category mnemonics for CHAR in TABLE.
181 CHAR can be any multilingual character
182 TABLE defaults to the current buffer's category table.
183 \[emu-x20.el; Mule emulating function]"
184 (mapconcat (lambda (chr)
185 (char-to-string (int-char chr))
187 (char-category-list character)
194 (defun string-to-int-list (str)
195 (mapcar #'char-int str)
204 ;;; emu-x20.el ends here