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.46 1997/01/29 15:02:16 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.
31 (defvar xemacs-beta-version
32 (if (string-match "(beta\\([0-9]+\\))" emacs-version)
34 (substring emacs-version (match-beginning 1)(match-end 1))
41 (defconst *noconv* 'no-conversion)
42 (defconst *ctext* 'ctext)
44 (defconst *big5* 'big5)
45 (defconst *euc-kr* 'euc-kr)
46 (defconst *koi8* 'koi8)
48 (defalias 'set-buffer-file-coding-system 'set-file-coding-system)
50 (defmacro as-binary-process (&rest body)
51 `(let (selective-display ; Disable ^M to nl translation.
52 process-input-coding-system
53 process-output-coding-system)
56 (defmacro as-binary-input-file (&rest body)
57 `(let ((file-coding-system-for-read 'no-conversion))
60 (defmacro as-binary-output-file (&rest body)
61 `(let ((file-coding-system 'no-conversion))
68 (defvar charsets-mime-charset-alist
69 '(((ascii) . us-ascii)
70 ((ascii latin-iso8859-1) . iso-8859-1)
71 ((ascii latin-iso8859-2) . iso-8859-2)
72 ((ascii latin-iso8859-3) . iso-8859-3)
73 ((ascii latin-iso8859-4) . iso-8859-4)
74 ;;; ((ascii cyrillic-iso8859-5) . iso-8859-5)
75 ((ascii cyrillic-iso8859-5) . koi8-r)
76 ((ascii arabic-iso8859-6) . iso-8859-6)
77 ((ascii greek-iso8859-7) . iso-8859-7)
78 ((ascii hebrew-iso8859-8) . iso-8859-8)
79 ((ascii latin-iso8859-9) . iso-8859-9)
80 ((ascii latin-jisx0201
81 japanese-jisx0208-1978 japanese-jisx0208) . iso-2022-jp)
82 ((ascii korean-ksc5601) . euc-kr)
83 ((ascii chinese-gb2312) . cn-gb-2312)
84 ((ascii chinese-big5-1 chinese-big5-2) . cn-big5)
85 ((ascii latin-iso8859-1 greek-iso8859-7
86 latin-jisx0201 japanese-jisx0208-1978
87 chinese-gb2312 japanese-jisx0208
88 korean-ksc5601 japanese-jisx0212) . iso-2022-jp-2)
89 ((ascii latin-iso8859-1 greek-iso8859-7
90 latin-jisx0201 japanese-jisx0208-1978
91 chinese-gb2312 japanese-jisx0208
92 korean-ksc5601 japanese-jisx0212
93 chinese-cns11643-1 chinese-cns11643-2) . iso-2022-int-1)
94 ((ascii latin-iso8859-1 latin-iso8859-2
95 cyrillic-iso8859-5 greek-iso8859-7
96 latin-jisx0201 japanese-jisx0208-1978
97 chinese-gb2312 japanese-jisx0208
98 korean-ksc5601 japanese-jisx0212
99 chinese-cns11643-1 chinese-cns11643-2
100 chinese-cns11643-3 chinese-cns11643-4
101 chinese-cns11643-5 chinese-cns11643-6
102 chinese-cns11643-7) . iso-2022-int-1)
105 (defvar default-mime-charset 'x-ctext)
107 (defvar mime-charset-coding-system-alist
108 '((iso-8859-1 . ctext)
111 (cn-gb-2312 . euc-china)
115 (iso-2022-jp-2 . iso-2022-ss2-7)
118 (defun mime-charset-to-coding-system (charset)
119 "Return coding-system by MIME charset. [emu-x20.el]"
120 (if (stringp charset)
121 (setq charset (intern (downcase charset)))
123 (or (cdr (assq charset mime-charset-coding-system-alist))
124 (and (memq charset (coding-system-list)) charset)
127 (defun detect-mime-charset-region (start end)
128 "Return MIME charset for region between START and END.
130 (charsets-to-mime-charset (charsets-in-region start end)))
132 (defun encode-mime-charset-region (start end charset)
133 "Encode the text between START and END as MIME CHARSET.
135 (let ((cs (mime-charset-to-coding-system charset)))
137 (encode-coding-region start end cs)
140 (defun decode-mime-charset-region (start end charset)
141 "Decode the text between START and END as MIME CHARSET.
143 (let ((cs (mime-charset-to-coding-system charset)))
145 (decode-coding-region start end cs)
148 (defun encode-mime-charset-string (string charset)
149 "Encode the STRING as MIME CHARSET. [emu-x20.el]"
150 (let ((cs (mime-charset-to-coding-system charset)))
152 (encode-coding-string string cs)
155 (defun decode-mime-charset-string (string charset)
156 "Decode the STRING as MIME CHARSET. [emu-x20.el]"
157 (let ((cs (mime-charset-to-coding-system charset)))
159 (decode-coding-string string cs)
166 ;; (defun char-bytes (chr) 1)
168 ;; (defun char-length (character)
169 ;; "Return number of elements a CHARACTER occupies in a string or buffer.
173 ;; (defun char-columns (character)
174 ;; "Return number of columns a CHARACTER occupies when displayed.
176 ;; (charset-columns (char-charset character))
179 ;;; @@ Mule emulating aliases
181 ;;; You should not use them.
183 ;;(defalias 'char-width 'char-columns)
185 (defalias 'char-leading-char 'char-charset)
187 (defun char-category (character)
188 "Return string of category mnemonics for CHAR in TABLE.
189 CHAR can be any multilingual character
190 TABLE defaults to the current buffer's category table.
191 \[emu-x20.el; Mule emulating function]"
192 (mapconcat (lambda (chr)
193 (char-to-string (int-char chr))
195 (char-category-list character)
202 ;; (defun string-columns (string)
203 ;; "Return number of columns STRING occupies when displayed.
206 ;; (len (length string))
209 ;; (setq col (+ col (char-columns (aref string i))))
214 ;;(defalias 'string-width 'string-columns)
216 (defun string-to-int-list (str)
217 (mapcar #'char-int str)
220 ;;(defalias 'sref 'aref)
222 ;; (defun truncate-string (str width &optional start-column)
223 ;; "Truncate STR to fit in WIDTH columns.
224 ;; Optional non-nil arg START-COLUMN specifies the starting column.
225 ;; \[emu-x20.el; Mule 2.3 emulating function]"
227 ;; (setq start-column 0))
228 ;; (substring str start-column width)
237 ;;; emu-x20.el ends here